1 ; RUN: opt -inline -S < %s | FileCheck %s
2 ; RUN: opt -passes='cgscc(inline)' -S < %s | FileCheck %s
5 ; Make sure doit is not inlined since the blockaddress is taken
6 ; which could be unsafe
7 ; CHECK: store i8* blockaddress(@doit, %here), i8** %pptr, align 8
9 @i = global i32 1, align 4
10 @ptr1 = common global i8* null, align 8
12 define void @doit(i8** nocapture %pptr, i32 %cond) nounwind uwtable {
14 %tobool = icmp eq i32 %cond, 0
15 br i1 %tobool, label %if.end, label %here
18 store i8* blockaddress(@doit, %here), i8** %pptr, align 8
25 define void @f(i32 %cond) nounwind uwtable {
27 call void @doit(i8** @ptr1, i32 %cond)
31 ; PR27233: We can inline @run into @init. Don't crash on it.
33 ; CHECK-LABEL: define void @init
34 ; CHECK: store i8* blockaddress(@run, %bb)
44 store i8* blockaddress(@run, %bb), i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @run.bb, i64 0, i64 0), align 8
51 @run.bb = global [1 x i8*] zeroinitializer
53 ; Check that a function referenced by a global blockaddress wont be inlined,
54 ; even if it contains a callbr. We might be able to relax this in the future
55 ; as long as the global blockaddress is updated correctly.
56 @ba = internal global i8* blockaddress(@foo, %7), align 8
57 define internal i32 @foo(i32) {
58 %2 = alloca i32, align 4
59 %3 = alloca i32, align 4
60 store i32 %0, i32* %3, align 4
61 %4 = load i32, i32* %3, align 4
62 callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %4, i8* blockaddress(@foo, %7), i8* blockaddress(@foo, %6)) #1
63 to label %5 [label %7, label %6]
65 ; <label>:5: ; preds = %1
66 store i32 0, i32* %2, align 4
69 ; <label>:6: ; preds = %1
70 store i32 1, i32* %2, align 4
73 ; <label>:7: ; preds = %1
74 store i32 2, i32* %2, align 4
77 ; <label>:8: ; preds = %7, %6, %5
78 %9 = load i32, i32* %2, align 4
81 define dso_local i32 @bar() {
82 %1 = call i32 @foo(i32 0)
86 ; CHECK: define dso_local i32 @bar() {
87 ; CHECK: %1 = call i32 @foo(i32 0)
91 ; Triple check that even with a global aggregate whose member is a blockaddress,
92 ; we still don't inline referred to functions.
94 %struct.foo = type { i8* }
96 @my_foo = dso_local global %struct.foo { i8* blockaddress(@baz, %7) }
98 define internal i32 @baz(i32) {
99 %2 = alloca i32, align 4
100 %3 = alloca i32, align 4
101 store i32 %0, i32* %3, align 4
102 %4 = load i32, i32* %3, align 4
103 callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %4, i8* blockaddress(@baz, %7), i8* blockaddress(@baz, %6)) #1
104 to label %5 [label %7, label %6]
106 ; <label>:5: ; preds = %1
107 store i32 0, i32* %2, align 4
110 ; <label>:6: ; preds = %1
111 store i32 1, i32* %2, align 4
114 ; <label>:7: ; preds = %1
115 store i32 2, i32* %2, align 4
118 ; <label>:8: ; preds = %7, %6, %5
119 %9 = load i32, i32* %2, align 4
122 define dso_local i32 @quux() {
123 %1 = call i32 @baz(i32 0)
127 ; CHECK: define dso_local i32 @quux() {
128 ; CHECK: %1 = call i32 @baz(i32 0)