blob: dc92dc9f171aa871b7e8ee01b96b0cf38e34b227 [file] [log] [blame]
Dan Gohman18800922009-09-11 18:01:28 +00001; RUN: opt < %s -deadargelim -S > %t
Chandler Carrutha5a29f92012-07-02 12:47:22 +00002; RUN: grep "define internal zeroext i32 @test1() nounwind" %t
3; RUN: grep "define internal <{ i32, i32 }> @test2" %t
Chris Lattnerb23aad02009-03-01 00:24:40 +00004
5%Ty = type <{ i32, i32 }>
Matthijs Kooijman48b282f2008-06-20 15:38:22 +00006
7; Check if the pass doesn't modify anything that doesn't need changing. We feed
8; an unused argument to each function to lure it into changing _something_ about
Matthijs Kooijmand3374462008-07-15 13:15:10 +00009; the function and then changing too much.
Matthijs Kooijman48b282f2008-06-20 15:38:22 +000010
Matthijs Kooijman121a2062008-07-15 14:57:01 +000011; This checks if the return value attributes are not removed
Devang Patel221fe422008-09-29 20:49:50 +000012define internal zeroext i32 @test1(i32 %DEADARG1) nounwind {
Matthijs Kooijman121a2062008-07-15 14:57:01 +000013 ret i32 1
Matthijs Kooijman48b282f2008-06-20 15:38:22 +000014}
15
16; This checks if the struct doesn't get non-packed
17define 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