1 ; RUN: opt < %s -inline -S | FileCheck %s
2 ; RUN: opt < %s -passes='cgscc(inline)' -S | FileCheck %s
5 @_ZTIi = external global i8*
7 ; CHECK-LABEL: callSimpleFunction
8 ; CHECK: call i32 @simpleFunction
9 define i32 @callSimpleFunction(i32 %idx, i32 %limit) {
11 %cmp = icmp sge i32 %idx, %limit
12 br i1 %cmp, label %if.then, label %if.end
15 %s = call i32 @simpleFunction(i32 %idx)
23 ; CHECK-LABEL: callSmallFunction
24 ; CHECK-NOT: call i32 @smallFunction
25 define i32 @callSmallFunction(i32 %idx, i32 %limit) {
27 %cmp = icmp sge i32 %idx, %limit
28 br i1 %cmp, label %if.then, label %if.end
31 %s = call i32 @smallFunction(i32 %idx)
39 ; CHECK-LABEL: throwSimpleException
40 ; CHECK: invoke i32 @simpleFunction
41 define i32 @throwSimpleException(i32 %idx, i32 %limit) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
43 %cmp = icmp sge i32 %idx, %limit
44 br i1 %cmp, label %if.then, label %if.end
46 if.then: ; preds = %entry
47 %exception = call i8* @__cxa_allocate_exception(i64 1) #0
48 invoke i32 @simpleFunction(i32 %idx)
49 to label %invoke.cont unwind label %lpad
51 invoke.cont: ; preds = %if.then
52 call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #1
55 lpad: ; preds = %if.then
56 %ll = landingpad { i8*, i32 }
60 if.end: ; preds = %entry
64 ; CHECK-LABEL: throwSmallException
65 ; CHECK-NOT: invoke i32 @smallFunction
66 define i32 @throwSmallException(i32 %idx, i32 %limit) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
68 %cmp = icmp sge i32 %idx, %limit
69 br i1 %cmp, label %if.then, label %if.end
71 if.then: ; preds = %entry
72 %exception = call i8* @__cxa_allocate_exception(i64 1) #0
73 invoke i32 @smallFunction(i32 %idx)
74 to label %invoke.cont unwind label %lpad
76 invoke.cont: ; preds = %if.then
77 call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #1
80 lpad: ; preds = %if.then
81 %ll = landingpad { i8*, i32 }
85 if.end: ; preds = %entry
89 define i32 @simpleFunction(i32 %a) #0 {
91 %a1 = load volatile i32, i32* @a
92 %x1 = add i32 %a1, %a1
93 %a2 = load volatile i32, i32* @a
94 %x2 = add i32 %x1, %a2
95 %a3 = load volatile i32, i32* @a
96 %x3 = add i32 %x2, %a3
97 %a4 = load volatile i32, i32* @a
98 %x4 = add i32 %x3, %a4
99 %a5 = load volatile i32, i32* @a
100 %x5 = add i32 %x4, %a5
101 %a6 = load volatile i32, i32* @a
102 %x6 = add i32 %x5, %a6
103 %a7 = load volatile i32, i32* @a
104 %x7 = add i32 %x6, %a6
105 %a8 = load volatile i32, i32* @a
106 %x8 = add i32 %x7, %a8
107 %a9 = load volatile i32, i32* @a
108 %x9 = add i32 %x8, %a9
109 %a10 = load volatile i32, i32* @a
110 %x10 = add i32 %x9, %a10
111 %a11 = load volatile i32, i32* @a
112 %x11 = add i32 %x10, %a11
113 %a12 = load volatile i32, i32* @a
114 %x12 = add i32 %x11, %a12
115 %add = add i32 %x12, %a
119 define i32 @smallFunction(i32 %a) {
121 %r = load volatile i32, i32* @a
125 attributes #0 = { nounwind }
126 attributes #1 = { noreturn }
128 declare i8* @__cxa_allocate_exception(i64)
129 declare i32 @__gxx_personality_v0(...)
130 declare void @__cxa_throw(i8*, i8*, i8*)