From 4634880e767051b361963d69940af77e9ab6f8a3 Mon Sep 17 00:00:00 2001 From: Erik Eckstein Date: Wed, 7 Nov 2018 12:51:54 -0800 Subject: [PATCH] SILOptimizer: avoid accessing the class properties if not necessary in redundant load elimination The fix here is to just swap two bail-out conditions. It's a NFC regarding the performed optimization, but it avoids importing class properties, which is not needed. This is a speculative fix for rdar://problem/45806457 --- lib/SIL/Projection.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/SIL/Projection.cpp b/lib/SIL/Projection.cpp index d450907549e7b..b826c5859c40a 100644 --- a/lib/SIL/Projection.cpp +++ b/lib/SIL/Projection.cpp @@ -599,20 +599,7 @@ ProjectionPath::expandTypeIntoLeafProjectionPaths(SILType B, SILModule *Mod, LLVM_DEBUG(llvm::dbgs() << "Visiting type: " << Ty << "\n"); - // Get the first level projection of the current type. - Projections.clear(); - Projection::getFirstLevelProjections(Ty, *Mod, Projections); - - // Reached the end of the projection tree, this field can not be expanded - // anymore. - if (Projections.empty()) { - LLVM_DEBUG(llvm::dbgs() << " No projections. " - "Finished projection list\n"); - Paths.push_back(PP); - continue; - } - - // If this is a class type, we also have reached the end of the type + // If this is a class type, we have reached the end of the type // tree for this type. // // We do not push its next level projection into the worklist, @@ -635,6 +622,19 @@ ProjectionPath::expandTypeIntoLeafProjectionPaths(SILType B, SILModule *Mod, continue; } + // Get the first level projection of the current type. + Projections.clear(); + Projection::getFirstLevelProjections(Ty, *Mod, Projections); + + // Reached the end of the projection tree, this field can not be expanded + // anymore. + if (Projections.empty()) { + LLVM_DEBUG(llvm::dbgs() << " No projections. " + "Finished projection list\n"); + Paths.push_back(PP); + continue; + } + // Keep expanding the location. for (auto &P : Projections) { ProjectionPath X(B);