Skip to content

Commit 04e281e

Browse files
Fix
1 parent 52d145c commit 04e281e

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/passes/CodeFolding.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,7 @@ struct CodeFolding
645645
if (tails.size() < 2) {
646646
return false;
647647
}
648-
// Compute body branch targets once and share across recursive calls to
649-
// avoid repeated O(N) tree walks.
650648
BranchUtils::NameSet localBodyTargets;
651-
if (!bodyTargets) {
652-
localBodyTargets = BranchUtils::getBranchTargets(getFunction()->body);
653-
bodyTargets = &localBodyTargets;
654-
}
655649
// remove things that are untoward and cannot be optimized
656650
tails.erase(
657651
std::remove_if(tails.begin(),
@@ -811,6 +805,13 @@ struct CodeFolding
811805
// as the changes may influence us. we leave further opts to further
812806
// passes (as this is rare in practice, it's generally not a perf
813807
// issue, but TODO optimize)
808+
// Compute body branch targets once and share across recursive
809+
// calls to avoid repeated O(N) tree walks.
810+
if (!bodyTargets) {
811+
localBodyTargets =
812+
BranchUtils::getBranchTargets(getFunction()->body);
813+
bodyTargets = &localBodyTargets;
814+
}
814815
if (optimizeTerminatingTails(explore, num + 1, bodyTargets)) {
815816
return true;
816817
}

0 commit comments

Comments
 (0)