Skip to content

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

Closed
@bogner

Description

@bogner

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.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions