1 ; RUN: opt < %s -passes=deadargelim -S | FileCheck %s
3 declare token @llvm.call.preallocated.setup(i32)
4 declare ptr @llvm.call.preallocated.arg(token, i32)
6 %Ty = type <{ i32, i32 }>
8 ; Check if the pass doesn't modify anything that doesn't need changing. We feed
9 ; an unused argument to each function to lure it into changing _something_ about
10 ; the function and then changing too much.
12 ; This checks if the return value attributes are not removed
13 ; CHECK: define internal zeroext i32 @test1() #1
14 define internal zeroext i32 @test1(i32 %DEADARG1) nounwind {
20 ; This checks if the struct doesn't get non-packed
21 ; CHECK-LABEL: define internal <{ i32, i32 }> @test2(
22 define internal <{ i32, i32 }> @test2(i32 %DEADARG1) {
25 ret <{ i32, i32 }> <{ i32 1, i32 2 }>
28 ; We use this external function to make sure the return values don't become dead
29 declare void @user(i32, <{ i32, i32 }>)
31 define void @caller() {
34 %B = call i32 @test1(i32 1)
35 %C = call <{ i32, i32 }> @test2(i32 2)
36 call void @user(i32 %B, <{ i32, i32 }> %C)
40 ; We can't remove 'this' here, as that would put argmem in ecx instead of
42 define internal x86_thiscallcc i32 @unused_this(ptr %this, ptr inalloca(i32) %argmem) {
45 %v = load i32, ptr %argmem
48 ; CHECK-LABEL: define internal x86_thiscallcc i32 @unused_this(ptr %this, ptr inalloca(i32) %argmem)
50 define i32 @caller2() {
54 %m = alloca inalloca i32
56 %v = call x86_thiscallcc i32 @unused_this(ptr %t, ptr inalloca(i32) %m)
60 ; We can't remove 'this' here, as that would put argmem in ecx instead of
62 define internal x86_thiscallcc i32 @unused_this_preallocated(ptr %this, ptr preallocated(i32) %argmem) {
65 %v = load i32, ptr %argmem
68 ; CHECK-LABEL: define internal x86_thiscallcc i32 @unused_this_preallocated(ptr %this, ptr preallocated(i32) %argmem)
70 define i32 @caller3() {
74 %c = call token @llvm.call.preallocated.setup(i32 1)
75 %M = call ptr @llvm.call.preallocated.arg(token %c, i32 0) preallocated(i32)
77 %v = call x86_thiscallcc i32 @unused_this_preallocated(ptr %t, ptr preallocated(i32) %M) ["preallocated"(token %c)]
81 ; CHECK: attributes #0 = { nocallback nofree nosync nounwind willreturn }
82 ; CHECK: attributes #1 = { nounwind }