[lld] [lld][WebAssembly] Convert more tests to assembly. NFC (PR #184418)
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 11:07:32 PST 2026
https://github.com/sbc100 created https://github.com/llvm/llvm-project/pull/184418
None
>From b98faff23542ccfab0fb3ab3e753ff225653be15 Mon Sep 17 00:00:00 2001
From: Sam Clegg <sbc at chromium.org>
Date: Tue, 3 Mar 2026 10:48:21 -0800
Subject: [PATCH] [lld][WebAssembly] Convert more tests to assembly. NFC
---
lld/test/wasm/Inputs/archive1.ll | 9 ------
lld/test/wasm/Inputs/archive1.s | 7 ++++
lld/test/wasm/Inputs/archive2.ll | 14 --------
lld/test/wasm/Inputs/archive2.s | 12 +++++++
lld/test/wasm/Inputs/archive3.ll | 11 -------
lld/test/wasm/Inputs/archive3.s | 10 ++++++
lld/test/wasm/archive-export.test | 4 +--
lld/test/wasm/archive.ll | 54 -------------------------------
lld/test/wasm/archive.s | 53 ++++++++++++++++++++++++++++++
9 files changed, 84 insertions(+), 90 deletions(-)
delete mode 100644 lld/test/wasm/Inputs/archive1.ll
create mode 100644 lld/test/wasm/Inputs/archive1.s
delete mode 100644 lld/test/wasm/Inputs/archive2.ll
create mode 100644 lld/test/wasm/Inputs/archive2.s
delete mode 100644 lld/test/wasm/Inputs/archive3.ll
create mode 100644 lld/test/wasm/Inputs/archive3.s
delete mode 100644 lld/test/wasm/archive.ll
create mode 100644 lld/test/wasm/archive.s
diff --git a/lld/test/wasm/Inputs/archive1.ll b/lld/test/wasm/Inputs/archive1.ll
deleted file mode 100644
index 7f614795aa0cc..0000000000000
--- a/lld/test/wasm/Inputs/archive1.ll
+++ /dev/null
@@ -1,9 +0,0 @@
-target triple = "wasm32-unknown-unknown"
-
-declare i32 @bar() local_unnamed_addr #1
-
-define i32 @foo() local_unnamed_addr #0 {
-entry:
- %call = tail call i32 @bar() #2
- ret i32 %call
-}
diff --git a/lld/test/wasm/Inputs/archive1.s b/lld/test/wasm/Inputs/archive1.s
new file mode 100644
index 0000000000000..da248a4b524ea
--- /dev/null
+++ b/lld/test/wasm/Inputs/archive1.s
@@ -0,0 +1,7 @@
+.functype bar () -> (i32)
+
+.globl foo
+foo:
+ .functype foo () -> (i32)
+ call bar
+ end_function
diff --git a/lld/test/wasm/Inputs/archive2.ll b/lld/test/wasm/Inputs/archive2.ll
deleted file mode 100644
index 66bfeac5ac6ce..0000000000000
--- a/lld/test/wasm/Inputs/archive2.ll
+++ /dev/null
@@ -1,14 +0,0 @@
-target triple = "wasm32-unknown-unknown"
-
-declare i32 @foo() local_unnamed_addr #1
-
-define i32 @bar() local_unnamed_addr #0 {
-entry:
- %call = tail call i32 @foo() #2
- ret i32 %call
-}
-
-define void @archive2_symbol() local_unnamed_addr #0 {
-entry:
- ret void
-}
diff --git a/lld/test/wasm/Inputs/archive2.s b/lld/test/wasm/Inputs/archive2.s
new file mode 100644
index 0000000000000..96b796a6413a4
--- /dev/null
+++ b/lld/test/wasm/Inputs/archive2.s
@@ -0,0 +1,12 @@
+.functype foo () -> (i32)
+
+.globl bar
+bar:
+ .functype bar () -> (i32)
+ call foo
+ end_function
+
+.globl archive2_symbol
+archive2_symbol:
+ .functype archive2_symbol () -> ()
+ end_function
diff --git a/lld/test/wasm/Inputs/archive3.ll b/lld/test/wasm/Inputs/archive3.ll
deleted file mode 100644
index 8c78a464f490b..0000000000000
--- a/lld/test/wasm/Inputs/archive3.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-target triple = "wasm32-unknown-unknown"
-
-define i32 @bar() local_unnamed_addr #0 {
-entry:
- ret i32 1
-}
-
-define void @archive3_symbol() local_unnamed_addr #0 {
-entry:
- ret void
-}
diff --git a/lld/test/wasm/Inputs/archive3.s b/lld/test/wasm/Inputs/archive3.s
new file mode 100644
index 0000000000000..abc88ab55ceb0
--- /dev/null
+++ b/lld/test/wasm/Inputs/archive3.s
@@ -0,0 +1,10 @@
+.globl bar
+bar:
+ .functype bar () -> (i32)
+ i32.const 1
+ end_function
+
+.globl archive3_symbol
+archive3_symbol:
+ .functype archive3_symbol () -> ()
+ end_function
diff --git a/lld/test/wasm/archive-export.test b/lld/test/wasm/archive-export.test
index c67e500e46dd2..46accf6b36e0b 100644
--- a/lld/test/wasm/archive-export.test
+++ b/lld/test/wasm/archive-export.test
@@ -1,8 +1,8 @@
Test that --export will also fetch lazy symbols from archives
RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o
-RUN: llc -filetype=obj %S/Inputs/archive1.ll -o %t.a1.o
-RUN: llc -filetype=obj %S/Inputs/archive2.ll -o %t.a2.o
+RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %S/Inputs/archive1.s -o %t.a1.o
+RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %S/Inputs/archive2.s -o %t.a2.o
RUN: rm -f %t.a
RUN: llvm-ar rcs %t.a %t.a1.o %t.a2.o
RUN: wasm-ld --export-dynamic --export=archive2_symbol -o %t.wasm %t.a %t.o
diff --git a/lld/test/wasm/archive.ll b/lld/test/wasm/archive.ll
deleted file mode 100644
index df72ec7813e22..0000000000000
--- a/lld/test/wasm/archive.ll
+++ /dev/null
@@ -1,54 +0,0 @@
-; RUN: llc -filetype=obj %s -o %t.o
-; RUN: llc -filetype=obj %S/Inputs/archive1.ll -o %t.a1.o
-; RUN: llc -filetype=obj %S/Inputs/archive2.ll -o %t.a2.o
-; RUN: llc -filetype=obj %S/Inputs/archive3.ll -o %t.a3.o
-; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hello.s -o %t.hello.o
-; RUN: rm -f %t.a
-; RUN: llvm-ar rcs %t.a %t.a1.o %t.a2.o %t.a3.o %t.hello.o
-; RUN: rm -f %t.imports
-; RUN: not wasm-ld %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-UNDEFINED %s
-
-; CHECK-UNDEFINED: undefined symbol: missing_func
-
-; RUN: echo 'missing_func' > %t.imports
-; RUN: wasm-ld -r %t.a %t.o -o %t.wasm
-
-; RUN: llvm-nm -a %t.wasm | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
-
-declare i32 @foo() local_unnamed_addr #1
-declare i32 @missing_func() local_unnamed_addr #1
-
-define void @_start() local_unnamed_addr #0 {
-entry:
- %call1 = call i32 @foo() #2
- %call2 = call i32 @missing_func() #2
- ret void
-}
-
-; Verify that mutually dependant object files in an archive is handled
-; correctly. Since we're using llvm-nm, we must link with --relocatable.
-;
-; TODO(ncw): Update LLD so that the symbol table is written out for
-; non-relocatable output (with an option to strip it)
-
-; CHECK: 00000016 T _start
-; CHECK-NEXT: 0000000a T archive2_symbol
-; CHECK-NEXT: 00000001 T bar
-; CHECK-NEXT: 0000000d T foo
-; CHECK-NEXT: U missing_func
-
-; Verify that symbols from unused objects don't appear in the symbol table
-; CHECK-NOT: hello
-
-; Specifying the same archive twice is allowed.
-; RUN: wasm-ld %t.a %t.a %t.o -o %t.wasm
-
-; Verfiy errors include library name
-; RUN: not wasm-ld -u archive2_symbol -u archive3_symbol %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-DUP %s
-; And that this also works with --whole-archive
-; RUN: not wasm-ld -u archive2_symbol -u archive3_symbol --whole-archive %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-DUP %s
-; CHECK-DUP: error: duplicate symbol: bar
-; CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a2.o)
-; CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a3.o)
diff --git a/lld/test/wasm/archive.s b/lld/test/wasm/archive.s
new file mode 100644
index 0000000000000..eec975ba5d7b3
--- /dev/null
+++ b/lld/test/wasm/archive.s
@@ -0,0 +1,53 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -filetype=obj %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -filetype=obj %S/Inputs/archive1.s -o %t.a1.o
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -filetype=obj %S/Inputs/archive2.s -o %t.a2.o
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -filetype=obj %S/Inputs/archive3.s -o %t.a3.o
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hello.s -o %t.hello.o
+# RUN: rm -f %t.a
+# RUN: llvm-ar rcs %t.a %t.a1.o %t.a2.o %t.a3.o %t.hello.o
+# RUN: rm -f %t.imports
+# RUN: not wasm-ld %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-UNDEFINED %s
+
+# CHECK-UNDEFINED: undefined symbol: missing_func
+
+# RUN: echo 'missing_func' > %t.imports
+# RUN: wasm-ld -r %t.a %t.o -o %t.wasm
+
+# RUN: llvm-nm -a %t.wasm | FileCheck %s
+
+.functype foo () -> (i32)
+.functype missing_func () -> ()
+
+.globl _start
+_start:
+ .functype _start () -> ()
+ call foo
+ drop
+ call missing_func
+ end_function
+
+# Verify that mutually dependant object files in an archive is handled
+# correctly. Since we're using llvm-nm, we must link with --relocatable.
+#
+# TODO(ncw): Update LLD so that the symbol table is written out for
+# non-relocatable output (with an option to strip it)
+
+# CHECK: 00000016 T _start
+# CHECK-NEXT: 0000000a T archive2_symbol
+# CHECK-NEXT: 00000001 T bar
+# CHECK-NEXT: 0000000d T foo
+# CHECK-NEXT: U missing_func
+
+# Verify that symbols from unused objects don't appear in the symbol table
+# CHECK-NOT: hello
+
+# Specifying the same archive twice is allowed.
+# RUN: wasm-ld %t.a %t.a %t.o -o %t.wasm
+
+# Verfiy errors include library name
+# RUN: not wasm-ld -u archive2_symbol -u archive3_symbol %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-DUP %s
+# And that this also works with --whole-archive
+# RUN: not wasm-ld -u archive2_symbol -u archive3_symbol --whole-archive %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-DUP %s
+# CHECK-DUP: error: duplicate symbol: bar
+# CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a2.o)
+# CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a3.o)
More information about the llvm-commits
mailing list