From: Evgeniy Stepanov Date: Wed, 25 Nov 2015 22:52:30 +0000 (+0000) Subject: [safestack] Fix alignment of dynamic allocas. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5062813b46e69c0ee735e6fefaa05f2c466e524f;p=oota-llvm.git [safestack] Fix alignment of dynamic allocas. Fixes PR25588. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254109 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Instrumentation/SafeStack.cpp b/lib/Transforms/Instrumentation/SafeStack.cpp index e51822f6942..6071ca5a875 100644 --- a/lib/Transforms/Instrumentation/SafeStack.cpp +++ b/lib/Transforms/Instrumentation/SafeStack.cpp @@ -541,7 +541,7 @@ void SafeStack::moveDynamicAllocasToUnsafeStack( if (DynamicTop) IRB.CreateStore(NewTop, DynamicTop); - Value *NewAI = IRB.CreateIntToPtr(SP, AI->getType()); + Value *NewAI = IRB.CreatePointerCast(NewTop, AI->getType()); if (AI->hasName() && isa(NewAI)) NewAI->takeName(AI); diff --git a/test/Transforms/SafeStack/setjmp2.ll b/test/Transforms/SafeStack/setjmp2.ll index 65fd920d63d..bb15d7e03ac 100644 --- a/test/Transforms/SafeStack/setjmp2.ll +++ b/test/Transforms/SafeStack/setjmp2.ll @@ -25,7 +25,7 @@ entry: ; CHECK-NEXT: %[[INTTOPTR:.*]] = inttoptr i64 %[[AND]] to i8* ; CHECK-NEXT: store i8* %[[INTTOPTR]], i8** @__safestack_unsafe_stack_ptr ; CHECK-NEXT: store i8* %[[INTTOPTR]], i8** %unsafe_stack_dynamic_ptr - ; CHECK-NEXT: %[[ALLOCA:.*]] = inttoptr i64 %[[SUB]] to i32* + ; CHECK-NEXT: %[[ALLOCA:.*]] = bitcast i8* %[[INTTOPTR]] to i32* %a = alloca i32, i32 %size ; CHECK: setjmp