1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

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
This commit is contained in:
Peter Collingbourne 2015-06-22 20:26:54 +00:00
parent 80f846dbf4
commit bd0552209e
2 changed files with 6 additions and 3 deletions

View File

@ -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);

View File

@ -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: