blob: 16569db4d38fce3ed7be00a893843e671f1ce564 [file] [log] [blame]
Bill Wendling90bc19c2013-02-20 07:21:42 +00001; RUN: opt < %s -deadargelim -S | FileCheck %s
Chris Lattnerb23aad02009-03-01 00:24:40 +00002
3%Ty = type <{ i32, i32 }>
Matthijs Kooijman48b282f2008-06-20 15:38:22 +00004
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
Matthijs Kooijmand3374462008-07-15 13:15:10 +00007; the function and then changing too much.
Matthijs Kooijman48b282f2008-06-20 15:38:22 +00008
Matthijs Kooijman121a2062008-07-15 14:57:01 +00009; This checks if the return value attributes are not removed
Bill Wendling90bc19c2013-02-20 07:21:42 +000010; CHECK: define internal zeroext i32 @test1() #0
Devang Patel221fe422008-09-29 20:49:50 +000011define internal zeroext i32 @test1(i32 %DEADARG1) nounwind {
Matthijs Kooijman121a2062008-07-15 14:57:01 +000012 ret i32 1
Matthijs Kooijman48b282f2008-06-20 15:38:22 +000013}
14
15; This checks if the struct doesn't get non-packed
Stephen Lina76289a2013-07-14 01:50:49 +000016; CHECK-LABEL: define internal <{ i32, i32 }> @test2(
Matthijs Kooijman48b282f2008-06-20 15:38:22 +000017define 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
Matthijs Kooijman121a2062008-07-15 14:57:01 +000022declare void @user(i32, <{ i32, i32 }>)
Matthijs Kooijman48b282f2008-06-20 15:38:22 +000023
24define void @caller() {
Matthijs Kooijman121a2062008-07-15 14:57:01 +000025 %B = call i32 @test1(i32 1)
Matthijs Kooijman48b282f2008-06-20 15:38:22 +000026 %C = call <{ i32, i32 }> @test2(i32 2)
Matthijs Kooijman121a2062008-07-15 14:57:01 +000027 call void @user(i32 %B, <{ i32, i32 }> %C)
Matthijs Kooijman48b282f2008-06-20 15:38:22 +000028 ret void
29}
30
Reid Klecknerd47a59a2014-02-03 20:42:49 +000031; We can't remove 'this' here, as that would put argmem in ecx instead of
32; memory.
33define 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
39define i32 @caller2() {
40 %t = alloca i32
David Majnemerc4ab61c2014-03-09 06:41:58 +000041 %m = alloca inalloca i32
Reid Klecknerd47a59a2014-02-03 20:42:49 +000042 store i32 42, i32* %m
43 %v = call x86_thiscallcc i32 @unused_this(i32* %t, i32* inalloca %m)
44 ret i32 %v
45}
46
Bill Wendling90bc19c2013-02-20 07:21:42 +000047; CHECK: attributes #0 = { nounwind }