aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/StructurizeCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/StructurizeCFG.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
index 3e15cad5f3f3..ac580b4161f4 100644
--- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
+++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
@@ -677,9 +677,8 @@ void StructurizeCFG::killTerminator(BasicBlock *BB) {
if (!Term)
return;
- for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB);
- SI != SE; ++SI)
- delPhiValues(BB, *SI);
+ for (BasicBlock *Succ : successors(BB))
+ delPhiValues(BB, Succ);
if (DA)
DA->removeValue(Term);
@@ -694,11 +693,9 @@ void StructurizeCFG::changeExit(RegionNode *Node, BasicBlock *NewExit,
BasicBlock *OldExit = SubRegion->getExit();
BasicBlock *Dominator = nullptr;
- // Find all the edges from the sub region to the exit
- for (auto BBI = pred_begin(OldExit), E = pred_end(OldExit); BBI != E;) {
- // Incrememt BBI before mucking with BB's terminator.
- BasicBlock *BB = *BBI++;
-
+ // Find all the edges from the sub region to the exit.
+ // We use make_early_inc_range here because we modify BB's terminator.
+ for (BasicBlock *BB : llvm::make_early_inc_range(predecessors(OldExit))) {
if (!SubRegion->contains(BB))
continue;
@@ -924,10 +921,9 @@ void StructurizeCFG::rebuildSSA() {
for (BasicBlock *BB : ParentRegion->blocks())
for (Instruction &I : *BB) {
bool Initialized = false;
- // We may modify the use list as we iterate over it, so be careful to
- // compute the next element in the use list at the top of the loop.
- for (auto UI = I.use_begin(), E = I.use_end(); UI != E;) {
- Use &U = *UI++;
+ // We may modify the use list as we iterate over it, so we use
+ // make_early_inc_range.
+ for (Use &U : llvm::make_early_inc_range(I.uses())) {
Instruction *User = cast<Instruction>(U.getUser());
if (User->getParent() == BB) {
continue;