summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp3
-rw-r--r--llvm/lib/Transforms/Utils/LowerSwitch.cpp4
-rw-r--r--llvm/lib/Transforms/Utils/MemorySSA.cpp7
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp20
4 files changed, 16 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 40f5d4ce361..a06c8499e19 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1287,8 +1287,7 @@ updateInlinedAtInfo(const DebugLoc &DL, DILocation *InlinedAtNode,
// Starting from the top, rebuild the nodes to point to the new inlined-at
// location (then rebuilding the rest of the chain behind it) and update the
// map of already-constructed inlined-at nodes.
- for (const DILocation *MD : make_range(InlinedAtLocations.rbegin(),
- InlinedAtLocations.rend())) {
+ for (const DILocation *MD : reverse(InlinedAtLocations)) {
Last = IANodes[MD] = DILocation::getDistinct(
Ctx, MD->getLine(), MD->getColumn(), MD->getScope(), Last);
}
diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
index 52beb154249..e73d28fd98e 100644
--- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
@@ -192,8 +192,8 @@ static void fixPhis(BasicBlock *SuccBB, BasicBlock *OrigBB, BasicBlock *NewBB,
}
// Remove incoming values in the reverse order to prevent invalidating
// *successive* index.
- for (auto III = Indices.rbegin(), IIE = Indices.rend(); III != IIE; ++III)
- PN->removeIncomingValue(*III);
+ for (unsigned III : reverse(Indices))
+ PN->removeIncomingValue(III);
}
}
diff --git a/llvm/lib/Transforms/Utils/MemorySSA.cpp b/llvm/lib/Transforms/Utils/MemorySSA.cpp
index a52ea34e77b..7cff51e9866 100644
--- a/llvm/lib/Transforms/Utils/MemorySSA.cpp
+++ b/llvm/lib/Transforms/Utils/MemorySSA.cpp
@@ -469,10 +469,9 @@ MemoryAccess *MemorySSA::findDominatingDef(BasicBlock *UseBlock,
auto It = PerBlockAccesses.find(CurrNode->getBlock());
if (It != PerBlockAccesses.end()) {
auto &Accesses = It->second;
- for (auto RAI = Accesses->rbegin(), RAE = Accesses->rend(); RAI != RAE;
- ++RAI) {
- if (isa<MemoryDef>(*RAI) || isa<MemoryPhi>(*RAI))
- return &*RAI;
+ for (MemoryAccess &RA : reverse(*Accesses)) {
+ if (isa<MemoryDef>(RA) || isa<MemoryPhi>(RA))
+ return &RA;
}
}
CurrNode = CurrNode->getIDom();
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 7c0f85c2ca1..6e1ac2c9a69 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1534,25 +1534,25 @@ static Value *isSafeToSpeculateStore(Instruction *I, BasicBlock *BrBB,
// Look for a store to the same pointer in BrBB.
unsigned MaxNumInstToLookAt = 9;
- for (BasicBlock::reverse_iterator RI = BrBB->rbegin(), RE = BrBB->rend();
- RI != RE && MaxNumInstToLookAt; ++RI) {
- Instruction *CurI = &*RI;
+ for (Instruction &CurI : reverse(*BrBB)) {
+ if (!MaxNumInstToLookAt)
+ break;
// Skip debug info.
if (isa<DbgInfoIntrinsic>(CurI))
continue;
--MaxNumInstToLookAt;
// Could be calling an instruction that effects memory like free().
- if (CurI->mayHaveSideEffects() && !isa<StoreInst>(CurI))
+ if (CurI.mayHaveSideEffects() && !isa<StoreInst>(CurI))
return nullptr;
- StoreInst *SI = dyn_cast<StoreInst>(CurI);
- // Found the previous store make sure it stores to the same location.
- if (SI && SI->getPointerOperand() == StorePtr)
- // Found the previous store, return its value operand.
- return SI->getValueOperand();
- else if (SI)
+ if (auto *SI = dyn_cast<StoreInst>(&CurI)) {
+ // Found the previous store make sure it stores to the same location.
+ if (SI->getPointerOperand() == StorePtr)
+ // Found the previous store, return its value operand.
+ return SI->getValueOperand();
return nullptr; // Unknown store.
+ }
}
return nullptr;
OpenPOWER on IntegriCloud