blob: a5deec6aa88111adf896dbe17f190c3a532181d5 [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
Tanya Lattner5640bd12008-03-01 09:15:35 +00004; RUN: llvm-as < %s | opt -inline | llvm-dis | 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!
17 unwind
Chris Lattner0f12ef62003-08-24 06:55:07 +000018}
19
Tanya Lattner5640bd12008-03-01 09:15:35 +000020; caller returns true if might_throw throws an exception... which gets
Chris Lattner1853f282003-08-24 12:16:58 +000021; propagated by callee.
Tanya Lattner5640bd12008-03-01 09:15:35 +000022define i32 @caller() {
23 %X = invoke i32 @callee( )
24 to label %cont unwind label %Handler ; <i32> [#uses=1]
25
26cont: ; preds = %0
27 ret i32 %X
28
29Handler: ; preds = %0
30; This consumes an exception thrown by might_throw
31 ret i32 1
Chris Lattner0f12ef62003-08-24 06:55:07 +000032}