File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed
Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change 2020#include " llvm/Analysis/BranchProbabilityInfo.h"
2121#include " llvm/Analysis/MemoryLocation.h"
2222#include " llvm/Analysis/OptimizationRemarkEmitter.h"
23+ #include " llvm/CodeGen/Analysis.h"
2324#include " llvm/CodeGen/Passes.h"
2425#include " llvm/CodeGen/TargetLowering.h"
2526#include " llvm/CodeGen/TargetPassConfig.h"
@@ -519,18 +520,11 @@ bool StackProtector::InsertStackProtectors() {
519520 HasIRCheck = true ;
520521
521522 // If we're instrumenting a block with a tail call, the check has to be
522- // inserted before the call rather than between it and the return. The
523- // verifier guarantees that a tail call is either directly before the
524- // return or with a single correct bitcast of the return value in between so
525- // we don't need to worry about many situations here.
523+ // inserted before the call rather than between it and the return.
526524 Instruction *Prev = CheckLoc->getPrevNonDebugInstruction ();
527- if (Prev && isa<CallInst>(Prev) && cast<CallInst>(Prev)->isTailCall ())
528- CheckLoc = Prev;
529- else if (Prev) {
530- Prev = Prev->getPrevNonDebugInstruction ();
531- if (Prev && isa<CallInst>(Prev) && cast<CallInst>(Prev)->isTailCall ())
525+ if (auto *CI = dyn_cast_if_present<CallInst>(Prev))
526+ if (CI->isTailCall () && isInTailCallPosition (*CI, *TM))
532527 CheckLoc = Prev;
533- }
534528
535529 // Generate epilogue instrumentation. The epilogue intrumentation can be
536530 // function-based or inlined depending on which mechanism the target is
Original file line number Diff line number Diff line change 1+ ; RUN: llc -mtriple=x86_64-linux-gnu %s -o - 2>&1 | FileCheck %s
2+
3+ declare void @callee ()
4+ define void @caller () sspreq {
5+ ; CHECK: callq callee@PLT
6+ ; CHECK: callq callee@PLT
7+ ; CHECK: cmpq
8+ ; CHECK: jne
9+ ; CHECK: callq __stack_chk_fail@PLT
10+
11+ tail call void @callee ()
12+ call void @callee ()
13+ ret void
14+ }
You can’t perform that action at this time.
0 commit comments