1 ; RUN: opt %s -inline -S | FileCheck %s
3 declare void @external_func()
6 @exception_inner = external global i8
7 @exception_outer = external global i8
8 @condition = external global i1
11 ; Check for a bug in which multiple "resume" instructions in the
12 ; inlined function caused "catch i8* @exception_outer" to appear
13 ; multiple times in the resulting landingpad.
15 define internal void @inner_multiple_resume() {
16 invoke void @external_func()
17 to label %cont unwind label %lpad
21 %lp = landingpad i32 personality i8* null
22 catch i8* @exception_inner
23 %cond = load i1* @condition
24 br i1 %cond, label %resume1, label %resume2
31 define void @outer_multiple_resume() {
32 invoke void @inner_multiple_resume()
33 to label %cont unwind label %lpad
37 %lp = landingpad i32 personality i8* null
38 catch i8* @exception_outer
41 ; CHECK: define void @outer_multiple_resume()
42 ; CHECK: %lp.i = landingpad
43 ; CHECK-NEXT: catch i8* @exception_inner
44 ; CHECK-NEXT: catch i8* @exception_outer
45 ; Check that there isn't another "catch" clause:
49 ; Check for a bug in which having a "resume" and a "call" in the
50 ; inlined function caused "catch i8* @exception_outer" to appear
51 ; multiple times in the resulting landingpad.
53 define internal void @inner_resume_and_call() {
54 call void @external_func()
55 invoke void @external_func()
56 to label %cont unwind label %lpad
60 %lp = landingpad i32 personality i8* null
61 catch i8* @exception_inner
65 define void @outer_resume_and_call() {
66 invoke void @inner_resume_and_call()
67 to label %cont unwind label %lpad
71 %lp = landingpad i32 personality i8* null
72 catch i8* @exception_outer
75 ; CHECK: define void @outer_resume_and_call()
76 ; CHECK: %lp.i = landingpad
77 ; CHECK-NEXT: catch i8* @exception_inner
78 ; CHECK-NEXT: catch i8* @exception_outer
79 ; Check that there isn't another "catch" clause:
83 ; Check what happens if the inlined function contains an "invoke" but
84 ; no "resume". In this case, the inlined landingpad does not need to
85 ; include the "catch i8* @exception_outer" clause from the outer
86 ; function (since the outer function's landingpad will not be
87 ; reachable), but it's OK to include this clause.
89 define internal void @inner_no_resume_or_call() {
90 invoke void @external_func()
91 to label %cont unwind label %lpad
95 %lp = landingpad i32 personality i8* null
96 catch i8* @exception_inner
97 ; A landingpad might have no "resume" if a C++ destructor aborts.
98 call void @abort() noreturn nounwind
102 define void @outer_no_resume_or_call() {
103 invoke void @inner_no_resume_or_call()
104 to label %cont unwind label %lpad
108 %lp = landingpad i32 personality i8* null
109 catch i8* @exception_outer
112 ; CHECK: define void @outer_no_resume_or_call()
113 ; CHECK: %lp.i = landingpad
114 ; CHECK-NEXT: catch i8* @exception_inner
115 ; CHECK-NEXT: catch i8* @exception_outer
116 ; Check that there isn't another "catch" clause:
117 ; CHECK-NEXT: call void @abort()