Skip to content

Conversation

@inbelic
Copy link
Contributor

@inbelic inbelic commented Oct 21, 2025

This is a temporary measure to explicitly remove the unrecognized named metadata when targeting DXIL.

This should be removed for an allowlist as tracked here: #164473.

@inbelic inbelic marked this pull request as ready for review October 21, 2025 18:27
@llvmbot
Copy link
Member

llvmbot commented Oct 21, 2025

@llvm/pr-subscribers-backend-directx

Author: Finn Plummer (inbelic)

Changes

This is a temporary measure to explicitly remove the unrecognized named metadata.

This should be removed for a whitelist once time to investigate is that list is allocated.


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

2 Files Affected:

  • (modified) llvm/lib/Target/DirectX/DXILPrepare.cpp (+8)
  • (added) llvm/test/CodeGen/DirectX/strip-llvm-errno-tbaa.ll (+19)
diff --git a/llvm/lib/Target/DirectX/DXILPrepare.cpp b/llvm/lib/Target/DirectX/DXILPrepare.cpp
index c8866bfefdfc5..42e90f0e27517 100644
--- a/llvm/lib/Target/DirectX/DXILPrepare.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrepare.cpp
@@ -294,6 +294,14 @@ class DXILPrepareModule : public ModulePass {
     if (NamedMDNode *RootSignature = M.getNamedMetadata("dx.rootsignatures"))
       RootSignature->eraseFromParent();
 
+    // llvm.errno.tbaa was recently added but is not supported in LLVM 3.7 and
+    // causes all tests using the DXIL Validator to fail.
+    //
+    // This is a temporary fix and should be replaced with a whitelist once
+    // we have determined all metadata that the DXIL Validator allows
+    if (NamedMDNode *ErrNo = M.getNamedMetadata("llvm.errno.tbaa"))
+      ErrNo->eraseFromParent();
+
     return true;
   }
 
diff --git a/llvm/test/CodeGen/DirectX/strip-llvm-errno-tbaa.ll b/llvm/test/CodeGen/DirectX/strip-llvm-errno-tbaa.ll
new file mode 100644
index 0000000000000..9190d0305d63f
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/strip-llvm-errno-tbaa.ll
@@ -0,0 +1,19 @@
+; RUN: opt -S -dxil-prepare < %s | FileCheck %s
+
+; Ensures that dxil-prepare will remove the llvm.errno.tbaa metadata
+
+target triple = "dxil-unknown-shadermodel6.0-compute"
+
+define void @main() {
+entry:
+  ret void
+}
+
+; CHECK-NOT: !llvm.errno.tbaa
+; CHECK-NOT: {{^!}}
+
+!llvm.errno.tbaa = !{!0}
+
+!0 = !{!1, !1, i64 0}
+!1 = !{!"omnipotent char", !2}
+!2 = !{!"Simple C/C++ TBAA"}

@inbelic inbelic changed the title [DirectX] add 'llvm.errno.tbaa' to metadata blacklist for DXIL target [DirectX] remove unrecognized 'llvm.errno.tbaa' named metadata for DXIL target Oct 21, 2025
Copy link
Contributor

@bogner bogner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable. Can you please file the "Use an allowlist for DXIL-compatible module metadata" issue as a follow up?

@inbelic inbelic merged commit bcf7267 into llvm:main Oct 21, 2025
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants