diff options
author | Hans Wennborg <hans@hanshq.net> | 2014-04-28 17:40:03 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2014-04-28 17:40:03 +0000 |
commit | 6426666f6561785d7d5a6d1904f6df11df655082 (patch) | |
tree | dbe4b3fc2bc6b2a653b439db4562440d00e35305 | |
parent | ac22ae75e3d97ae34b1c2f2e0a28dd2168ed20fb (diff) | |
download | llvm-6426666f6561785d7d5a6d1904f6df11df655082.tar.gz llvm-6426666f6561785d7d5a6d1904f6df11df655082.tar.bz2 llvm-6426666f6561785d7d5a6d1904f6df11df655082.tar.xz |
InstCombine: don't drop 'inalloca' in PromoteCastOfAllocation (PR19569)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207426 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineCasts.cpp | 1 | ||||
-rw-r--r-- | test/Transforms/InstCombine/alloca.ll | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp index de8b94d6c2..70b0a8343f 100644 --- a/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -143,6 +143,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI, AllocaInst *New = AllocaBuilder.CreateAlloca(CastElTy, Amt); New->setAlignment(AI.getAlignment()); New->takeName(&AI); + New->setUsedWithInAlloca(AI.isUsedWithInAlloca()); // If the allocation has multiple real uses, insert a cast and change all // things that used it to use the new cast. This will also hack on CI, but it diff --git a/test/Transforms/InstCombine/alloca.ll b/test/Transforms/InstCombine/alloca.ll index ae1cfa1ed2..6d0c131c51 100644 --- a/test/Transforms/InstCombine/alloca.ll +++ b/test/Transforms/InstCombine/alloca.ll @@ -129,3 +129,24 @@ define void @test8() { call void (...)* @use(i32* %x) ret void } + +; PR19569 +%struct_type = type { i32, i32 } +declare void @test9_aux(<{ %struct_type }>* inalloca) +declare i8* @llvm.stacksave() +declare void @llvm.stackrestore(i8*) + +define void @test9(%struct_type* %a) { +; CHECK-LABEL: @test9( +entry: + %inalloca.save = call i8* @llvm.stacksave() + %argmem = alloca inalloca <{ %struct_type }> +; CHECK: alloca inalloca i64, align 8 + %0 = getelementptr inbounds <{ %struct_type }>* %argmem, i32 0, i32 0 + %1 = bitcast %struct_type* %0 to i8* + %2 = bitcast %struct_type* %a to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* %2, i32 8, i32 4, i1 false) + call void @test9_aux(<{ %struct_type }>* inalloca %argmem) + call void @llvm.stackrestore(i8* %inalloca.save) + ret void +} |