Dan Gohman | 3c7d308 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -deadargelim -S > %t |
Chris Lattner | 60ca3f4 | 2009-03-01 00:24:40 +0000 | [diff] [blame] | 2 | ; RUN: grep {define internal zeroext i32 @test1() nounwind} %t |
| 3 | ; RUN: grep {define internal %Ty @test2} %t |
| 4 | |
| 5 | %Ty = type <{ i32, i32 }> |
Matthijs Kooijman | 3525228 | 2008-06-20 15:38:22 +0000 | [diff] [blame] | 6 | |
| 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 Kooijman | 54a1fe6 | 2008-07-15 13:15:10 +0000 | [diff] [blame] | 9 | ; the function and then changing too much. |
Matthijs Kooijman | 3525228 | 2008-06-20 15:38:22 +0000 | [diff] [blame] | 10 | |
Matthijs Kooijman | 5e67fe2 | 2008-07-15 14:57:01 +0000 | [diff] [blame] | 11 | ; This checks if the return value attributes are not removed |
Devang Patel | cd84248 | 2008-09-29 20:49:50 +0000 | [diff] [blame] | 12 | define internal zeroext i32 @test1(i32 %DEADARG1) nounwind { |
Matthijs Kooijman | 5e67fe2 | 2008-07-15 14:57:01 +0000 | [diff] [blame] | 13 | ret i32 1 |
Matthijs Kooijman | 3525228 | 2008-06-20 15:38:22 +0000 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | ; This checks if the struct doesn't get non-packed |
| 17 | define 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 Kooijman | 5e67fe2 | 2008-07-15 14:57:01 +0000 | [diff] [blame] | 22 | declare void @user(i32, <{ i32, i32 }>) |
Matthijs Kooijman | 3525228 | 2008-06-20 15:38:22 +0000 | [diff] [blame] | 23 | |
| 24 | define void @caller() { |
Matthijs Kooijman | 5e67fe2 | 2008-07-15 14:57:01 +0000 | [diff] [blame] | 25 | %B = call i32 @test1(i32 1) |
Matthijs Kooijman | 3525228 | 2008-06-20 15:38:22 +0000 | [diff] [blame] | 26 | %C = call <{ i32, i32 }> @test2(i32 2) |
Matthijs Kooijman | 5e67fe2 | 2008-07-15 14:57:01 +0000 | [diff] [blame] | 27 | call void @user(i32 %B, <{ i32, i32 }> %C) |
Matthijs Kooijman | 3525228 | 2008-06-20 15:38:22 +0000 | [diff] [blame] | 28 | ret void |
| 29 | } |
| 30 | |