blob: 1894c434131890d373c8c9130dedb2d116830119 [file] [log] [blame]
Chris Lattner03ef2fc2003-05-29 15:16:10 +00001; This test ensures that alloca instructions in the entry block for an inlined
2; function are moved to the top of the function they are inlined into.
3;
Dmitri Gribenkob137c9e2012-12-30 01:28:40 +00004; RUN: opt -S -inline < %s | FileCheck %s
Chris Lattner03ef2fc2003-05-29 15:16:10 +00005
Tanya Lattner5640bd12008-03-01 09:15:35 +00006define i32 @func(i32 %i) {
Sanjay Patelda7fe0c2016-05-09 18:54:14 +00007 %X = alloca i32
8 store i32 %i, i32* %X
9 ret i32 %i
Chris Lattner03ef2fc2003-05-29 15:16:10 +000010}
11
Tanya Lattner5640bd12008-03-01 09:15:35 +000012declare void @bar()
Chris Lattner03ef2fc2003-05-29 15:16:10 +000013
Tanya Lattner5640bd12008-03-01 09:15:35 +000014define i32 @main(i32 %argc) {
Sanjay Patelda7fe0c2016-05-09 18:54:14 +000015; CHECK-LABEL: @main(
16; CHECK-NEXT: Entry:
17; CHECK-NEXT: [[X_I:%.*]] = alloca i32
18;
Chris Lattner03ef2fc2003-05-29 15:16:10 +000019Entry:
Sanjay Patelda7fe0c2016-05-09 18:54:14 +000020 call void @bar( )
21 %X = call i32 @func( i32 7 )
22 %Y = add i32 %X, %argc
23 ret i32 %Y
Chris Lattner03ef2fc2003-05-29 15:16:10 +000024}
Tanya Lattner5640bd12008-03-01 09:15:35 +000025