[llvm] b03f7c3 - [SimplifyCFG] Use range based for loop (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 3 07:21:55 PDT 2022
Author: Nikita Popov
Date: 2022-11-03T15:21:45+01:00
New Revision: b03f7c3365b1c6ae692b06685a6266d359bfa2d3
URL: https://github.com/llvm/llvm-project/commit/b03f7c3365b1c6ae692b06685a6266d359bfa2d3
DIFF: https://github.com/llvm/llvm-project/commit/b03f7c3365b1c6ae692b06685a6266d359bfa2d3.diff
LOG: [SimplifyCFG] Use range based for loop (NFC)
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index bf0eca555014..80854e8ffbd2 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2885,13 +2885,10 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB,
unsigned SpeculatedInstructions = 0;
Value *SpeculatedStoreValue = nullptr;
StoreInst *SpeculatedStore = nullptr;
- for (BasicBlock::iterator BBI = ThenBB->begin(),
- BBE = std::prev(ThenBB->end());
- BBI != BBE; ++BBI) {
- Instruction *I = &*BBI;
+ for (Instruction &I : drop_end(*ThenBB)) {
// Skip debug info.
if (isa<DbgInfoIntrinsic>(I)) {
- SpeculatedDbgIntrinsics.push_back(I);
+ SpeculatedDbgIntrinsics.push_back(&I);
continue;
}
@@ -2903,7 +2900,7 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB,
// the samples collected on the non-conditional path are counted towards
// the conditional path. We leave it for the counts inference algorithm to
// figure out a proper count for an unknown probe.
- SpeculatedDbgIntrinsics.push_back(I);
+ SpeculatedDbgIntrinsics.push_back(&I);
continue;
}
@@ -2914,23 +2911,23 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB,
return false;
// Don't hoist the instruction if it's unsafe or expensive.
- if (!isSafeToSpeculativelyExecute(I) &&
+ if (!isSafeToSpeculativelyExecute(&I) &&
!(HoistCondStores && (SpeculatedStoreValue = isSafeToSpeculateStore(
- I, BB, ThenBB, EndBB))))
+ &I, BB, ThenBB, EndBB))))
return false;
if (!SpeculatedStoreValue &&
- computeSpeculationCost(I, TTI) >
+ computeSpeculationCost(&I, TTI) >
PHINodeFoldingThreshold * TargetTransformInfo::TCC_Basic)
return false;
// Store the store speculation candidate.
if (SpeculatedStoreValue)
- SpeculatedStore = cast<StoreInst>(I);
+ SpeculatedStore = cast<StoreInst>(&I);
// Do not hoist the instruction if any of its operands are defined but not
// used in BB. The transformation will prevent the operand from
// being sunk into the use block.
- for (Use &Op : I->operands()) {
+ for (Use &Op : I.operands()) {
Instruction *OpI = dyn_cast<Instruction>(Op);
if (!OpI || OpI->getParent() != BB || OpI->mayHaveSideEffects())
continue; // Not a candidate for sinking.
More information about the llvm-commits
mailing list