Skip to content

Conversation

@arsenm
Copy link
Contributor

@arsenm arsenm commented Nov 8, 2025

No description provided.

@arsenm arsenm marked this pull request as ready for review November 8, 2025 04:10
Copy link
Contributor Author

arsenm commented Nov 8, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-llvm-selectiondag

Author: Matt Arsenault (arsenm)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/167087.diff

2 Files Affected:

  • (modified) llvm/include/llvm/IR/RuntimeLibcalls.td (+4)
  • (added) llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll (+6)
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(...)

@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2025

@llvm/pr-subscribers-llvm-ir

Author: Matt Arsenault (arsenm)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/167087.diff

2 Files Affected:

  • (modified) llvm/include/llvm/IR/RuntimeLibcalls.td (+4)
  • (added) llvm/test/Transforms/Util/DeclareRuntimeLibcalls/emscripten.ll (+6)
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(...)

@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-small-printf-emscripten branch 2 times, most recently from b54d80c to f0a641e Compare November 10, 2025 19:22
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-unlocked-io-funcs-macos branch from 6656c92 to b01305a Compare November 10, 2025 19:22
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-unlocked-io-funcs-macos branch from b01305a to 2a92356 Compare November 12, 2025 00:57
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-small-printf-emscripten branch from f0a641e to 0f391f4 Compare November 12, 2025 00:57
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-unlocked-io-funcs-macos branch from 2a92356 to dfee74d Compare November 12, 2025 02:11
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-small-printf-emscripten branch from 0f391f4 to 2eee7b2 Compare November 12, 2025 02:11
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-unlocked-io-funcs-macos branch from dfee74d to 87e1210 Compare November 12, 2025 03:24
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-small-printf-emscripten branch from 2eee7b2 to a67707c Compare November 12, 2025 03:24
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-small-printf-emscripten branch from a67707c to ce348c0 Compare November 25, 2025 13:43
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-unlocked-io-funcs-macos branch 2 times, most recently from 9dc2f82 to ef3799c Compare November 25, 2025 16:18
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-small-printf-emscripten branch from ce348c0 to f2bd446 Compare November 25, 2025 16:18
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-unlocked-io-funcs-macos branch from ef3799c to cc5c05b Compare November 26, 2025 15:43
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/add-small-printf-emscripten branch from f2bd446 to cb88ecd Compare November 26, 2025 15:43
Base automatically changed from users/arsenm/runtime-libcalls/add-unlocked-io-funcs-macos to main November 27, 2025 13:18
@arsenm arsenm merged commit d128d90 into main Nov 27, 2025
13 of 17 checks passed
@arsenm arsenm deleted the users/arsenm/runtime-libcalls/add-small-printf-emscripten branch November 27, 2025 13:42
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this pull request Dec 3, 2025
kcloudy0717 pushed a commit to kcloudy0717/llvm-project that referenced this pull request Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants