blob: 2750b79fbe11fc775ce9690322c68152ba264936 [file] [log] [blame]
Mark Seaborn1b3dd352013-12-08 00:51:21 +00001; RUN: opt %s -inline -S | FileCheck %s
2
3declare void @external_func()
4
5@exception_type1 = external global i8
6@exception_type2 = external global i8
7
8
David Majnemer7fddecc2015-06-17 20:52:32 +00009define internal void @inner() personality i8* null {
Mark Seaborn1b3dd352013-12-08 00:51:21 +000010 invoke void @external_func()
11 to label %cont unwind label %lpad
12cont:
13 ret void
14lpad:
David Majnemer7fddecc2015-06-17 20:52:32 +000015 %lp = landingpad i32
Mark Seaborn1b3dd352013-12-08 00:51:21 +000016 catch i8* @exception_type1
17 resume i32 %lp
18}
19
20; Test that the "cleanup" clause is kept when inlining @inner() into
21; this call site (PR17872), otherwise C++ destructors will not be
22; called when they should be.
23
David Majnemer7fddecc2015-06-17 20:52:32 +000024define void @outer() personality i8* null {
Mark Seaborn1b3dd352013-12-08 00:51:21 +000025 invoke void @inner()
26 to label %cont unwind label %lpad
27cont:
28 ret void
29lpad:
David Majnemer7fddecc2015-06-17 20:52:32 +000030 %lp = landingpad i32
Mark Seaborn1b3dd352013-12-08 00:51:21 +000031 cleanup
32 catch i8* @exception_type2
33 resume i32 %lp
34}
35; CHECK: define void @outer
36; CHECK: landingpad
37; CHECK-NEXT: cleanup
38; CHECK-NEXT: catch i8* @exception_type1
39; CHECK-NEXT: catch i8* @exception_type2