blob: bbb9ab055393d61d9e38e946aeb3d1aa428350a2 [file] [log] [blame]
Chris Lattner0f12ef62003-08-24 06:55:07 +00001; Test that if an invoked function is inlined, and if that function cannot
2; throw, that the dead handler is now unreachable.
3
Dan Gohman18800922009-09-11 18:01:28 +00004; RUN: opt < %s -inline -simplifycfg -S | \
Reid Spencer951d8dc2007-04-15 08:30:33 +00005; RUN: not grep UnreachableExceptionHandler
Chris Lattner0f12ef62003-08-24 06:55:07 +00006
Tanya Lattner5640bd12008-03-01 09:15:35 +00007declare void @might_throw()
Chris Lattner0f12ef62003-08-24 06:55:07 +00008
Tanya Lattner5640bd12008-03-01 09:15:35 +00009define internal i32 @callee() {
10 invoke void @might_throw( )
11 to label %cont unwind label %exc
Chris Lattner0f12ef62003-08-24 06:55:07 +000012
Tanya Lattner5640bd12008-03-01 09:15:35 +000013cont: ; preds = %0
14 ret i32 0
15
16exc: ; preds = %0
17 ret i32 1
Chris Lattner0f12ef62003-08-24 06:55:07 +000018}
19
Chris Lattner1853f282003-08-24 12:16:58 +000020; caller returns true if might_throw throws an exception... callee cannot throw.
Tanya Lattner5640bd12008-03-01 09:15:35 +000021define i32 @caller() {
22 %X = invoke i32 @callee( )
23 to label %cont unwind label %UnreachableExceptionHandler ; <i32> [#uses=1]
24
25cont: ; preds = %0
26 ret i32 %X
27
28UnreachableExceptionHandler: ; preds = %0
29 ret i32 -1
Chris Lattner0f12ef62003-08-24 06:55:07 +000030}