https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/167087

>From b54d80c70a08bd9c5fab3a41142c9803593a747b Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Fri, 7 Nov 2025 19:51:41 -0800
Subject: [PATCH] RuntimeLibcalls: Add small_printf functions to emscripten

---
 llvm/include/llvm/IR/RuntimeLibcalls.td                     | 4 ++++
 .../Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll    | 6 ++++++
 2 files changed, 10 insertions(+)
 create mode 100644 
llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll

diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td 
b/llvm/include/llvm/IR/RuntimeLibcalls.td
index dd06a3442cebb..ad11216c6ee9d 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -3457,6 +3457,7 @@ def SystemZZOSSystemLibrary
 def emscripten_return_address : RuntimeLibcallImpl<RETURN_ADDRESS>;
 
 def isWasm : RuntimeLibcallPredicate<"TT.isWasm()">;
+def isOSEmscripten : RuntimeLibcallPredicate<[{TT.isOSEmscripten()}]>;
 
 // Define the emscripten name for return address helper.
 // TODO: when implementing other Wasm backends, make this generic or only do
@@ -3468,6 +3469,9 @@ def WasmSystemLibrary
            exp10f, exp10,
            _Unwind_CallPersonality,
            emscripten_return_address,
+           LibcallImpls<(add __small_printf,
+                             __small_sprintf,
+                             __small_fprintf), isOSEmscripten>,
            __stack_chk_fail, __stack_chk_guard)>;
 
 
//===----------------------------------------------------------------------===//
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll 
b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll
new file mode 100644
index 0000000000000..f92f0fe2a189f
--- /dev/null
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll
@@ -0,0 +1,6 @@
+; REQUIRES: webassembly-registered-target
+; RUN: opt -S -passes=declare-runtime-libcalls 
-mtriple=wasm64-unknown-emscripten < %s | FileCheck %s
+
+; CHECK: declare void @__small_fprintf(...)
+; CHECK: declare void @__small_printf(...)
+; CHECK: declare void @__small_sprintf(...)

_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to