Move the personality function from LandingPadInst to Function
[oota-llvm.git] / test / Transforms / Inline / invoke_test-2.ll
1 ; Test that if an invoked function is inlined, and if that function cannot
2 ; throw, that the dead handler is now unreachable.
3
4 ; RUN: opt < %s -inline -simplifycfg -S | \
5 ; RUN:   not grep UnreachableExceptionHandler
6
7 declare void @might_throw()
8
9 define internal i32 @callee() personality i32 (...)* @__gxx_personality_v0 {
10         invoke void @might_throw( )
11                         to label %cont unwind label %exc
12
13 cont:           ; preds = %0
14         ret i32 0
15
16 exc:            ; preds = %0
17         %exn = landingpad {i8*, i32}
18                  cleanup
19         ret i32 1
20 }
21
22 ; caller returns true if might_throw throws an exception... callee cannot throw.
23 define i32 @caller() personality i32 (...)* @__gxx_personality_v0 {
24         %X = invoke i32 @callee( )
25                         to label %cont unwind label %UnreachableExceptionHandler                ; <i32> [#uses=1]
26
27 cont:           ; preds = %0
28         ret i32 %X
29
30 UnreachableExceptionHandler:            ; preds = %0
31         %exn = landingpad {i8*, i32}
32                  cleanup
33         ret i32 -1
34 }
35
36 declare i32 @__gxx_personality_v0(...)