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