xref: /llvm-project/llvm/test/Transforms/Inline/invoke-cleanup.ll (revision 151602c7a9935558ca671b35359989b261045db0)
1; RUN: opt %s -passes=inline -S | FileCheck %s
2; RUN: opt %s -passes='cgscc(inline)' -S | FileCheck %s
3; RUN: opt %s -passes='module-inline' -S | FileCheck %s
4
5declare void @external_func()
6
7@exception_type1 = external global i8
8@exception_type2 = external global i8
9
10
11define internal void @inner() personality ptr null {
12  invoke void @external_func()
13      to label %cont unwind label %lpad
14cont:
15  ret void
16lpad:
17  %lp = landingpad i32
18      catch ptr @exception_type1
19  resume i32 %lp
20}
21
22; Test that the "cleanup" clause is kept when inlining @inner() into
23; this call site (PR17872), otherwise C++ destructors will not be
24; called when they should be.
25
26define void @outer() personality ptr null {
27  invoke void @inner()
28      to label %cont unwind label %lpad
29cont:
30  ret void
31lpad:
32  %lp = landingpad i32
33      cleanup
34      catch ptr @exception_type2
35  resume i32 %lp
36}
37; CHECK: define void @outer
38; CHECK: landingpad
39; CHECK-NEXT: cleanup
40; CHECK-NEXT: catch ptr @exception_type1
41; CHECK-NEXT: catch ptr @exception_type2
42