blob: 680a5ca2542a299d49aec00c2f60d20cab9827cd [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
Bill Wendlingd33e3002011-09-01 01:08:21 +000017 %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0
18 cleanup
Tanya Lattner5640bd12008-03-01 09:15:35 +000019 ret i32 1
Chris Lattner0f12ef62003-08-24 06:55:07 +000020}
21
Chris Lattner1853f282003-08-24 12:16:58 +000022; caller returns true if might_throw throws an exception... callee cannot throw.
Tanya Lattner5640bd12008-03-01 09:15:35 +000023define i32 @caller() {
24 %X = invoke i32 @callee( )
25 to label %cont unwind label %UnreachableExceptionHandler ; <i32> [#uses=1]
26
27cont: ; preds = %0
28 ret i32 %X
29
30UnreachableExceptionHandler: ; preds = %0
Bill Wendlingd33e3002011-09-01 01:08:21 +000031 %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0
32 cleanup
Tanya Lattner5640bd12008-03-01 09:15:35 +000033 ret i32 -1
Chris Lattner0f12ef62003-08-24 06:55:07 +000034}
Bill Wendlingd33e3002011-09-01 01:08:21 +000035
36declare i32 @__gxx_personality_v0(...)