diff --git a/lib/SILOptimizer/SILCombiner/SILCombine.cpp b/lib/SILOptimizer/SILCombiner/SILCombine.cpp index 4481b188a43c5..df91fb8e13cf9 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombine.cpp +++ b/lib/SILOptimizer/SILCombiner/SILCombine.cpp @@ -172,7 +172,7 @@ bool SILCombiner::trySinkOwnedForwardingInst(SingleValueInstruction *svi) { svi->moveBefore(consumingUser); MadeChange = true; - // NOTE: We return nullptr here so that our caller doesn't delete the + // NOTE: We return false here so that our caller doesn't delete the // instruction and instead tries to simplify it. return false; } diff --git a/lib/SILOptimizer/SILCombiner/SILCombiner.h b/lib/SILOptimizer/SILCombiner/SILCombiner.h index 741e60e70bf86..8fcc715e0d734 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombiner.h +++ b/lib/SILOptimizer/SILCombiner/SILCombiner.h @@ -353,10 +353,6 @@ class SILCombiner : bool optimizeIdentityCastComposition(ApplyInst *FInverse, StringRef FInverseName, StringRef FName); - /// Let \p user and \p value be two forwarding single value instructions with - /// the property that \p user, through potentially a chain of forwarding - /// instructions. - /// /// Let \p user and \p value be two forwarding single value instructions with /// the property that \p value is the value that \p user forwards. In this /// case, this helper routine will eliminate \p value if it can rewrite user diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerCastVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerCastVisitors.cpp index d8e03c625c2e4..2e0fcbcc6a3cd 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombinerCastVisitors.cpp +++ b/lib/SILOptimizer/SILCombiner/SILCombinerCastVisitors.cpp @@ -141,6 +141,7 @@ class SingleBlockOwnedForwardingInstFolder { if (!hasOneNonDebugUse(next)) return false; + assert(getSingleNonDebugUser(rest.back()) == next); rest.push_back(next); return true; } @@ -166,14 +167,13 @@ class SingleBlockOwnedForwardingInstFolder { } private: - /// From backwards -> forwards, for each instruction in rest, delete all of - /// its debug uses and then set its single remaining use to be SILUndef. + /// Processing from def->use by walking rest backwards, delete all of its + /// debug uses and then set its single remaining use to be SILUndef. /// /// This means that after this runs front's forwarding operand is now /// SILUndef. void cleanupRest() & { - // We process backwards -> forwards. This cleans up everything but the front - // value. + // We process from def->use. This cleans up everything but the front value. while (!rest.empty()) { auto *inst = rest.pop_back_val(); deleteAllDebugUses(inst, SC.getInstModCallbacks());