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 | 951d8dc | 2007-04-15 08:30:33 +0000 | [diff] [blame^] | 4 | ; RUN: llvm-upgrade < %s | llvm-as | opt -inline -simplifycfg | llvm-dis | \ |
| 5 | ; RUN: not grep UnreachableExceptionHandler |
Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 6 | |
| 7 | declare void %might_throw() |
| 8 | |
| 9 | implementation |
| 10 | |
| 11 | internal int %callee() { |
| 12 | invoke void %might_throw() to label %cont except label %exc |
| 13 | cont: |
| 14 | ret int 0 |
| 15 | exc: |
| 16 | ; This just consumes the exception! |
| 17 | ret int 1 |
| 18 | } |
| 19 | |
Chris Lattner | 1853f28 | 2003-08-24 12:16:58 +0000 | [diff] [blame] | 20 | ; caller returns true if might_throw throws an exception... callee cannot throw. |
Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 21 | int %caller() { |
| 22 | %X = invoke int %callee() to label %cont |
| 23 | except label %UnreachableExceptionHandler |
| 24 | cont: |
| 25 | ret int %X |
| 26 | UnreachableExceptionHandler: |
| 27 | ret int -1 ; This is dead! |
| 28 | } |