diff options
author | Florian Hahn <flo@fhahn.com> | 2022-12-02 12:58:46 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2022-12-02 12:58:46 +0000 |
commit | 63150f463934bcf3a6d2945efea478d2e3250db1 (patch) | |
tree | b029c61ca4f297502e652f87acd43796c82c99f8 /llvm/lib/CodeGen/StackProtector.cpp | |
parent | cfe77f23d6f190d54763a7575cee95aceb9216bc (diff) | |
download | llvm-63150f463934bcf3a6d2945efea478d2e3250db1.zip llvm-63150f463934bcf3a6d2945efea478d2e3250db1.tar.gz llvm-63150f463934bcf3a6d2945efea478d2e3250db1.tar.bz2 |
Revert "Enhance stack protector for calling no return function"
This reverts commit 416e8c6ad529c57f21f46c6f52ded96d3ed239fb.
This commit causes a test failure with expensive checks due to a DT
verification failure. Revert to bring bot back to green:
https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/24249/testReport/junit/LLVM/CodeGen_X86/stack_protector_no_return_ll/
+ /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/clang-build/bin/llc /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm-project/llvm/test/CodeGen/X86/stack-protector-no-return.ll -mtriple=x86_64-unknown-linux-gnu -o -
+ /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/clang-build/bin/FileCheck /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm-project/llvm/test/CodeGen/X86/stack-protector-no-return.ll
DominatorTree is different than a freshly computed one!
Current:
=============================--------------------------------
Inorder Dominator Tree: DFSNumbers invalid: 0 slow queries.
[1] %entry {4294967295,4294967295} [0]
[2] %unreachable {4294967295,4294967295} [1]
[2] %lpad {4294967295,4294967295} [1]
[3] %invoke.cont {4294967295,4294967295} [2]
[4] %invoke.cont2 {4294967295,4294967295} [3]
[4] %SP_return3 {4294967295,4294967295} [3]
[4] %CallStackCheckFailBlk2 {4294967295,4294967295} [3]
[3] %lpad1 {4294967295,4294967295} [2]
[4] %eh.resume {4294967295,4294967295} [3]
[5] %SP_return6 {4294967295,4294967295} [4]
[5] %CallStackCheckFailBlk5 {4294967295,4294967295} [4]
[4] %terminate.lpad {4294967295,4294967295} [3]
[5] %SP_return9 {4294967295,4294967295} [4]
[5] %CallStackCheckFailBlk8 {4294967295,4294967295} [4]
[2] %SP_return {4294967295,4294967295} [1]
[2] %CallStackCheckFailBlk {4294967295,4294967295} [1]
Roots: %entry
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r-- | llvm/lib/CodeGen/StackProtector.cpp | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp index 2f0056f..f974bb6 100644 --- a/llvm/lib/CodeGen/StackProtector.cpp +++ b/llvm/lib/CodeGen/StackProtector.cpp @@ -415,11 +415,11 @@ static Value *getStackGuard(const TargetLoweringBase *TLI, Module *M, /// /// Returns true if the platform/triple supports the stackprotectorcreate pseudo /// node. -static bool CreatePrologue(Function *F, Module *M, Instruction *CheckLoc, +static bool CreatePrologue(Function *F, Module *M, ReturnInst *RI, const TargetLoweringBase *TLI, AllocaInst *&AI) { bool SupportsSelectionDAGSP = false; IRBuilder<> B(&F->getEntryBlock().front()); - PointerType *PtrTy = Type::getInt8PtrTy(CheckLoc->getContext()); + PointerType *PtrTy = Type::getInt8PtrTy(RI->getContext()); AI = B.CreateAlloca(PtrTy, nullptr, "StackGuardSlot"); Value *GuardSlot = getStackGuard(TLI, M, B, &SupportsSelectionDAGSP); @@ -444,27 +444,14 @@ bool StackProtector::InsertStackProtectors() { AllocaInst *AI = nullptr; // Place on stack that stores the stack guard. for (BasicBlock &BB : llvm::make_early_inc_range(*F)) { - Instruction *CheckLoc = dyn_cast<ReturnInst>(BB.getTerminator()); - if (!CheckLoc) { - for (auto &Inst : BB) { - auto *CB = dyn_cast<CallBase>(&Inst); - if (!CB) - continue; - if (!CB->doesNotReturn()) - continue; - // Do stack check before non-return calls (e.g: __cxa_throw) - CheckLoc = CB; - break; - } - } - - if (!CheckLoc) + ReturnInst *RI = dyn_cast<ReturnInst>(BB.getTerminator()); + if (!RI) continue; // Generate prologue instrumentation if not already generated. if (!HasPrologue) { HasPrologue = true; - SupportsSelectionDAGSP &= CreatePrologue(F, M, CheckLoc, TLI, AI); + SupportsSelectionDAGSP &= CreatePrologue(F, M, RI, TLI, AI); } // SelectionDAG based code generation. Nothing else needs to be done here. @@ -490,7 +477,8 @@ bool StackProtector::InsertStackProtectors() { // verifier guarantees that a tail call is either directly before the // return or with a single correct bitcast of the return value in between so // we don't need to worry about many situations here. - Instruction *Prev = CheckLoc->getPrevNonDebugInstruction(); + Instruction *CheckLoc = RI; + Instruction *Prev = RI->getPrevNonDebugInstruction(); if (Prev && isa<CallInst>(Prev) && cast<CallInst>(Prev)->isTailCall()) CheckLoc = Prev; else if (Prev) { |