Sanjay Patel | 0f15342 | 2016-05-09 21:51:53 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
Chris Lattner | 03ef2fc | 2003-05-29 15:16:10 +0000 | [diff] [blame] | 2 | ; This test ensures that alloca instructions in the entry block for an inlined |
| 3 | ; function are moved to the top of the function they are inlined into. |
| 4 | ; |
Dmitri Gribenko | b137c9e | 2012-12-30 01:28:40 +0000 | [diff] [blame] | 5 | ; RUN: opt -S -inline < %s | FileCheck %s |
Chandler Carruth | 625038d | 2016-12-27 07:18:43 +0000 | [diff] [blame] | 6 | ; RUN: opt -S -passes='cgscc(inline)' < %s | FileCheck %s |
Chris Lattner | 03ef2fc | 2003-05-29 15:16:10 +0000 | [diff] [blame] | 7 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 8 | define i32 @func(i32 %i) { |
Sanjay Patel | da7fe0c | 2016-05-09 18:54:14 +0000 | [diff] [blame] | 9 | %X = alloca i32 |
| 10 | store i32 %i, i32* %X |
| 11 | ret i32 %i |
Chris Lattner | 03ef2fc | 2003-05-29 15:16:10 +0000 | [diff] [blame] | 12 | } |
| 13 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 14 | declare void @bar() |
Chris Lattner | 03ef2fc | 2003-05-29 15:16:10 +0000 | [diff] [blame] | 15 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 16 | define i32 @main(i32 %argc) { |
Sanjay Patel | da7fe0c | 2016-05-09 18:54:14 +0000 | [diff] [blame] | 17 | ; CHECK-LABEL: @main( |
| 18 | ; CHECK-NEXT: Entry: |
| 19 | ; CHECK-NEXT: [[X_I:%.*]] = alloca i32 |
| 20 | ; |
Chris Lattner | 03ef2fc | 2003-05-29 15:16:10 +0000 | [diff] [blame] | 21 | Entry: |
Sanjay Patel | da7fe0c | 2016-05-09 18:54:14 +0000 | [diff] [blame] | 22 | call void @bar( ) |
| 23 | %X = call i32 @func( i32 7 ) |
| 24 | %Y = add i32 %X, %argc |
| 25 | ret i32 %Y |
Chris Lattner | 03ef2fc | 2003-05-29 15:16:10 +0000 | [diff] [blame] | 26 | } |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 27 | |
Sanjay Patel | 0f15342 | 2016-05-09 21:51:53 +0000 | [diff] [blame] | 28 | ; https://llvm.org/bugs/show_bug.cgi?id=27277 |
| 29 | ; Don't assume that the size is a ConstantInt (an undef value is also a constant). |
| 30 | |
| 31 | define void @PR27277(i32 %p1) { |
| 32 | ; CHECK-LABEL: @PR27277( |
| 33 | ; CHECK-NEXT: [[VLA:%.*]] = alloca double, i32 %p1 |
| 34 | ; CHECK-NEXT: call void @PR27277(i32 undef) |
| 35 | ; CHECK-NEXT: ret void |
| 36 | ; |
| 37 | %vla = alloca double, i32 %p1 |
| 38 | call void @PR27277(i32 undef) |
| 39 | ret void |
| 40 | } |
| 41 | |
| 42 | ; Don't assume that the size is a ConstantInt (a ConstExpr is also a constant). |
| 43 | |
| 44 | @GV = common global i32* null |
| 45 | |
| 46 | define void @PR27277_part2(i32 %p1) { |
| 47 | ; CHECK-LABEL: @PR27277_part2( |
| 48 | ; CHECK-NEXT: [[VLA:%.*]] = alloca double, i32 %p1 |
| 49 | ; CHECK-NEXT: call void @PR27277_part2(i32 ptrtoint (i32** @GV to i32)) |
| 50 | ; CHECK-NEXT: ret void |
| 51 | ; |
| 52 | %vla = alloca double, i32 %p1 |
| 53 | call void @PR27277_part2(i32 ptrtoint (i32** @GV to i32)) |
| 54 | ret void |
| 55 | } |
| 56 | |