Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 1 | ; Test that any rethrown exceptions in an inlined function are automatically |
| 2 | ; turned into branches to the invoke destination. |
| 3 | |
Reid Spencer | d0e30dc | 2006-12-02 04:23:10 +0000 | [diff] [blame] | 4 | ; RUN: llvm-upgrade < %s | llvm-as | opt -inline | llvm-dis | not grep unwind$ |
Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 5 | |
| 6 | declare void %might_throw() |
Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 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: ; This just rethrows the exception! |
Chris Lattner | bf33da2 | 2005-05-13 15:48:41 +0000 | [diff] [blame] | 15 | unwind |
Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 16 | } |
| 17 | |
Chris Lattner | 1853f28 | 2003-08-24 12:16:58 +0000 | [diff] [blame] | 18 | ; caller returns true if might_throw throws an exception... which gets |
| 19 | ; propagated by callee. |
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 %Handler |
| 23 | cont: |
| 24 | ret int %X |
| 25 | Handler: |
| 26 | ; This consumes an exception thrown by might_throw |
Chris Lattner | 1853f28 | 2003-08-24 12:16:58 +0000 | [diff] [blame] | 27 | ret int 1 |
Chris Lattner | 0f12ef6 | 2003-08-24 06:55:07 +0000 | [diff] [blame] | 28 | } |