blob: cd0713955a2ee9d629b151f8578ece036645783b [file] [log] [blame]
Sanjay Patel0f153422016-05-09 21:51:53 +00001; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
Chris Lattner03ef2fc2003-05-29 15:16:10 +00002; 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 Gribenkob137c9e2012-12-30 01:28:40 +00005; RUN: opt -S -inline < %s | FileCheck %s
Chandler Carruth625038d2016-12-27 07:18:43 +00006; RUN: opt -S -passes='cgscc(inline)' < %s | FileCheck %s
Chris Lattner03ef2fc2003-05-29 15:16:10 +00007
Tanya Lattner5640bd12008-03-01 09:15:35 +00008define i32 @func(i32 %i) {
Sanjay Patelda7fe0c2016-05-09 18:54:14 +00009 %X = alloca i32
10 store i32 %i, i32* %X
11 ret i32 %i
Chris Lattner03ef2fc2003-05-29 15:16:10 +000012}
13
Tanya Lattner5640bd12008-03-01 09:15:35 +000014declare void @bar()
Chris Lattner03ef2fc2003-05-29 15:16:10 +000015
Tanya Lattner5640bd12008-03-01 09:15:35 +000016define i32 @main(i32 %argc) {
Sanjay Patelda7fe0c2016-05-09 18:54:14 +000017; CHECK-LABEL: @main(
18; CHECK-NEXT: Entry:
19; CHECK-NEXT: [[X_I:%.*]] = alloca i32
20;
Chris Lattner03ef2fc2003-05-29 15:16:10 +000021Entry:
Sanjay Patelda7fe0c2016-05-09 18:54:14 +000022 call void @bar( )
23 %X = call i32 @func( i32 7 )
24 %Y = add i32 %X, %argc
25 ret i32 %Y
Chris Lattner03ef2fc2003-05-29 15:16:10 +000026}
Tanya Lattner5640bd12008-03-01 09:15:35 +000027
Sanjay Patel0f153422016-05-09 21:51:53 +000028; 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
31define 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
46define 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