Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 1 | ; Test that if an invoked function is inlined, and if that function cannot |
| 2 | ; throw, that the dead handler is now unreachable. |
| 3 | |
Reid Spencer | d0e30dc | 2006-12-02 04:23:10 +0000 | [diff] [blame] | 4 | ; RUN: llvm-upgrade < %s | llvm-as | opt -inline -simplifycfg | llvm-dis | not grep UnreachableExceptionHandler |
Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 5 | |
| 6 | declare void %might_throw() |
| 7 | |
| 8 | implementation |
| 9 | |
| 10 | internal int %callee() { |
| 11 | invoke void %might_throw() to label %cont except label %exc |
| 12 | cont: |
| 13 | ret int 0 |
| 14 | exc: |
| 15 | ; This just consumes the exception! |
| 16 | ret int 1 |
| 17 | } |
| 18 | |
Chris Lattner | 1853f28 | 2003-08-24 12:16:58 +0000 | [diff] [blame] | 19 | ; caller returns true if might_throw throws an exception... callee cannot throw. |
Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 20 | int %caller() { |
| 21 | %X = invoke int %callee() to label %cont |
| 22 | except label %UnreachableExceptionHandler |
| 23 | cont: |
| 24 | ret int %X |
| 25 | UnreachableExceptionHandler: |
| 26 | ret int -1 ; This is dead! |
| 27 | } |