diff options
author | Nikita Popov <npopov@redhat.com> | 2022-11-03 13:16:24 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-11-03 15:21:45 +0100 |
commit | b03f7c3365b1c6ae692b06685a6266d359bfa2d3 (patch) | |
tree | a3d48b94890b029f52d58a5af137332ff570deb7 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | dc9854d4e91e5ede86e8ebb9bfea244cf494e8c6 (diff) | |
download | llvm-b03f7c3365b1c6ae692b06685a6266d359bfa2d3.zip llvm-b03f7c3365b1c6ae692b06685a6266d359bfa2d3.tar.gz llvm-b03f7c3365b1c6ae692b06685a6266d359bfa2d3.tar.bz2 |
[SimplifyCFG] Use range based for loop (NFC)
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index bf0eca5..80854e8 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. |