IR: Change inalloca's grammar a bit
[oota-llvm.git] / test / Transforms / DeadArgElim / keepalive.ll
1 ; RUN: opt < %s -deadargelim -S | FileCheck %s
2
3 %Ty = type <{ i32, i32 }>
4
5 ; Check if the pass doesn't modify anything that doesn't need changing. We feed
6 ; an unused argument to each function to lure it into changing _something_ about
7 ; the function and then changing too much.
8
9 ; This checks if the return value attributes are not removed
10 ; CHECK: define internal zeroext i32 @test1() #0
11 define internal zeroext i32 @test1(i32 %DEADARG1) nounwind {
12         ret i32 1
13 }
14
15 ; This checks if the struct doesn't get non-packed
16 ; CHECK-LABEL: define internal <{ i32, i32 }> @test2(
17 define internal <{ i32, i32 }> @test2(i32 %DEADARG1) {
18         ret <{ i32, i32 }> <{ i32 1, i32 2 }>
19 }
20
21 ; We use this external function to make sure the return values don't become dead
22 declare void @user(i32, <{ i32, i32 }>)
23
24 define void @caller() {
25         %B = call i32 @test1(i32 1)
26         %C = call <{ i32, i32 }> @test2(i32 2)
27         call void @user(i32 %B, <{ i32, i32 }> %C)
28         ret void
29 }
30
31 ; We can't remove 'this' here, as that would put argmem in ecx instead of
32 ; memory.
33 define internal x86_thiscallcc i32 @unused_this(i32* %this, i32* inalloca %argmem) {
34         %v = load i32* %argmem
35         ret i32 %v
36 }
37 ; CHECK-LABEL: define internal x86_thiscallcc i32 @unused_this(i32* %this, i32* inalloca %argmem)
38
39 define i32 @caller2() {
40         %t = alloca i32
41         %m = alloca inalloca i32
42         store i32 42, i32* %m
43         %v = call x86_thiscallcc i32 @unused_this(i32* %t, i32* inalloca %m)
44         ret i32 %v
45 }
46
47 ; CHECK: attributes #0 = { nounwind }