132 lines · plain
1; RUN: opt < %s -passes=inline -S | FileCheck %s2; RUN: opt < %s -passes='cgscc(inline)' -S | FileCheck %s3 4@a = global i32 45@_ZTIi = external global ptr6 7; CHECK-LABEL: callSimpleFunction8; CHECK: call i32 @simpleFunction9define i32 @callSimpleFunction(i32 %idx, i32 %limit) {10entry:11 %cmp = icmp sge i32 %idx, %limit12 br i1 %cmp, label %if.then, label %if.end13 14if.then:15 %s = call i32 @simpleFunction(i32 %idx)16 store i32 %s, ptr @a17 unreachable18 19if.end:20 ret i32 %idx21}22 23; CHECK-LABEL: callSmallFunction24; CHECK-NOT: call i32 @smallFunction25define i32 @callSmallFunction(i32 %idx, i32 %limit) {26entry:27 %cmp = icmp sge i32 %idx, %limit28 br i1 %cmp, label %if.then, label %if.end29 30if.then:31 %s = call i32 @smallFunction(i32 %idx)32 store i32 %s, ptr @a33 unreachable34 35if.end:36 ret i32 %idx37}38 39; CHECK-LABEL: throwSimpleException40; CHECK: invoke i32 @simpleFunction41define i32 @throwSimpleException(i32 %idx, i32 %limit) #0 personality ptr @__gxx_personality_v0 {42entry:43 %cmp = icmp sge i32 %idx, %limit44 br i1 %cmp, label %if.then, label %if.end45 46if.then: ; preds = %entry47 %exception = call ptr @__cxa_allocate_exception(i64 1) #048 invoke i32 @simpleFunction(i32 %idx)49 to label %invoke.cont unwind label %lpad50 51invoke.cont: ; preds = %if.then52 call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null) #153 unreachable54 55lpad: ; preds = %if.then56 %ll = landingpad { ptr, i32 }57 cleanup58 ret i32 %idx59 60if.end: ; preds = %entry61 ret i32 %idx62}63 64; CHECK-LABEL: throwSmallException65; CHECK-NOT: invoke i32 @smallFunction66define i32 @throwSmallException(i32 %idx, i32 %limit) #0 personality ptr @__gxx_personality_v0 {67entry:68 %cmp = icmp sge i32 %idx, %limit69 br i1 %cmp, label %if.then, label %if.end70 71if.then: ; preds = %entry72 %exception = call ptr @__cxa_allocate_exception(i64 1) #073 invoke i32 @smallFunction(i32 %idx)74 to label %invoke.cont unwind label %lpad75 76invoke.cont: ; preds = %if.then77 call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null) #178 unreachable79 80lpad: ; preds = %if.then81 %ll = landingpad { ptr, i32 }82 cleanup83 ret i32 %idx84 85if.end: ; preds = %entry86 ret i32 %idx87}88 89define i32 @simpleFunction(i32 %a) #0 {90entry:91 %a1 = load volatile i32, ptr @a92 %x1 = add i32 %a1, %a193 %a2 = load volatile i32, ptr @a94 %x2 = add i32 %x1, %a295 %a3 = load volatile i32, ptr @a96 %x3 = add i32 %x2, %a397 %a4 = load volatile i32, ptr @a98 %x4 = add i32 %x3, %a499 %a5 = load volatile i32, ptr @a100 %x5 = add i32 %x4, %a5101 %a6 = load volatile i32, ptr @a102 %x6 = add i32 %x5, %a6103 %a7 = load volatile i32, ptr @a104 %x7 = add i32 %x6, %a6105 %a8 = load volatile i32, ptr @a106 %x8 = add i32 %x7, %a8107 %a9 = load volatile i32, ptr @a108 %x9 = add i32 %x8, %a9109 %a10 = load volatile i32, ptr @a110 %x10 = add i32 %x9, %a10111 %a11 = load volatile i32, ptr @a112 %x11 = add i32 %x10, %a11113 %a12 = load volatile i32, ptr @a114 %x12 = add i32 %x11, %a12115 %add = add i32 %x12, %a116 ret i32 %add117}118 119define i32 @smallFunction(i32 %a) {120entry:121 %r = load volatile i32, ptr @a122 ret i32 %r123}124 125attributes #0 = { nounwind }126attributes #1 = { noreturn }127 128declare ptr @__cxa_allocate_exception(i64)129declare i32 @__gxx_personality_v0(...)130declare void @__cxa_throw(ptr, ptr, ptr)131 132