[llvm] [WebAssembly] Merge eh-assembly-legacy.s into eh-assembly.s (PR #111411)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 10:35:02 PDT 2024


https://github.com/aheejin created https://github.com/llvm/llvm-project/pull/111411

Now that we don't need to specify `--no-type-check` on `eh-assembly.s`, we can test the two modes in the same file.

>From a6cfe3d2820efb96d1f92d36817d72f9eb85c9ad Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Fri, 4 Oct 2024 21:19:54 +0000
Subject: [PATCH] [WebAssembly] Merge eh-assembly-legacy.s into eh-assembly.s

Now that we don't need to specify `--no-type-check` on `eh-assembly.s`,
we can test the two modes in the same file.
---
 llvm/test/MC/WebAssembly/eh-assembly-legacy.s | 99 -------------------
 llvm/test/MC/WebAssembly/eh-assembly.s        | 90 +++++++++++++++++
 2 files changed, 90 insertions(+), 99 deletions(-)
 delete mode 100644 llvm/test/MC/WebAssembly/eh-assembly-legacy.s

diff --git a/llvm/test/MC/WebAssembly/eh-assembly-legacy.s b/llvm/test/MC/WebAssembly/eh-assembly-legacy.s
deleted file mode 100644
index deba6cc683f035..00000000000000
--- a/llvm/test/MC/WebAssembly/eh-assembly-legacy.s
+++ /dev/null
@@ -1,99 +0,0 @@
-# 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  foo () -> ()
-
-eh_legacy_test:
-  .functype  eh_legacy_test () -> ()
-
-  # try-catch with catch, catch_all, throw, and rethrow
-  try
-    i32.const 3
-    throw     __cpp_exception
-  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
-
-  # try-catch with a mulvivalue return
-  try () -> (i32, f32)
-    i32.const 0
-    f32.const 0.0
-  catch       __cpp_exception
-    f32.const 1.0
-  end_try
-  drop
-  drop
-
-  # Catch-less try
-  try
-    call  foo
-  end_try
-  end_function
-
-# CHECK-LABEL: eh_legacy_test:
-# CHECK:         try
-# CHECK-NEXT:    i32.const       3
-# 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:         try             () -> (i32, f32)
-# CHECK-NEXT:    i32.const       0
-# CHECK-NEXT:    f32.const       0x0p0
-# CHECK-NEXT:    catch           __cpp_exception
-# CHECK-NEXT:    f32.const       0x1p0
-# CHECK-NEXT:    end_try
-# CHECK-NEXT:    drop
-# CHECK-NEXT:    drop
-
-# CHECK:         try
-# CHECK-NEXT:    call    foo
-# CHECK-NEXT:    end_try
-# CHECK-NEXT:    end_function
-
diff --git a/llvm/test/MC/WebAssembly/eh-assembly.s b/llvm/test/MC/WebAssembly/eh-assembly.s
index d28a7048fb6114..38cda10a387a3b 100644
--- a/llvm/test/MC/WebAssembly/eh-assembly.s
+++ b/llvm/test/MC/WebAssembly/eh-assembly.s
@@ -82,9 +82,58 @@ eh_test:
   end_try_table
   drop
   drop
+  end_function
+
+eh_legacy_test:
+  .functype  eh_legacy_test () -> ()
+
+  # try-catch with catch, catch_all, throw, and rethrow
+  try
+    i32.const 3
+    throw     __cpp_exception
+  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
+
+  # try-catch with a mulvivalue return
+  try () -> (i32, f32)
+    i32.const 0
+    f32.const 0.0
+  catch       __cpp_exception
+    f32.const 1.0
+  end_try
+  drop
+  drop
 
+  # Catch-less try
+  try
+    call  foo
+  end_try
   end_function
 
+
 # CHECK-LABEL: eh_test:
 # CHECK:         block           exnref
 # CHECK-NEXT:    block
@@ -153,3 +202,44 @@ eh_test:
 # CHECK-NEXT:    end_try_table
 # CHECK-NEXT:    drop
 # CHECK-NEXT:    drop
+
+# CHECK:       eh_legacy_test:
+# CHECK:         try
+# CHECK-NEXT:    i32.const       3
+# 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:         try             () -> (i32, f32)
+# CHECK-NEXT:    i32.const       0
+# CHECK-NEXT:    f32.const       0x0p0
+# CHECK-NEXT:    catch           __cpp_exception
+# CHECK-NEXT:    f32.const       0x1p0
+# CHECK-NEXT:    end_try
+# CHECK-NEXT:    drop
+# CHECK-NEXT:    drop
+
+# CHECK:         try
+# CHECK-NEXT:    call    foo
+# CHECK-NEXT:    end_try



More information about the llvm-commits mailing list