Fix test.
[oota-llvm.git] / test / Transforms / SRETPromotion / basictest.ll
1 ; RUN: opt < %s -sretpromotion -S > %t
2 ; RUN: cat %t | grep sret | count 1
3
4 ; This function is promotable
5 define internal void @promotable({i32, i32}* sret %s) {
6   %A = getelementptr {i32, i32}* %s, i32 0, i32 0
7   store i32 0, i32* %A
8   %B = getelementptr {i32, i32}* %s, i32 0, i32 0
9   store i32 1, i32* %B
10   ret void
11 }
12
13 ; This function is not promotable (due to it's use below)
14 define internal void @notpromotable({i32, i32}* sret %s) {
15   %A = getelementptr {i32, i32}* %s, i32 0, i32 0
16   store i32 0, i32* %A
17   %B = getelementptr {i32, i32}* %s, i32 0, i32 0
18   store i32 1, i32* %B
19   ret void
20 }
21
22 define void @caller({i32, i32}* %t) {
23   %s = alloca {i32, i32}
24   call void @promotable({i32, i32}* %s)
25   %A = getelementptr {i32, i32}* %s, i32 0, i32 0
26   %a = load i32* %A
27   %B = getelementptr {i32, i32}* %s, i32 0, i32 0
28   %b = load i32* %B
29   ; This passes in something that's not an alloca, which makes the argument not
30   ; promotable
31   call void @notpromotable({i32, i32}* %t)
32   ret void
33 }