[WebAssembly] Create separate file for EH assembly tests#108472
Merged
[WebAssembly] Create separate file for EH assembly tests#108472
Conversation
Member
|
@llvm/pr-subscribers-mc @llvm/pr-subscribers-backend-webassembly Author: Heejin Ahn (aheejin) ChangesCreate Full diff: https://github.com/llvm/llvm-project/pull/108472.diff 2 Files Affected:
diff --git a/llvm/test/MC/WebAssembly/basic-assembly.s b/llvm/test/MC/WebAssembly/basic-assembly.s
index ac358c1b5c7a52..db7ccc9759beca 100644
--- a/llvm/test/MC/WebAssembly/basic-assembly.s
+++ b/llvm/test/MC/WebAssembly/basic-assembly.s
@@ -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)
@@ -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
@@ -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
diff --git a/llvm/test/MC/WebAssembly/eh-assembly.s b/llvm/test/MC/WebAssembly/eh-assembly.s
new file mode 100644
index 00000000000000..01d237b7237e47
--- /dev/null
+++ b/llvm/test/MC/WebAssembly/eh-assembly.s
@@ -0,0 +1,65 @@
+# 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
+ catch __cpp_exception
+ drop
+ rethrow 0
+ catch __c_longjmp
+ drop
+ catch_all
+ rethrow 0
+ end_try
+
+ # try-catch with a return value
+ try i32
+ i32.const 0
+ catch __cpp_exception
+ end_try
+ drop
+
+ # Nested try-catch with a rethrow
+ try
+ call foo
+ catch_all
+ try
+ catch_all
+ rethrow 1
+ end_try
+ end_try
+ 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 i32
+# CHECK-NEXT: i32.const 0
+# CHECK-NEXT: catch __cpp_exception
+# CHECK-NEXT: end_try
+# CHECK-NEXT: drop
+# 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-NEXT: end_function
|
Create `eh-assembly.s` that contains EH tests and remove EH tests from `basic-assembly.s`, given that it's easier to manage. (We can have many different tests, including the legacy EH and the new exnref, and with nesting for readability)
e7c67a6 to
6989574
Compare
aheejin
commented
Sep 13, 2024
| eh_legacy_test: | ||
| # try-catch with catch, catch_all, throw, and rethrow | ||
| try | ||
| throw __cpp_exception |
Member
Author
There was a problem hiding this comment.
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.
dschuff
approved these changes
Sep 13, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Create
eh-assembly.sthat contains EH tests and remove EH tests frombasic-assembly.s, given that it's easier to manage. (We can have many different tests, including the legacy EH and the new exnref, and with nesting for readability)