Skip to content

[DirectX] Disable libcalls that we don't support #138787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bogner opened this issue May 7, 2025 · 0 comments · Fixed by #138991
Closed

[DirectX] Disable libcalls that we don't support #138787

bogner opened this issue May 7, 2025 · 0 comments · Fixed by #138991
Assignees

Comments

@bogner
Copy link
Contributor

bogner commented May 7, 2025

We should disable libcalls such as memcpy and memset that we don't support in DXIL rather than try to chase down the long tail of legalizing them. Something like this does this will prevent LLVM optimizations from generating new libcalls:

diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index e2fd2aa13cce..ff9b8ff45258 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -205,6 +205,11 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
     return;
   }

+  if (T.isDXIL()) {
+    TLI.disableAllFunctions();
+    return;
+  }
+
   // memset_pattern{4,8,16} is only available on iOS 3.0 and Mac OS X 10.5 and
   // later. All versions of watchOS support it.
   if (T.isMacOSX()) {

This may be sufficient and just need testing, but when implementing we should take a look at the set of libcalls and make sure that disabling all of them is the right choice.

@Icohedron Icohedron moved this to Active in HLSL Support May 7, 2025
Icohedron added a commit that referenced this issue May 12, 2025
…8991)

Fixes #138787

To the best of my knowledge, DXIL does not (and should not) support any
of the libcalls in
[`TargetLibraryInfo.def`](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Analysis/TargetLibraryInfo.def).
Math libcalls are not used in HLSL and also do not have lowerings to
DXIL. (The current implementation of math functions are done via
intrinsics.)
If there is a mistake with disabling all libcalls, then the libcalls we
need can be re-enabled in a follow-up PR.

---------

Co-authored-by: Justin Bogner <[email protected]>
@github-project-automation github-project-automation bot moved this from Active to Closed in HLSL Support May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

2 participants