| 1 |
; REQUIRES: webassembly-registered-target |
| 2 |
; RUN: %clang %s -target wasm32-unknown-unknown -fwasm-exceptions -c -S -o - | FileCheck %s |
| 3 |
|
| 4 |
; This tests whether clang driver can take -fwasm-exceptions and compile bitcode |
| 5 |
; files using Wasm EH. |
| 6 |
|
| 7 |
; CHECK-LABEL: test |
| 8 |
; CHECK: try |
| 9 |
; CHECK: call foo |
| 10 |
; CHECK: catch __cpp_exception |
| 11 |
; CHECK: end |
| 12 |
define void @test() personality ptr @__gxx_wasm_personality_v0 { |
| 13 |
entry: |
| 14 |
invoke void @foo() |
| 15 |
to label %try.cont unwind label %catch.dispatch |
| 16 |
|
| 17 |
catch.dispatch: ; preds = %entry |
| 18 |
%0 = catchswitch within none [label %catch.start] unwind to caller |
| 19 |
|
| 20 |
catch.start: ; preds = %catch.dispatch |
| 21 |
%1 = catchpad within %0 [ptr null] |
| 22 |
%2 = call ptr @llvm.wasm.get.exception(token %1) |
| 23 |
%3 = call i32 @llvm.wasm.get.ehselector(token %1) |
| 24 |
%4 = call ptr @__cxa_begin_catch(ptr %2) #2 [ "funclet"(token %1) ] |
| 25 |
call void @__cxa_end_catch() [ "funclet"(token %1) ] |
| 26 |
catchret from %1 to label %try.cont |
| 27 |
|
| 28 |
try.cont: ; preds = %entry, %catch.start |
| 29 |
ret void |
| 30 |
} |
| 31 |
|
| 32 |
declare void @foo() |
| 33 |
declare i32 @__gxx_wasm_personality_v0(...) |
| 34 |
declare ptr @llvm.wasm.get.exception(token) |
| 35 |
declare i32 @llvm.wasm.get.ehselector(token) |
| 36 |
declare ptr @__cxa_begin_catch(ptr) |
| 37 |
declare void @__cxa_end_catch() |
| 38 |
|