[lld] [llvm] WebAssembly: Move runtime libcall setting out of TargetLowering (PR #142624)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 12 22:35:58 PDT 2025
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/142624
>From 129c1db90e0e6d3037c6509976c227433310043a Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Mon, 2 Jun 2025 19:28:50 +0200
Subject: [PATCH 1/2] WebAssembly: Move runtime libcall setting out of
TargetLowering
RuntimeLibcallInfo needs to be correct outside of codegen contexts.
---
llvm/lib/IR/RuntimeLibcalls.cpp | 5 +++++
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | 5 -----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index d84c56f0af5c6..d655f84b37c50 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -531,6 +531,11 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
setLibcallName(RTLIB::MULO_I64, nullptr);
}
setLibcallName(RTLIB::MULO_I128, nullptr);
+ } else {
+ // Define the emscripten name for return address helper.
+ // TODO: when implementing other Wasm backends, make this generic or only do
+ // this on emscripten depending on what they end up doing.
+ setLibcallName(RTLIB::RETURN_ADDRESS, "emscripten_return_address");
}
if (TT.isSystemZ() && TT.isOSzOS()) {
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index aac3473311192..3cd923c0ba058 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -385,11 +385,6 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
setMaxAtomicSizeInBitsSupported(64);
- // Define the emscripten name for return address helper.
- // TODO: when implementing other Wasm backends, make this generic or only do
- // this on emscripten depending on what they end up doing.
- setLibcallName(RTLIB::RETURN_ADDRESS, "emscripten_return_address");
-
// Always convert switches to br_tables unless there is only one case, which
// is equivalent to a simple branch. This reduces code size for wasm, and we
// defer possible jump table optimizations to the VM.
>From 9fd32f4688a54f78c6d8535e0126911ca5b415b8 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 13 Jun 2025 14:28:20 +0900
Subject: [PATCH 2/2] Remove lld test
---
.../wasm/lto/Inputs/libcall-return-addr.ll | 6 ------
lld/test/wasm/lto/libcall-return-addr.ll | 18 ------------------
2 files changed, 24 deletions(-)
delete mode 100644 lld/test/wasm/lto/Inputs/libcall-return-addr.ll
delete mode 100644 lld/test/wasm/lto/libcall-return-addr.ll
diff --git a/lld/test/wasm/lto/Inputs/libcall-return-addr.ll b/lld/test/wasm/lto/Inputs/libcall-return-addr.ll
deleted file mode 100644
index 271bdae11e49d..0000000000000
--- a/lld/test/wasm/lto/Inputs/libcall-return-addr.ll
+++ /dev/null
@@ -1,6 +0,0 @@
-target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-S128-ni:1:10:20"
-target triple = "wasm32-unknown-emscripten"
-
-define ptr @emscripten_return_address() {
- ret ptr null
-}
diff --git a/lld/test/wasm/lto/libcall-return-addr.ll b/lld/test/wasm/lto/libcall-return-addr.ll
deleted file mode 100644
index 74eba74f97018..0000000000000
--- a/lld/test/wasm/lto/libcall-return-addr.ll
+++ /dev/null
@@ -1,18 +0,0 @@
-; RUN: llvm-as %s -o %t.o
-; RUN: llvm-as %p/Inputs/libcall-return-addr.ll -o %t.return-addr.o
-; RUN: rm -f %t.a
-; RUN: llvm-ar rcs %t.a %t.return-addr.o
-; RUN: not wasm-ld --export-all %t.o %t.a -o %t.wasm 2>&1 | FileCheck %s
-
-target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-S128-ni:1:10:20"
-target triple = "wasm32-unknown-emscripten"
-
- at g_ptr = global ptr null
-
-define void @_start() {
- %addr = call ptr @llvm.returnaddress(i32 1)
- store ptr %addr, ptr @g_ptr
- ret void
-}
-
-; CHECK: wasm-ld: error: {{.*}}return-addr.o): attempt to add bitcode file after LTO (emscripten_return_address)
More information about the llvm-commits
mailing list