[PATCH] D19407: [SafeStack] [SSP] Use llvm.stackguard intrinsic.
Marcin KoĆcielnicki via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 22 03:12:23 PDT 2016
koriakin created this revision.
koriakin added reviewers: timshen, eugenis.
koriakin added a subscriber: llvm-commits.
koriakin set the repository for this revision to rL LLVM.
This is necessary for SafeStack support on PPC64.
Repository:
rL LLVM
http://reviews.llvm.org/D19407
Files:
lib/CodeGen/SafeStack.cpp
test/Transforms/SafeStack/X86/ssp.ll
Index: test/Transforms/SafeStack/X86/ssp.ll
===================================================================
--- test/Transforms/SafeStack/X86/ssp.ll
+++ test/Transforms/SafeStack/X86/ssp.ll
@@ -8,7 +8,7 @@
; CHECK: %[[A:.*]] = getelementptr i8, i8* %[[USP]], i32 -8
; CHECK: %[[StackGuardSlot:.*]] = bitcast i8* %[[A]] to i8**
-; CHECK: %[[StackGuard:.*]] = load i8*, i8** @__stack_chk_guard
+; CHECK: %[[StackGuard:.*]] = call i8* @llvm.stackguard()
; CHECK: store i8* %[[StackGuard]], i8** %[[StackGuardSlot]]
%a = alloca i8, align 1
Index: lib/CodeGen/SafeStack.cpp
===================================================================
--- lib/CodeGen/SafeStack.cpp
+++ lib/CodeGen/SafeStack.cpp
@@ -394,9 +394,12 @@
Value *StackGuardVar = nullptr;
if (TL)
StackGuardVar = TL->getIRStackGuard(IRB);
- if (!StackGuardVar)
- StackGuardVar =
- F.getParent()->getOrInsertGlobal("__stack_chk_guard", StackPtrTy);
+ if (!StackGuardVar) {
+ Module *M = F.getParent();
+ TL->insertSSPDeclarations(*M);
+ Function *SG = Intrinsic::getDeclaration(M, Intrinsic::stackguard);
+ return IRB.CreateCall(SG);
+ }
return IRB.CreateLoad(StackGuardVar, "StackGuard");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19407.54621.patch
Type: text/x-patch
Size: 1208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160422/5c4a5d62/attachment.bin>
More information about the llvm-commits
mailing list