1; RUN: opt < %s -deadargelim -S | FileCheck %s 2 3declare token @llvm.call.preallocated.setup(i32) 4declare i8* @llvm.call.preallocated.arg(token, i32) 5 6%Ty = type <{ i32, i32 }> 7 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. 11 12; This checks if the return value attributes are not removed 13; CHECK: define internal zeroext i32 @test1() #1 14define internal zeroext i32 @test1(i32 %DEADARG1) nounwind { 15; 16; 17 ret i32 1 18} 19 20; This checks if the struct doesn't get non-packed 21; CHECK-LABEL: define internal <{ i32, i32 }> @test2( 22define internal <{ i32, i32 }> @test2(i32 %DEADARG1) { 23; 24; 25 ret <{ i32, i32 }> <{ i32 1, i32 2 }> 26} 27 28; We use this external function to make sure the return values don't become dead 29declare void @user(i32, <{ i32, i32 }>) 30 31define void @caller() { 32; 33; 34 %B = call i32 @test1(i32 1) 35 %C = call <{ i32, i32 }> @test2(i32 2) 36 call void @user(i32 %B, <{ i32, i32 }> %C) 37 ret void 38} 39 40; We can't remove 'this' here, as that would put argmem in ecx instead of 41; memory. 42define internal x86_thiscallcc i32 @unused_this(i32* %this, i32* inalloca %argmem) { 43; 44; 45 %v = load i32, i32* %argmem 46 ret i32 %v 47} 48; CHECK-LABEL: define internal x86_thiscallcc i32 @unused_this(i32* %this, i32* inalloca %argmem) 49 50define i32 @caller2() { 51; 52; 53 %t = alloca i32 54 %m = alloca inalloca i32 55 store i32 42, i32* %m 56 %v = call x86_thiscallcc i32 @unused_this(i32* %t, i32* inalloca %m) 57 ret i32 %v 58} 59 60; We can't remove 'this' here, as that would put argmem in ecx instead of 61; memory. 62define internal x86_thiscallcc i32 @unused_this_preallocated(i32* %this, i32* preallocated(i32) %argmem) { 63; 64; 65 %v = load i32, i32* %argmem 66 ret i32 %v 67} 68; CHECK-LABEL: define internal x86_thiscallcc i32 @unused_this_preallocated(i32* %this, i32* preallocated(i32) %argmem) 69 70define i32 @caller3() { 71; 72; 73 %t = alloca i32 74 %c = call token @llvm.call.preallocated.setup(i32 1) 75 %M = call i8* @llvm.call.preallocated.arg(token %c, i32 0) preallocated(i32) 76 %m = bitcast i8* %M to i32* 77 store i32 42, i32* %m 78 %v = call x86_thiscallcc i32 @unused_this_preallocated(i32* %t, i32* preallocated(i32) %m) ["preallocated"(token %c)] 79 ret i32 %v 80} 81 82; CHECK: attributes #0 = { nofree nosync nounwind willreturn } 83; CHECK: attributes #1 = { nounwind } 84