[llvm] fb1e4b1 - [DirectX] Move getNonDXILAttributeMask to DirectXIRPasses (#202781)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 15:48:32 PDT 2026


Author: Harald van Dijk
Date: 2026-06-09T23:48:26+01:00
New Revision: fb1e4b1e59d4a7136cd4782a04da0aca189dfafd

URL: https://github.com/llvm/llvm-project/commit/fb1e4b1e59d4a7136cd4782a04da0aca189dfafd
DIFF: https://github.com/llvm/llvm-project/commit/fb1e4b1e59d4a7136cd4782a04da0aca189dfafd.diff

LOG: [DirectX] Move getNonDXILAttributeMask to DirectXIRPasses (#202781)

DXILDebugInfo.cpp uses it and is part of DirectXIRPasses, but
DXILPrepare.cpp defined it and is part of DirectXCodeGen. DirectXCodeGen
has a dependency on DirectXIRPasses, so we cannot also add a dependency
from DirectXIRPasses back on DirectXCodeGen, and we need to move the
definition of getNonDXILAttributeMask() instead.

Fixes: #201336

Added: 
    llvm/lib/Target/DirectX/DirectXIRPasses/DXILAttributes.cpp
    llvm/lib/Target/DirectX/DirectXIRPasses/DXILAttributes.h

Modified: 
    llvm/lib/Target/DirectX/DXILPrepare.cpp
    llvm/lib/Target/DirectX/DirectX.h
    llvm/lib/Target/DirectX/DirectXIRPasses/CMakeLists.txt
    llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/DirectX/DXILPrepare.cpp b/llvm/lib/Target/DirectX/DXILPrepare.cpp
index 7aafc926a5c5a..23bc42e549dee 100644
--- a/llvm/lib/Target/DirectX/DXILPrepare.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrepare.cpp
@@ -14,6 +14,7 @@
 #include "DXILRootSignature.h"
 #include "DXILShaderFlags.h"
 #include "DirectX.h"
+#include "DirectXIRPasses/DXILAttributes.h"
 #include "DirectXIRPasses/PointerTypeAnalysis.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSet.h"
@@ -33,70 +34,6 @@
 using namespace llvm;
 using namespace llvm::dxil;
 
-namespace llvm {
-namespace dxil {
-const AttributeMask &getNonDXILAttributeMask() {
-  static const AttributeMask Result = [] {
-    AttributeMask DXILAttributeMask;
-    for (Attribute::AttrKind Kind : {Attribute::Alignment,
-                                     Attribute::AlwaysInline,
-                                     Attribute::Builtin,
-                                     Attribute::ByVal,
-                                     Attribute::InAlloca,
-                                     Attribute::Cold,
-                                     Attribute::Convergent,
-                                     Attribute::InlineHint,
-                                     Attribute::InReg,
-                                     Attribute::JumpTable,
-                                     Attribute::MinSize,
-                                     Attribute::Naked,
-                                     Attribute::Nest,
-                                     Attribute::NoAlias,
-                                     Attribute::NoBuiltin,
-                                     Attribute::NoDuplicate,
-                                     Attribute::NoImplicitFloat,
-                                     Attribute::NoInline,
-                                     Attribute::NonLazyBind,
-                                     Attribute::NonNull,
-                                     Attribute::Dereferenceable,
-                                     Attribute::DereferenceableOrNull,
-                                     Attribute::Memory,
-                                     Attribute::NoRedZone,
-                                     Attribute::NoReturn,
-                                     Attribute::NoUnwind,
-                                     Attribute::OptimizeForSize,
-                                     Attribute::OptimizeNone,
-                                     Attribute::ReadNone,
-                                     Attribute::ReadOnly,
-                                     Attribute::Returned,
-                                     Attribute::ReturnsTwice,
-                                     Attribute::SExt,
-                                     Attribute::StackAlignment,
-                                     Attribute::StackProtect,
-                                     Attribute::StackProtectReq,
-                                     Attribute::StackProtectStrong,
-                                     Attribute::SafeStack,
-                                     Attribute::StructRet,
-                                     Attribute::SanitizeAddress,
-                                     Attribute::SanitizeThread,
-                                     Attribute::SanitizeMemory,
-                                     Attribute::UWTable,
-                                     Attribute::ZExt})
-      DXILAttributeMask.addAttribute(Kind);
-    AttributeMask Result;
-    for (Attribute::AttrKind Kind = Attribute::None;
-         Kind != Attribute::EndAttrKinds;
-         Kind = Attribute::AttrKind(Kind + 1)) {
-      if (!DXILAttributeMask.contains(Kind))
-        Result.addAttribute(Kind);
-    }
-    return Result;
-  }();
-  return Result;
-}
-} // namespace dxil
-} // namespace llvm
-
 namespace {
 
 static void collectDeadStringAttrs(AttributeMask &DeadAttrs, AttributeSet &&AS,

diff  --git a/llvm/lib/Target/DirectX/DirectX.h b/llvm/lib/Target/DirectX/DirectX.h
index 3aa91ca75dd4b..55a12e9f458b6 100644
--- a/llvm/lib/Target/DirectX/DirectX.h
+++ b/llvm/lib/Target/DirectX/DirectX.h
@@ -126,10 +126,6 @@ void initializeDXILFinalizeLinkageLegacyPass(PassRegistry &);
 
 /// Pass to finalize linkage of functions.
 ModulePass *createDXILFinalizeLinkageLegacyPass();
-
-namespace dxil {
-const AttributeMask &getNonDXILAttributeMask();
-} // namespace dxil
 } // namespace llvm
 
 #endif // LLVM_LIB_TARGET_DIRECTX_DIRECTX_H

diff  --git a/llvm/lib/Target/DirectX/DirectXIRPasses/CMakeLists.txt b/llvm/lib/Target/DirectX/DirectXIRPasses/CMakeLists.txt
index ab960583ae8e1..fb65a116a4f0b 100644
--- a/llvm/lib/Target/DirectX/DirectXIRPasses/CMakeLists.txt
+++ b/llvm/lib/Target/DirectX/DirectXIRPasses/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_llvm_component_library(LLVMDirectXIRPasses
+  DXILAttributes.cpp
   DXILDebugInfo.cpp
   PointerTypeAnalysis.cpp
 

diff  --git a/llvm/lib/Target/DirectX/DirectXIRPasses/DXILAttributes.cpp b/llvm/lib/Target/DirectX/DirectXIRPasses/DXILAttributes.cpp
new file mode 100644
index 0000000000000..75058b03655ec
--- /dev/null
+++ b/llvm/lib/Target/DirectX/DirectXIRPasses/DXILAttributes.cpp
@@ -0,0 +1,77 @@
+//===--- DXILAttributes.cpp - attribute helper function -------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DXILAttributes.h"
+#include "llvm/IR/AttributeMask.h"
+
+using namespace llvm;
+using namespace llvm::dxil;
+
+namespace llvm {
+namespace dxil {
+const AttributeMask &getNonDXILAttributeMask() {
+  static const AttributeMask Result = [] {
+    AttributeMask DXILAttributeMask;
+    for (Attribute::AttrKind Kind : {Attribute::Alignment,
+                                     Attribute::AlwaysInline,
+                                     Attribute::Builtin,
+                                     Attribute::ByVal,
+                                     Attribute::InAlloca,
+                                     Attribute::Cold,
+                                     Attribute::Convergent,
+                                     Attribute::InlineHint,
+                                     Attribute::InReg,
+                                     Attribute::JumpTable,
+                                     Attribute::MinSize,
+                                     Attribute::Naked,
+                                     Attribute::Nest,
+                                     Attribute::NoAlias,
+                                     Attribute::NoBuiltin,
+                                     Attribute::NoDuplicate,
+                                     Attribute::NoImplicitFloat,
+                                     Attribute::NoInline,
+                                     Attribute::NonLazyBind,
+                                     Attribute::NonNull,
+                                     Attribute::Dereferenceable,
+                                     Attribute::DereferenceableOrNull,
+                                     Attribute::Memory,
+                                     Attribute::NoRedZone,
+                                     Attribute::NoReturn,
+                                     Attribute::NoUnwind,
+                                     Attribute::OptimizeForSize,
+                                     Attribute::OptimizeNone,
+                                     Attribute::ReadNone,
+                                     Attribute::ReadOnly,
+                                     Attribute::Returned,
+                                     Attribute::ReturnsTwice,
+                                     Attribute::SExt,
+                                     Attribute::StackAlignment,
+                                     Attribute::StackProtect,
+                                     Attribute::StackProtectReq,
+                                     Attribute::StackProtectStrong,
+                                     Attribute::SafeStack,
+                                     Attribute::StructRet,
+                                     Attribute::SanitizeAddress,
+                                     Attribute::SanitizeThread,
+                                     Attribute::SanitizeMemory,
+                                     Attribute::UWTable,
+                                     Attribute::ZExt})
+      DXILAttributeMask.addAttribute(Kind);
+    AttributeMask Result;
+    for (Attribute::AttrKind Kind = Attribute::None;
+         Kind != Attribute::EndAttrKinds;
+         Kind = Attribute::AttrKind(Kind + 1)) {
+      if (!DXILAttributeMask.contains(Kind))
+        Result.addAttribute(Kind);
+    }
+    return Result;
+  }();
+  return Result;
+}
+} // namespace dxil
+} // namespace llvm

diff  --git a/llvm/lib/Target/DirectX/DirectXIRPasses/DXILAttributes.h b/llvm/lib/Target/DirectX/DirectXIRPasses/DXILAttributes.h
new file mode 100644
index 0000000000000..67bc5f2156562
--- /dev/null
+++ b/llvm/lib/Target/DirectX/DirectXIRPasses/DXILAttributes.h
@@ -0,0 +1,22 @@
+//===- DXILAttributes.h - DirectX attributes ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_DIRECTX_DXILATTRIBUTES_H
+#define LLVM_LIB_TARGET_DIRECTX_DXILATTRIBUTES_H
+
+namespace llvm {
+class AttributeMask;
+
+namespace dxil {
+const AttributeMask &getNonDXILAttributeMask();
+} // namespace dxil
+} // namespace llvm
+
+#endif // LLVM_LIB_TARGET_DIRECTX_DXILATTRIBUTES_H

diff  --git a/llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp b/llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp
index e8565129e8cd9..4564c1d16050b 100644
--- a/llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp
+++ b/llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "DXILDebugInfo.h"
-#include "DirectX.h"
+#include "DXILAttributes.h"
 #include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/IR/AttributeMask.h"
 #include "llvm/IR/DebugInfo.h"


        


More information about the llvm-commits mailing list