blob: f5ce95aa516cf106dcc25d1f166e5cbaa3433a45 [file] [log] [blame]
Chris Lattner0f12ef62003-08-24 06:55:07 +00001; Test that any rethrown exceptions in an inlined function are automatically
2; turned into branches to the invoke destination.
3
Dan Gohman18800922009-09-11 18:01:28 +00004; RUN: opt < %s -inline -S | not grep unwind$
Chris Lattner0f12ef62003-08-24 06:55:07 +00005
Tanya Lattner5640bd12008-03-01 09:15:35 +00006declare void @might_throw()
Chris Lattner0f12ef62003-08-24 06:55:07 +00007
Tanya Lattner5640bd12008-03-01 09:15:35 +00008define internal i32 @callee() {
9 invoke void @might_throw( )
10 to label %cont unwind label %exc
Chris Lattner0f12ef62003-08-24 06:55:07 +000011
Tanya Lattner5640bd12008-03-01 09:15:35 +000012cont: ; preds = %0
13 ret i32 0
14
15exc: ; preds = %0a
16 ; This just rethrows the exception!
Bill Wendlingd33e3002011-09-01 01:08:21 +000017 %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0
18 cleanup
19 resume { i8*, i32 } %exn
Chris Lattner0f12ef62003-08-24 06:55:07 +000020}
21
Tanya Lattner5640bd12008-03-01 09:15:35 +000022; caller returns true if might_throw throws an exception... which gets
Chris Lattner1853f282003-08-24 12:16:58 +000023; propagated by callee.
Tanya Lattner5640bd12008-03-01 09:15:35 +000024define i32 @caller() {
25 %X = invoke i32 @callee( )
26 to label %cont unwind label %Handler ; <i32> [#uses=1]
27
28cont: ; preds = %0
29 ret i32 %X
30
31Handler: ; preds = %0
32; This consumes an exception thrown by might_throw
Bill Wendlingd33e3002011-09-01 01:08:21 +000033 %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0
34 cleanup
Tanya Lattner5640bd12008-03-01 09:15:35 +000035 ret i32 1
Chris Lattner0f12ef62003-08-24 06:55:07 +000036}
Bill Wendlingd33e3002011-09-01 01:08:21 +000037
38declare i32 @__gxx_personality_v0(...)