1; RUN: opt < %s -passes=deadargelim -S | FileCheck %s 2 3declare token @llvm.call.preallocated.setup(i32) 4declare ptr @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(ptr %this, ptr inalloca(i32) %argmem) { 43; 44; 45 %v = load i32, ptr %argmem 46 ret i32 %v 47} 48; CHECK-LABEL: define internal x86_thiscallcc i32 @unused_this(ptr %this, ptr inalloca(i32) %argmem) 49 50define i32 @caller2() { 51; 52; 53 %t = alloca i32 54 %m = alloca inalloca i32 55 store i32 42, ptr %m 56 %v = call x86_thiscallcc i32 @unused_this(ptr %t, ptr inalloca(i32) %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(ptr %this, ptr preallocated(i32) %argmem) { 63; 64; 65 %v = load i32, ptr %argmem 66 ret i32 %v 67} 68; CHECK-LABEL: define internal x86_thiscallcc i32 @unused_this_preallocated(ptr %this, ptr 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 ptr @llvm.call.preallocated.arg(token %c, i32 0) preallocated(i32) 76 store i32 42, ptr %M 77 %v = call x86_thiscallcc i32 @unused_this_preallocated(ptr %t, ptr preallocated(i32) %M) ["preallocated"(token %c)] 78 ret i32 %v 79} 80 81; CHECK: attributes #0 = { nocallback nofree nosync nounwind willreturn } 82; CHECK: attributes #1 = { nounwind } 83