summaryrefslogtreecommitdiff
path: root/src/passes/CodePushing.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/CodePushing.cpp')
-rw-r--r--src/passes/CodePushing.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/passes/CodePushing.cpp b/src/passes/CodePushing.cpp
index 682f025c8..5026773d4 100644
--- a/src/passes/CodePushing.cpp
+++ b/src/passes/CodePushing.cpp
@@ -161,11 +161,21 @@ private:
// everything that matters if you want to be pushed past the pushPoint
EffectAnalyzer cumulativeEffects(passOptions, module);
cumulativeEffects.walk(list[pushPoint]);
- // it is ok to ignore the branching here, that is the crucial point of this
- // opt
- // TODO: it would be ok to ignore thrown exceptions here, if we know they
- // could not be caught and must go outside of the function
- cumulativeEffects.ignoreBranches();
+ // It is ok to ignore branching out of the block here, that is the crucial
+ // point of this optimization. That is, we are in a situation like this:
+ //
+ // {
+ // x = value;
+ // if (..) break;
+ // foo(x);
+ // }
+ //
+ // If the branch is taken, then that's fine, it will jump out of this block
+ // and reach some outer scope, and in that case we never need x at all
+ // (since we've proven before that x is not used outside of this block, see
+ // numGetsSoFar which we use for that). Similarly, control flow could
+ // transfer away via a return or an exception and that would be ok as well.
+ cumulativeEffects.ignoreControlFlowTransfers();
std::vector<LocalSet*> toPush;
Index i = pushPoint - 1;
while (1) {