[llvm] WebAssembly: Move runtime libcall setting out of TargetLowering (PR #142624)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 3 07:59:05 PDT 2025


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/142624

RuntimeLibcallInfo needs to be correct outside of codegen contexts.

>From 91985a1b7a1a249e99779cd7e27e86d59a8366c6 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] 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 db0373055160c..ec4dc1858e4a5 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -277,5 +277,10 @@ 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");
   }
 }
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.



More information about the llvm-commits mailing list