blob: b0b9bf3fa13bc2b4f8efe19ffb8c9497395c693b [file] [log] [blame]
Dan Gohman3c7d3082009-09-11 18:01:28 +00001; RUN: opt < %s -deadargelim -S > %t
Chris Lattner60ca3f42009-03-01 00:24:40 +00002; RUN: grep {define internal zeroext i32 @test1() nounwind} %t
3; RUN: grep {define internal %Ty @test2} %t
4
5%Ty = type <{ i32, i32 }>
Matthijs Kooijman35252282008-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 Kooijman54a1fe62008-07-15 13:15:10 +00009; the function and then changing too much.
Matthijs Kooijman35252282008-06-20 15:38:22 +000010
Matthijs Kooijman5e67fe22008-07-15 14:57:01 +000011; This checks if the return value attributes are not removed
Devang Patelcd842482008-09-29 20:49:50 +000012define internal zeroext i32 @test1(i32 %DEADARG1) nounwind {
Matthijs Kooijman5e67fe22008-07-15 14:57:01 +000013 ret i32 1
Matthijs Kooijman35252282008-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 Kooijman5e67fe22008-07-15 14:57:01 +000022declare void @user(i32, <{ i32, i32 }>)
Matthijs Kooijman35252282008-06-20 15:38:22 +000023
24define void @caller() {
Matthijs Kooijman5e67fe22008-07-15 14:57:01 +000025 %B = call i32 @test1(i32 1)
Matthijs Kooijman35252282008-06-20 15:38:22 +000026 %C = call <{ i32, i32 }> @test2(i32 2)
Matthijs Kooijman5e67fe22008-07-15 14:57:01 +000027 call void @user(i32 %B, <{ i32, i32 }> %C)
Matthijs Kooijman35252282008-06-20 15:38:22 +000028 ret void
29}
30