1 ; RUN: opt %s -passes='cgscc(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() personality i8* null {
16 invoke void @external_func()
17 to label %cont unwind label %lpad
22 catch i8* @exception_inner
23 %cond = load i1, i1* @condition
24 br i1 %cond, label %resume1, label %resume2
31 define void @outer_multiple_resume() personality i8* null {
32 invoke void @inner_multiple_resume()
33 to label %cont unwind label %lpad
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() personality i8* null {
54 call void @external_func()
55 invoke void @external_func()
56 to label %cont unwind label %lpad
61 catch i8* @exception_inner
65 define void @outer_resume_and_call() personality i8* null {
66 invoke void @inner_resume_and_call()
67 to label %cont unwind label %lpad
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() personality i8* null {
90 invoke void @external_func()
91 to label %cont unwind label %lpad
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() personality i8* null {
103 invoke void @inner_no_resume_or_call()
104 to label %cont unwind label %lpad
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()