1; RUN: opt < %s -inline -S | FileCheck %s 2 3@a = global i32 4 4@_ZTIi = external global i8* 5 6; CHECK-LABEL: callSimpleFunction 7; CHECK: call i32 @simpleFunction 8define i32 @callSimpleFunction(i32 %idx, i32 %limit) { 9entry: 10 %cmp = icmp sge i32 %idx, %limit 11 br i1 %cmp, label %if.then, label %if.end 12 13if.then: 14 %s = call i32 @simpleFunction(i32 %idx) 15 store i32 %s, i32* @a 16 unreachable 17 18if.end: 19 ret i32 %idx 20} 21 22; CHECK-LABEL: callSmallFunction 23; CHECK-NOT: call i32 @smallFunction 24define i32 @callSmallFunction(i32 %idx, i32 %limit) { 25entry: 26 %cmp = icmp sge i32 %idx, %limit 27 br i1 %cmp, label %if.then, label %if.end 28 29if.then: 30 %s = call i32 @smallFunction(i32 %idx) 31 store i32 %s, i32* @a 32 unreachable 33 34if.end: 35 ret i32 %idx 36} 37 38; CHECK-LABEL: throwSimpleException 39; CHECK: invoke i32 @simpleFunction 40define i32 @throwSimpleException(i32 %idx, i32 %limit) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 41entry: 42 %cmp = icmp sge i32 %idx, %limit 43 br i1 %cmp, label %if.then, label %if.end 44 45if.then: ; preds = %entry 46 %exception = call i8* @__cxa_allocate_exception(i64 1) #0 47 invoke i32 @simpleFunction(i32 %idx) 48 to label %invoke.cont unwind label %lpad 49 50invoke.cont: ; preds = %if.then 51 call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #1 52 unreachable 53 54lpad: ; preds = %if.then 55 %ll = landingpad { i8*, i32 } 56 cleanup 57 ret i32 %idx 58 59if.end: ; preds = %entry 60 ret i32 %idx 61} 62 63; CHECK-LABEL: throwSmallException 64; CHECK-NOT: invoke i32 @smallFunction 65define i32 @throwSmallException(i32 %idx, i32 %limit) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 66entry: 67 %cmp = icmp sge i32 %idx, %limit 68 br i1 %cmp, label %if.then, label %if.end 69 70if.then: ; preds = %entry 71 %exception = call i8* @__cxa_allocate_exception(i64 1) #0 72 invoke i32 @smallFunction(i32 %idx) 73 to label %invoke.cont unwind label %lpad 74 75invoke.cont: ; preds = %if.then 76 call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #1 77 unreachable 78 79lpad: ; preds = %if.then 80 %ll = landingpad { i8*, i32 } 81 cleanup 82 ret i32 %idx 83 84if.end: ; preds = %entry 85 ret i32 %idx 86} 87 88define i32 @simpleFunction(i32 %a) #0 { 89entry: 90 %a1 = load volatile i32, i32* @a 91 %x1 = add i32 %a1, %a1 92 %a2 = load volatile i32, i32* @a 93 %x2 = add i32 %x1, %a2 94 %a3 = load volatile i32, i32* @a 95 %x3 = add i32 %x2, %a3 96 %a4 = load volatile i32, i32* @a 97 %x4 = add i32 %x3, %a4 98 %a5 = load volatile i32, i32* @a 99 %x5 = add i32 %x4, %a5 100 %a6 = load volatile i32, i32* @a 101 %x6 = add i32 %x5, %a6 102 %a7 = load volatile i32, i32* @a 103 %x7 = add i32 %x6, %a6 104 %a8 = load volatile i32, i32* @a 105 %x8 = add i32 %x7, %a8 106 %a9 = load volatile i32, i32* @a 107 %x9 = add i32 %x8, %a9 108 %a10 = load volatile i32, i32* @a 109 %x10 = add i32 %x9, %a10 110 %a11 = load volatile i32, i32* @a 111 %x11 = add i32 %x10, %a11 112 %a12 = load volatile i32, i32* @a 113 %x12 = add i32 %x11, %a12 114 %add = add i32 %x12, %a 115 ret i32 %add 116} 117 118define i32 @smallFunction(i32 %a) { 119entry: 120 %r = load volatile i32, i32* @a 121 ret i32 %r 122} 123 124attributes #0 = { nounwind } 125attributes #1 = { noreturn } 126 127declare i8* @__cxa_allocate_exception(i64) 128declare i32 @__gxx_personality_v0(...) 129declare void @__cxa_throw(i8*, i8*, i8*) 130 131