diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/Sink.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/Sink.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/Sink.cpp b/llvm/lib/Transforms/Scalar/Sink.cpp index 7348c45c5d3..2f7a9f9a65c 100644 --- a/llvm/lib/Transforms/Scalar/Sink.cpp +++ b/llvm/lib/Transforms/Scalar/Sink.cpp @@ -258,10 +258,11 @@ bool Sinking::SinkInstruction(Instruction *Inst, // If no suitable postdominator was found, look at all the successors and // decide which one we should sink to, if any. - for (succ_iterator I = succ_begin(Inst->getParent()), - E = succ_end(Inst->getParent()); I != E && !SuccToSinkTo; ++I) { - if (IsAcceptableTarget(Inst, *I)) - SuccToSinkTo = *I; + for (BasicBlock *Succ : successors(Inst->getParent())) { + if (SuccToSinkTo) + break; + if (IsAcceptableTarget(Inst, Succ)) + SuccToSinkTo = Succ; } // If we couldn't find a block to sink to, ignore this instruction. |