[llvm] r240321 - SafeStack: Create the unsafe stack pointer on demand.
Peter Collingbourne
peter at pcc.me.uk
Mon Jun 22 13:26:54 PDT 2015
Author: pcc
Date: Mon Jun 22 15:26:54 2015
New Revision: 240321
URL: http://llvm.org/viewvc/llvm-project?rev=240321&view=rev
Log:
SafeStack: Create the unsafe stack pointer on demand.
This avoids creating an unnecessary undefined reference on targets such as
NVPTX that require such references to be declared in asm output.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/SafeStack.cpp
llvm/trunk/test/Transforms/SafeStack/no-attr.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/SafeStack.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SafeStack.cpp?rev=240321&r1=240320&r2=240321&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SafeStack.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SafeStack.cpp Mon Jun 22 15:26:54 2015
@@ -165,7 +165,7 @@ class SafeStack : public FunctionPass {
Type *Int32Ty;
Type *Int8Ty;
- Constant *UnsafeStackPtr;
+ Constant *UnsafeStackPtr = nullptr;
/// Unsafe stack alignment. Each stack frame must ensure that the stack is
/// aligned to this value. We need to re-align the unsafe stack if the
@@ -232,8 +232,6 @@ public:
Int32Ty = Type::getInt32Ty(M.getContext());
Int8Ty = Type::getInt8Ty(M.getContext());
- UnsafeStackPtr = getOrCreateUnsafeStackPtr(M);
-
return false;
}
@@ -576,6 +574,9 @@ bool SafeStack::runOnFunction(Function &
if (!StackRestorePoints.empty())
++NumUnsafeStackRestorePointsFunctions;
+ if (!UnsafeStackPtr)
+ UnsafeStackPtr = getOrCreateUnsafeStackPtr(*F.getParent());
+
// The top of the unsafe stack after all unsafe static allocas are allocated.
Value *StaticTop = moveStaticAllocasToUnsafeStack(F, StaticAllocas, Returns);
Modified: llvm/trunk/test/Transforms/SafeStack/no-attr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SafeStack/no-attr.ll?rev=240321&r1=240320&r2=240321&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SafeStack/no-attr.ll (original)
+++ llvm/trunk/test/Transforms/SafeStack/no-attr.ll Mon Jun 22 15:26:54 2015
@@ -6,6 +6,8 @@
; no safestack attribute
; Requires no protector.
+; CHECK-NOT: __safestack_unsafe_stack_ptr
+
; CHECK: @foo
define void @foo(i8* %a) nounwind uwtable {
entry:
More information about the llvm-commits
mailing list