aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SafeStack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/SafeStack.cpp')
-rw-r--r--llvm/lib/CodeGen/SafeStack.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp
index 3680617..e097843d 100644
--- a/llvm/lib/CodeGen/SafeStack.cpp
+++ b/llvm/lib/CodeGen/SafeStack.cpp
@@ -373,9 +373,13 @@ bool SafeStack::IsSafeStackAlloca(const Value *AllocaPtr, uint64_t AllocaSize) {
Value *SafeStack::getStackGuard(IRBuilder<> &IRB, Function &F) {
Value *StackGuardVar = TL.getIRStackGuard(IRB);
- if (!StackGuardVar)
- StackGuardVar =
- F.getParent()->getOrInsertGlobal("__stack_chk_guard", StackPtrTy);
+ Module *M = F.getParent();
+
+ if (!StackGuardVar) {
+ TL.insertSSPDeclarations(*M);
+ return IRB.CreateCall(Intrinsic::getDeclaration(M, Intrinsic::stackguard));
+ }
+
return IRB.CreateLoad(StackPtrTy, StackGuardVar, "StackGuard");
}