aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-06-26 13:39:21 +0000
committerDuncan Sands <baldrick@free.fr>2012-06-26 13:39:21 +0000
commit91fa1da2f73ce77d386cacb1a69f38dcdf7cd60c (patch)
tree446595ae1db95df9e03449bf6da17e545706d7c3 /test
parentb787d41959163f6104af7b34a5ce719210dfb72f (diff)
downloadexternal_llvm-91fa1da2f73ce77d386cacb1a69f38dcdf7cd60c.zip
external_llvm-91fa1da2f73ce77d386cacb1a69f38dcdf7cd60c.tar.gz
external_llvm-91fa1da2f73ce77d386cacb1a69f38dcdf7cd60c.tar.bz2
Replacing zero-sized alloca's with a null pointer is too aggressive, instead
merge all zero-sized alloca's into one, fixing c43204g from the Ada ACATS conformance testsuite. What happened there was that a variable sized object was being allocated on the stack, "alloca i8, i32 %size". It was then being passed to another function, which tested that the address was not null (raising an exception if it was) then manipulated %size bytes in it (load and/or store). The optimizers cleverly managed to deduce that %size was zero (congratulations to them, as it isn't at all obvious), which made the alloca zero size, causing the optimizers to replace it with null, which then caused the check mentioned above to fail, and the exception to be raised, wrongly. Note that no loads and stores were actually being done to the alloca (the loop that does them is executed %size times, i.e. is not executed), only the not-null address check. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159202 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/InstCombine/alloca.ll8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/Transforms/InstCombine/alloca.ll b/test/Transforms/InstCombine/alloca.ll
index ef7185c..50e0347 100644
--- a/test/Transforms/InstCombine/alloca.ll
+++ b/test/Transforms/InstCombine/alloca.ll
@@ -5,8 +5,11 @@ target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:1
declare void @use(...)
-; Zero byte allocas should be deleted.
+@int = global i32 zeroinitializer
+
+; Zero byte allocas should be merged if they can't be deleted.
; CHECK: @test
+; CHECK: alloca
; CHECK-NOT: alloca
define void @test() {
%X = alloca [0 x i32] ; <[0 x i32]*> [#uses=1]
@@ -15,6 +18,9 @@ define void @test() {
call void (...)* @use( i32* %Y )
%Z = alloca { } ; <{ }*> [#uses=1]
call void (...)* @use( { }* %Z )
+ %size = load i32* @int
+ %A = alloca {{}}, i32 %size
+ call void (...)* @use( {{}}* %A )
ret void
}