[llvm] SPIRV: Define runtime libcalls to be (almost) empty (PR #148631)
    Matt Arsenault via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Jul 14 06:29:38 PDT 2025
    
    
  
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/148631
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.
>From 5200a8ae248780edd257c14755b0cfe4c56d7d7c Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Mon, 14 Jul 2025 21:56:42 +0900
Subject: [PATCH] SPIRV: Define runtime libcalls to be (almost) empty
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.
---
 llvm/include/llvm/IR/RuntimeLibcalls.td | 11 +++++++++++
 1 file changed, 11 insertions(+)
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
 //===----------------------------------------------------------------------===//
    
    
More information about the llvm-commits
mailing list