summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2015-06-22 20:26:54 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2015-06-22 20:26:54 +0000
commitde26a918c1ad2e1848978b8dfcd5f382652c1693 (patch)
tree01b0942ccef9bcb09345d542dd80caeb2a5710c8 /llvm/lib/Transforms
parent63b4dc46ca636b0db2592b352afa98e0f1f8fea2 (diff)
downloadbcm5719-llvm-de26a918c1ad2e1848978b8dfcd5f382652c1693.tar.gz
bcm5719-llvm-de26a918c1ad2e1848978b8dfcd5f382652c1693.zip
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. llvm-svn: 240321
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Instrumentation/SafeStack.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SafeStack.cpp b/llvm/lib/Transforms/Instrumentation/SafeStack.cpp
index 13c54121831..6b185a2b127 100644
--- a/llvm/lib/Transforms/Instrumentation/SafeStack.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SafeStack.cpp
@@ -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 &F) {
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);
OpenPOWER on IntegriCloud