diff options
author | Kazu Hirata <kazu@google.com> | 2021-09-18 09:29:24 -0700 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2021-09-18 09:29:24 -0700 |
commit | 48719e3b1861a9b8216dc3aa4dce1b05389f0aff (patch) | |
tree | 2a749bac3b0a39c118d0612031b2b88042db0481 /llvm/lib/CodeGen/StackProtector.cpp | |
parent | 2b44a7325c56cdd78bbcfab7ff7a00126aa5c822 (diff) | |
download | llvm-48719e3b1861a9b8216dc3aa4dce1b05389f0aff.zip llvm-48719e3b1861a9b8216dc3aa4dce1b05389f0aff.tar.gz llvm-48719e3b1861a9b8216dc3aa4dce1b05389f0aff.tar.bz2 |
[CodeGen] Use make_early_inc_range (NFC)
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r-- | llvm/lib/CodeGen/StackProtector.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp index 9f229d5..8143523 100644 --- a/llvm/lib/CodeGen/StackProtector.cpp +++ b/llvm/lib/CodeGen/StackProtector.cpp @@ -440,9 +440,8 @@ bool StackProtector::InsertStackProtectors() { !TM->Options.EnableGlobalISel); AllocaInst *AI = nullptr; // Place on stack that stores the stack guard. - for (Function::iterator I = F->begin(), E = F->end(); I != E;) { - BasicBlock *BB = &*I++; - ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator()); + for (BasicBlock &BB : llvm::make_early_inc_range(*F)) { + ReturnInst *RI = dyn_cast<ReturnInst>(BB.getTerminator()); if (!RI) continue; @@ -530,23 +529,23 @@ bool StackProtector::InsertStackProtectors() { // Split the basic block before the return instruction. BasicBlock *NewBB = - BB->splitBasicBlock(CheckLoc->getIterator(), "SP_return"); + BB.splitBasicBlock(CheckLoc->getIterator(), "SP_return"); // Update the dominator tree if we need to. - if (DT && DT->isReachableFromEntry(BB)) { - DT->addNewBlock(NewBB, BB); - DT->addNewBlock(FailBB, BB); + if (DT && DT->isReachableFromEntry(&BB)) { + DT->addNewBlock(NewBB, &BB); + DT->addNewBlock(FailBB, &BB); } // Remove default branch instruction to the new BB. - BB->getTerminator()->eraseFromParent(); + BB.getTerminator()->eraseFromParent(); // Move the newly created basic block to the point right after the old // basic block so that it's in the "fall through" position. - NewBB->moveAfter(BB); + NewBB->moveAfter(&BB); // Generate the stack protector instructions in the old basic block. - IRBuilder<> B(BB); + IRBuilder<> B(&BB); Value *Guard = getStackGuard(TLI, M, B); LoadInst *LI2 = B.CreateLoad(B.getInt8PtrTy(), AI, true); Value *Cmp = B.CreateICmpEQ(Guard, LI2); |