diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-03-20 11:40:34 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-06-04 11:58:51 +0000 | 
| commit | 4b6eb0e63c698094db5506763df44cc83c19f643 (patch) | |
| tree | f1d30b8c10bc6db323b91538745ae8ab8b593910 /contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp | |
| parent | 76886853f03395abb680824bcc74e98f83bd477a (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp | 30 | 
1 files changed, 13 insertions, 17 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp b/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp index 9f229d51b985..7445f77c955d 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp @@ -148,10 +148,8 @@ bool StackProtector::ContainsProtectableArray(Type *Ty, bool &IsLarge,      return false;    bool NeedsProtector = false; -  for (StructType::element_iterator I = ST->element_begin(), -                                    E = ST->element_end(); -       I != E; ++I) -    if (ContainsProtectableArray(*I, IsLarge, Strong, true)) { +  for (Type *ET : ST->elements()) +    if (ContainsProtectableArray(ET, IsLarge, Strong, true)) {        // If the element is a protectable array and is large (>= SSPBufferSize)        // then we are done.  If the protectable array is not large, then        // keep looking in case a subsequent element is a large array. @@ -436,13 +434,11 @@ bool StackProtector::InsertStackProtectors() {    // protection in SDAG.    bool SupportsSelectionDAGSP =        TLI->useStackGuardXorFP() || -      (EnableSelectionDAGSP && !TM->Options.EnableFastISel && -       !TM->Options.EnableGlobalISel); -  AllocaInst *AI = nullptr;       // Place on stack that stores the stack guard. +      (EnableSelectionDAGSP && !TM->Options.EnableFastISel); +  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 +526,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);  | 
