| Reid Kleckner | 96d0113 | 2015-02-11 01:23:16 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -simplifycfg < %s | FileCheck %s |
| 2 | |
| 3 | ; Don't remove invokes of nounwind functions if the personality handles async |
| 4 | ; exceptions. The @div function in this test can fault, even though it can't |
| 5 | ; throw a synchronous exception. |
| 6 | |
| 7 | define i32 @div(i32 %n, i32 %d) nounwind { |
| 8 | entry: |
| 9 | %div = sdiv i32 %n, %d |
| 10 | ret i32 %div |
| 11 | } |
| 12 | |
| David Majnemer | 7fddecc | 2015-06-17 20:52:32 +0000 | [diff] [blame] | 13 | define i32 @main() nounwind personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) { |
| Reid Kleckner | 96d0113 | 2015-02-11 01:23:16 +0000 | [diff] [blame] | 14 | entry: |
| 15 | %call = invoke i32 @div(i32 10, i32 0) |
| 16 | to label %__try.cont unwind label %lpad |
| 17 | |
| 18 | lpad: |
| David Majnemer | 7fddecc | 2015-06-17 20:52:32 +0000 | [diff] [blame] | 19 | %0 = landingpad { i8*, i32 } |
| Reid Kleckner | 96d0113 | 2015-02-11 01:23:16 +0000 | [diff] [blame] | 20 | catch i8* null |
| 21 | br label %__try.cont |
| 22 | |
| 23 | __try.cont: |
| 24 | %retval.0 = phi i32 [ %call, %entry ], [ 0, %lpad ] |
| 25 | ret i32 %retval.0 |
| 26 | } |
| 27 | |
| 28 | ; CHECK-LABEL: define i32 @main() |
| 29 | ; CHECK: invoke i32 @div(i32 10, i32 0) |
| 30 | |
| 31 | declare i32 @__C_specific_handler(...) |