83 lines · plain
1; RUN: opt < %s -passes=deadargelim -S | FileCheck %s2 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 feed9; an unused argument to each function to lure it into changing _something_ about10; the function and then changing too much.11 12; This checks if the return value attributes are not removed13; CHECK: define internal zeroext i32 @test1() #114define internal zeroext i32 @test1(i32 %DEADARG1) nounwind {15;16;17 ret i32 118}19 20; This checks if the struct doesn't get non-packed21; 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 dead29declare 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 void38}39 40; We can't remove 'this' here, as that would put argmem in ecx instead of41; memory.42define internal x86_thiscallcc i32 @unused_this(ptr %this, ptr inalloca(i32) %argmem) {43;44;45 %v = load i32, ptr %argmem46 ret i32 %v47}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 i3254 %m = alloca inalloca i3255 store i32 42, ptr %m56 %v = call x86_thiscallcc i32 @unused_this(ptr %t, ptr inalloca(i32) %m)57 ret i32 %v58}59 60; We can't remove 'this' here, as that would put argmem in ecx instead of61; memory.62define internal x86_thiscallcc i32 @unused_this_preallocated(ptr %this, ptr preallocated(i32) %argmem) {63;64;65 %v = load i32, ptr %argmem66 ret i32 %v67}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 i3274 %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 %M77 %v = call x86_thiscallcc i32 @unused_this_preallocated(ptr %t, ptr preallocated(i32) %M) ["preallocated"(token %c)]78 ret i32 %v79}80 81; CHECK: attributes #0 = { nocallback nofree nosync nounwind willreturn }82; CHECK: attributes #1 = { nounwind }83