• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
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;
5; RUN: opt -S -inline < %s | FileCheck %s
6
7define i32 @func(i32 %i) {
8  %X = alloca i32
9  store i32 %i, i32* %X
10  ret i32 %i
11}
12
13declare void @bar()
14
15define i32 @main(i32 %argc) {
16; CHECK-LABEL: @main(
17; CHECK-NEXT:  Entry:
18; CHECK-NEXT:    [[X_I:%.*]] = alloca i32
19;
20Entry:
21  call void @bar( )
22  %X = call i32 @func( i32 7 )
23  %Y = add i32 %X, %argc
24  ret i32 %Y
25}
26
27; https://llvm.org/bugs/show_bug.cgi?id=27277
28; Don't assume that the size is a ConstantInt (an undef value is also a constant).
29
30define void @PR27277(i32 %p1) {
31; CHECK-LABEL: @PR27277(
32; CHECK-NEXT:    [[VLA:%.*]] = alloca double, i32 %p1
33; CHECK-NEXT:    call void @PR27277(i32 undef)
34; CHECK-NEXT:    ret void
35;
36  %vla = alloca double, i32 %p1
37  call void @PR27277(i32 undef)
38  ret void
39}
40
41; Don't assume that the size is a ConstantInt (a ConstExpr is also a constant).
42
43@GV = common global i32* null
44
45define void @PR27277_part2(i32 %p1) {
46; CHECK-LABEL: @PR27277_part2(
47; CHECK-NEXT:    [[VLA:%.*]] = alloca double, i32 %p1
48; CHECK-NEXT:    call void @PR27277_part2(i32 ptrtoint (i32** @GV to i32))
49; CHECK-NEXT:    ret void
50;
51  %vla = alloca double, i32 %p1
52  call void @PR27277_part2(i32 ptrtoint (i32** @GV to i32))
53  ret void
54}
55
56