[llvm] [MC][WebAssembly] Convert tag section tests to assembly. NFC (PR #159141)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 11:14:41 PDT 2025


================
@@ -0,0 +1,63 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+exception-handling -filetype=obj %s | obj2yaml | FileCheck %s
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+exception-handling -filetype=obj %s | llvm-readobj -S - | FileCheck -check-prefix=SEC %s
+
+.tagtype my_exception i32
+
+.globl test_throw0
+test_throw0:
+  .functype test_throw0 (i32) -> (i32)
+  i32.const 0
+  throw my_exception
+  i32.const 0
+  end_function
+
+.globl test_throw1
+test_throw1:
+  .functype test_throw1 (i32) -> (i32)
+  i32.const 0
+  throw my_exception
+  i32.const 0
+  end_function
+
+.globl my_exception
+my_exception:
+
+# CHECK:      Sections:
+# CHECK-NEXT:   - Type:            TYPE
+# CHECK-NEXT:     Signatures:
+# CHECK-NEXT:       - Index:           0
+# CHECK-NEXT:         ParamTypes:
+# CHECK-NEXT:           - I32
+# CHECK-NEXT:         ReturnTypes:
+# CHECK-NEXT:           - I32
+# CHECK-NEXT:       - Index:           1
+# CHECK-NEXT:         ParamTypes:
+# CHECK-NEXT:           - I32
+# CHECK-NEXT:         ReturnTypes:      []
+
+# CHECK:        - Type:            TAG
+# CHECK-NEXT:     TagTypes:        [ 1 ]
+
+# CHECK-NEXT:   - Type:            CODE
+# CHECK-NEXT:     Relocations:
+# CHECK-NEXT:       - Type:            R_WASM_TAG_INDEX_LEB
+# CHECK-NEXT:         Index:           1
+# CHECK-NEXT:         Offset:          0x6
+# CHECK-NEXT:       - Type:            R_WASM_TAG_INDEX_LEB
+# CHECK-NEXT:         Index:           1
+# CHECK-NEXT:         Offset:          0x13
+
+# CHECK:        - Type:            CUSTOM
+# CHECK-NEXT:     Name:            linking
+# CHECK-NEXT:     Version:         2
+# CHECK-NEXT:     SymbolTable:
+
+# CHECK:            - Index:           1
+# CHECK-NEXT:         Kind:            TAG
+# CHECK-NEXT:         Name:            my_exception
+# CHECK-NEXT:         Flags:           [ ]
----------------
sbc100 wrote:

`__cpp_exception` did not change at all here.   I just changed the test to use `my_exception` instead of `__cpp_exception` which the old `.ll` was referencing.  

I didn't both to make `my_exception` weakly defined since that is not important to this test.

The reason the old test used `__cpp_exception` was because its the only tag that can be referenced from bitcode.  Using tags other than that currently requires assembly and I guess that asm support did not exist when this test was originally written?

https://github.com/llvm/llvm-project/pull/159141


More information about the llvm-commits mailing list