[llvm] SPIRV: Define runtime libcalls to be (almost) empty (PR #148631)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 06:29:01 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-spir-v

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

This is a behavior change; previously SPIRV inherited
a default set of calls which seems like a mistake. This
defines a library set with no calls. Add memcpy and memset
as a hack; this avoids PreISelIntrinsicLowering performing
the default expansion. SPIRVPrepareFunctions also calls
the utilities to expand these but the resulting output
is slightly different. The backend specific version
can probably be removed, it for some reason has a larger
output than the default one.

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


1 Files Affected:

- (modified) llvm/include/llvm/IR/RuntimeLibcalls.td (+11) 


``````````diff
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 4ad6689691f8e..12bcc34ad5b85 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1997,6 +1997,17 @@ def SPARCSystemLibrary
        LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128)
 >;
 
+//===----------------------------------------------------------------------===//
+// SPIRV Runtime Libcalls
+//===----------------------------------------------------------------------===//
+
+def isSPIRV : RuntimeLibcallPredicate<"TT.isSPIRV()">;
+
+// No calls FIXME: Add memcpy/memset is a hack to skip
+// PreISelIntrinsicLowering in favor of SPIRVPrepareFunctions;
+// probably should remove that and just use the default one.
+def SPIRVSystemLibrary : SystemRuntimeLibrary<isSPIRV, (add memset, memcpy)>;
+
 //===----------------------------------------------------------------------===//
 // Windows Runtime Libcalls
 //===----------------------------------------------------------------------===//

``````````

</details>


https://github.com/llvm/llvm-project/pull/148631


More information about the llvm-commits mailing list