Skip to content

Commit c82627e

Browse files
authored
[NFC] Improve OnceReduction comment (#6068)
Followup to #6061
1 parent fad0698 commit c82627e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/passes/OnceReduction.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,13 @@ struct OnceReduction : public Pass {
526526
// the global and call bar, and in AFTER we also call bar.
527527
//
528528
// Thus, the behavior is the same, and we can remove the early-exit
529-
// lines.
529+
// lines. Note that things would be quite different if we had any code
530+
// after the call to bar(), as then that code would no longer be
531+
// guarded by an early-exit (and could end up called more than once).
532+
// That is, this optimization depends on the fact that bar's call from
533+
// foo is being guarded by two sets of early-exits, one in foo and one
534+
// in bar, and therefore we only really need one; if foo did anything
535+
// more than just call bar, that would be incorrect.
530536
//
531537
// We must be careful of loops, however: If A calls B and B calls A,
532538
// then at least one must keep the early-exit logic, or else they

0 commit comments

Comments
 (0)