Skip to content

[WebAssembly] Create separate file for EH assembly tests #108472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions llvm/test/MC/WebAssembly/basic-assembly.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+tail-call,+reference-types,atomics,+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+tail-call,+reference-types,atomics,+simd128,+nontrapping-fptoint < %s | FileCheck %s
# Check that it converts to .o without errors, but don't check any output:
# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -mattr=+tail-call,+reference-types,+atomics,+simd128,+nontrapping-fptoint,+exception-handling -o %t.o < %s
# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -mattr=+tail-call,+reference-types,+atomics,+simd128,+nontrapping-fptoint -o %t.o < %s

.functype something1 () -> ()
.functype something2 (i64) -> (i32, f64)
Expand Down Expand Up @@ -107,19 +107,14 @@ test0:
#i32x4.trunc_sat_f32x4_s
f32.const 1.0
i32.trunc_f32_s
try
i32.atomic.load 0
i32.const 0
memory.atomic.notify 0
drop
.LBB0_3:
catch __cpp_exception
local.set 0
end_try
i32.const .L.str
i32.load8_u .L.str+2
i32.load16_u .L.str:p2align=0
throw 0
.LBB0_4:
#i32.trunc_sat_f32_s
global.get __stack_pointer
Expand Down Expand Up @@ -249,19 +244,14 @@ empty_exnref_table:
# CHECK-NEXT: drop
# CHECK-NEXT: f32.const 0x1p0
# CHECK-NEXT: i32.trunc_f32_s
# CHECK-NEXT: try
# CHECK-NEXT: i32.atomic.load 0
# CHECK-NEXT: i32.const 0
# CHECK-NEXT: memory.atomic.notify 0
# CHECK-NEXT: drop
# CHECK-NEXT: .LBB0_3:
# CHECK-NEXT: catch __cpp_exception
# CHECK-NEXT: local.set 0
# CHECK-NEXT: end_try
# CHECK-NEXT: i32.const .L.str
# CHECK-NEXT: i32.load8_u .L.str+2
# CHECK-NEXT: i32.load16_u .L.str:p2align=0
# CHECK-NEXT: throw 0
# CHECK-NEXT: .LBB0_4:
# CHECK-NEXT: global.get __stack_pointer
# CHECK-NEXT: global.set __stack_pointer
Expand Down
67 changes: 67 additions & 0 deletions llvm/test/MC/WebAssembly/eh-assembly.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+exception-handling < %s | FileCheck %s
# Check that it converts to .o without errors, but don't check any output:
# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -mattr=+exception-handling -o %t.o < %s

.tagtype __cpp_exception i32
.tagtype __c_longjmp i32
.functype eh_legacy_test () -> ()
.functype foo () -> ()

eh_legacy_test:
# try-catch with catch, catch_all, throw, and rethrow
try
throw __cpp_exception
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw should be preceded with an i32 value but that fails the type checker currently because we don't support throw in the type checker. That will be fixed by a follow-up PR.

catch __cpp_exception
drop
rethrow 0
catch __c_longjmp
drop
catch_all
rethrow 0
end_try

# Nested try-catch with a rethrow
try
call foo
catch_all
try
catch_all
rethrow 1
end_try
end_try

# try-catch with a single return value
try i32
i32.const 0
catch __cpp_exception
end_try
drop
end_function

# CHECK-LABEL: eh_legacy_test:
# CHECK-NEXT: try
# CHECK-NEXT: throw __cpp_exception
# CHECK-NEXT: catch __cpp_exception
# CHECK-NEXT: drop
# CHECK-NEXT: rethrow 0
# CHECK-NEXT: catch __c_longjmp
# CHECK-NEXT: drop
# CHECK-NEXT: catch_all
# CHECK-NEXT: rethrow 0
# CHECK-NEXT: end_try

# CHECK: try
# CHECK-NEXT: call foo
# CHECK-NEXT: catch_all
# CHECK-NEXT: try
# CHECK-NEXT: catch_all
# CHECK-NEXT: rethrow 1
# CHECK-NEXT: end_try
# CHECK-NEXT: end_try

# CHECK: try i32
# CHECK-NEXT: i32.const 0
# CHECK-NEXT: catch __cpp_exception
# CHECK-NEXT: end_try
# CHECK-NEXT: drop
# CHECK-NEXT: end_function
Loading