Skip to content

[DXIL] Adding support to RootSignatureFlags in obj2yaml #122396

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

Merged
merged 29 commits into from
Feb 7, 2025

Conversation

joaosaffran
Copy link
Contributor

@joaosaffran joaosaffran commented Jan 10, 2025

This PR adds:

  • RootSignatureFlags extraction from DXContainer using obj2yaml

This PR is part of: #121493

@joaosaffran joaosaffran marked this pull request as ready for review January 10, 2025 23:11
@llvmbot llvmbot added backend:DirectX objectyaml llvm:analysis Includes value tracking, cost tables and constant folding llvm:binary-utilities labels Jan 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 10, 2025

@llvm/pr-subscribers-objectyaml

@llvm/pr-subscribers-backend-directx

Author: None (joaosaffran)

Changes

This PR adds:

  • Root signature 1.0 definition for RootSignatureFlags
  • Root Signature Generation to DX Container
  • Root Signature RootSignatureFlags extraction from LLVM
  • Root Signature generation to DXIL IR
  • RootSignatureFlags Validation
  • RootSignatureFlags extraction from DXContainer using obj2yaml

Patch is 25.19 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122396.diff

14 Files Affected:

  • (modified) llvm/include/llvm/Analysis/DXILMetadataAnalysis.h (+3)
  • (added) llvm/include/llvm/Analysis/DXILRootSignature.h (+88)
  • (modified) llvm/include/llvm/BinaryFormat/DXContainerConstants.def (+1)
  • (modified) llvm/include/llvm/Object/DXContainer.h (+8)
  • (modified) llvm/include/llvm/ObjectYAML/DXContainerYAML.h (+14)
  • (modified) llvm/lib/Analysis/CMakeLists.txt (+1)
  • (modified) llvm/lib/Analysis/DXILMetadataAnalysis.cpp (+17)
  • (added) llvm/lib/Analysis/DXILRootSignature.cpp (+110)
  • (modified) llvm/lib/Object/DXContainer.cpp (+15)
  • (modified) llvm/lib/ObjectYAML/DXContainerEmitter.cpp (+7)
  • (modified) llvm/lib/ObjectYAML/DXContainerYAML.cpp (+68)
  • (modified) llvm/lib/Target/DirectX/DXContainerGlobals.cpp (+23)
  • (added) llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll (+27)
  • (modified) llvm/tools/obj2yaml/dxcontainer2yaml.cpp (+22)
diff --git a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
index cb535ac14f1c61..89c5bffcdbb954 100644
--- a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
+++ b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
@@ -10,10 +10,12 @@
 #define LLVM_ANALYSIS_DXILMETADATA_H
 
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/Triple.h"
+#include <optional>
 
 namespace llvm {
 
@@ -37,6 +39,7 @@ struct ModuleMetadataInfo {
   Triple::EnvironmentType ShaderProfile{Triple::UnknownEnvironment};
   VersionTuple ValidatorVersion{};
   SmallVector<EntryProperties> EntryPropertyVec{};
+  std::optional<root_signature::VersionedRootSignatureDesc> RootSignatureDesc;
   void print(raw_ostream &OS) const;
 };
 
diff --git a/llvm/include/llvm/Analysis/DXILRootSignature.h b/llvm/include/llvm/Analysis/DXILRootSignature.h
new file mode 100644
index 00000000000000..cb3d6192f4404d
--- /dev/null
+++ b/llvm/include/llvm/Analysis/DXILRootSignature.h
@@ -0,0 +1,88 @@
+//===- DXILRootSignature.h - DXIL Root Signature helper objects -----------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file contains helper objects for working with DXIL Root
+/// Signatures.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DIRECTX_HLSLROOTSIGNATURE_H
+#define LLVM_DIRECTX_HLSLROOTSIGNATURE_H
+
+#include "llvm/IR/Metadata.h"
+#include "llvm/Support/ScopedPrinter.h"
+namespace llvm {
+namespace dxil {
+namespace root_signature {
+
+enum class RootSignatureElementKind {
+  None = 0,
+  RootFlags = 1,
+  RootConstants = 2,
+  RootDescriptor = 3,
+  DescriptorTable = 4,
+  StaticSampler = 5
+};
+
+enum class RootSignatureVersion {
+  Version_1 = 1,
+  Version_1_0 = 1,
+  Version_1_1 = 2,
+  Version_1_2 = 3
+};
+
+enum RootSignatureFlags : uint32_t {
+  None = 0,
+  AllowInputAssemblerInputLayout = 0x1,
+  DenyVertexShaderRootAccess = 0x2,
+  DenyHullShaderRootAccess = 0x4,
+  DenyDomainShaderRootAccess = 0x8,
+  DenyGeometryShaderRootAccess = 0x10,
+  DenyPixelShaderRootAccess = 0x20,
+  AllowStreamOutput = 0x40,
+  LocalRootSignature = 0x80,
+  DenyAmplificationShaderRootAccess = 0x100,
+  DenyMeshShaderRootAccess = 0x200,
+  CBVSRVUAVHeapDirectlyIndexed = 0x400,
+  SamplerHeapDirectlyIndexed = 0x800,
+  AllowLowTierReservedHwCbLimit = 0x80000000,
+  ValidFlags = 0x80000fff
+};
+
+struct DxilRootSignatureDesc1_0 {
+  RootSignatureFlags Flags;
+};
+
+struct VersionedRootSignatureDesc {
+  RootSignatureVersion Version;
+  union {
+    DxilRootSignatureDesc1_0 Desc_1_0;
+  };
+
+  bool isPopulated();
+
+  void swapBytes();
+};
+
+class MetadataParser {
+public:
+  NamedMDNode *Root;
+  MetadataParser(NamedMDNode *Root) : Root(Root) {}
+
+  bool Parse(RootSignatureVersion Version, VersionedRootSignatureDesc *Desc);
+
+private:
+  bool ParseRootFlags(MDNode *RootFlagRoot, VersionedRootSignatureDesc *Desc);
+  bool ParseRootSignatureElement(MDNode *Element,
+                                 VersionedRootSignatureDesc *Desc);
+};
+} // namespace root_signature
+} // namespace dxil
+} // namespace llvm
+
+#endif // LLVM_DIRECTX_HLSLROOTSIGNATURE_H
diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
index 1aacbb2f65b27f..38b69228cd3975 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
+++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
@@ -4,6 +4,7 @@ CONTAINER_PART(DXIL)
 CONTAINER_PART(SFI0)
 CONTAINER_PART(HASH)
 CONTAINER_PART(PSV0)
+CONTAINER_PART(RTS0)
 CONTAINER_PART(ISG1)
 CONTAINER_PART(OSG1)
 CONTAINER_PART(PSG1)
diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h
index 19c83ba6c6e85d..9a6aa8224eddf4 100644
--- a/llvm/include/llvm/Object/DXContainer.h
+++ b/llvm/include/llvm/Object/DXContainer.h
@@ -17,6 +17,7 @@
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBufferRef.h"
@@ -287,6 +288,7 @@ class DXContainer {
   std::optional<uint64_t> ShaderFeatureFlags;
   std::optional<dxbc::ShaderHash> Hash;
   std::optional<DirectX::PSVRuntimeInfo> PSVInfo;
+  std::optional<dxil::root_signature::VersionedRootSignatureDesc> RootSignature;
   DirectX::Signature InputSignature;
   DirectX::Signature OutputSignature;
   DirectX::Signature PatchConstantSignature;
@@ -296,6 +298,7 @@ class DXContainer {
   Error parseDXILHeader(StringRef Part);
   Error parseShaderFeatureFlags(StringRef Part);
   Error parseHash(StringRef Part);
+  Error parseRootSignature(StringRef Part);
   Error parsePSVInfo(StringRef Part);
   Error parseSignature(StringRef Part, DirectX::Signature &Array);
   friend class PartIterator;
@@ -382,6 +385,11 @@ class DXContainer {
 
   std::optional<dxbc::ShaderHash> getShaderHash() const { return Hash; }
 
+  std::optional<dxil::root_signature::VersionedRootSignatureDesc>
+  getRootSignature() const {
+    return RootSignature;
+  }
+
   const std::optional<DirectX::PSVRuntimeInfo> &getPSVInfo() const {
     return PSVInfo;
   };
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index 66ad057ab0e30f..e9da51f61c0a2b 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -16,6 +16,7 @@
 #define LLVM_OBJECTYAML_DXCONTAINERYAML_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/ObjectYAML/YAML.h"
 #include "llvm/Support/YAMLTraits.h"
@@ -149,6 +150,13 @@ struct Signature {
   llvm::SmallVector<SignatureParameter> Parameters;
 };
 
+struct RootSignature {
+  RootSignature() = default;
+
+  dxil::root_signature::RootSignatureVersion Version;
+  dxil::root_signature::RootSignatureFlags Flags;
+};
+
 struct Part {
   Part() = default;
   Part(std::string N, uint32_t S) : Name(N), Size(S) {}
@@ -159,6 +167,7 @@ struct Part {
   std::optional<ShaderHash> Hash;
   std::optional<PSVInfo> Info;
   std::optional<DXContainerYAML::Signature> Signature;
+  std::optional<DXContainerYAML::RootSignature> RootSignature;
 };
 
 struct Object {
@@ -241,6 +250,11 @@ template <> struct MappingTraits<DXContainerYAML::Signature> {
   static void mapping(IO &IO, llvm::DXContainerYAML::Signature &El);
 };
 
+template <> struct MappingTraits<DXContainerYAML::RootSignature> {
+  static void mapping(IO &IO,
+                      llvm::DXContainerYAML::RootSignature &RootSignature);
+};
+
 } // namespace yaml
 
 } // namespace llvm
diff --git a/llvm/lib/Analysis/CMakeLists.txt b/llvm/lib/Analysis/CMakeLists.txt
index 0db5b80f336cb5..8875ddd34fe56c 100644
--- a/llvm/lib/Analysis/CMakeLists.txt
+++ b/llvm/lib/Analysis/CMakeLists.txt
@@ -62,6 +62,7 @@ add_llvm_component_library(LLVMAnalysis
   DominanceFrontier.cpp
   DXILResource.cpp
   DXILMetadataAnalysis.cpp
+  DXILRootSignature.cpp
   FunctionPropertiesAnalysis.cpp
   GlobalsModRef.cpp
   GuardUtils.cpp
diff --git a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
index a7f666a3f8b48f..3bd60bfe203f49 100644
--- a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
+++ b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
@@ -10,12 +10,15 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/InitializePasses.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include <memory>
 
 #define DEBUG_TYPE "dxil-metadata-analysis"
 
@@ -28,6 +31,7 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) {
   MMDAI.DXILVersion = TT.getDXILVersion();
   MMDAI.ShaderModelVersion = TT.getOSVersion();
   MMDAI.ShaderProfile = TT.getEnvironment();
+
   NamedMDNode *ValidatorVerNode = M.getNamedMetadata("dx.valver");
   if (ValidatorVerNode) {
     auto *ValVerMD = cast<MDNode>(ValidatorVerNode->getOperand(0));
@@ -37,6 +41,19 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) {
         VersionTuple(MajorMD->getZExtValue(), MinorMD->getZExtValue());
   }
 
+  NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
+  if (RootSignatureNode) {
+    auto RootSignatureParser =
+        root_signature::MetadataParser(RootSignatureNode);
+
+    root_signature::VersionedRootSignatureDesc Desc;
+
+    RootSignatureParser.Parse(root_signature::RootSignatureVersion::Version_1,
+                              &Desc);
+
+    MMDAI.RootSignatureDesc = Desc;
+  }
+
   // For all HLSL Shader functions
   for (auto &F : M.functions()) {
     if (!F.hasFnAttribute("hlsl.shader"))
diff --git a/llvm/lib/Analysis/DXILRootSignature.cpp b/llvm/lib/Analysis/DXILRootSignature.cpp
new file mode 100644
index 00000000000000..fce97eb27cf8f8
--- /dev/null
+++ b/llvm/lib/Analysis/DXILRootSignature.cpp
@@ -0,0 +1,110 @@
+//===- DXILRootSignature.cpp - DXIL Root Signature helper objects
+//-----------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file contains the parsing logic to extract root signature data
+///       from LLVM IR metadata.
+///
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/DXILRootSignature.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Metadata.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+
+namespace llvm {
+namespace dxil {
+
+bool root_signature::MetadataParser::Parse(RootSignatureVersion Version,
+                                           VersionedRootSignatureDesc *Desc) {
+  Desc->Version = Version;
+  bool HasError = false;
+
+  for (unsigned int Sid = 0; Sid < Root->getNumOperands(); Sid++) {
+    // This should be an if, for error handling
+    MDNode *Node = cast<MDNode>(Root->getOperand(Sid));
+
+    // Not sure what use this for...
+    Metadata *Func = Node->getOperand(0).get();
+
+    // This should be an if, for error handling
+    MDNode *Elements = cast<MDNode>(Node->getOperand(1).get());
+
+    for (unsigned int Eid = 0; Eid < Elements->getNumOperands(); Eid++) {
+      MDNode *Element = cast<MDNode>(Elements->getOperand(Eid));
+
+      HasError = HasError || ParseRootSignatureElement(Element, Desc);
+    }
+  }
+  return HasError;
+}
+
+bool root_signature::MetadataParser::ParseRootFlags(
+    MDNode *RootFlagNode, VersionedRootSignatureDesc *Desc) {
+
+  assert(RootFlagNode->getNumOperands() == 2 &&
+         "Invalid format for RootFlag Element");
+  auto *Flag = mdconst::extract<ConstantInt>(RootFlagNode->getOperand(1));
+  auto Value = (RootSignatureFlags)Flag->getZExtValue();
+
+  if ((Value & ~RootSignatureFlags::ValidFlags) != RootSignatureFlags::None)
+    return true;
+
+  switch (Desc->Version) {
+
+  case RootSignatureVersion::Version_1:
+    Desc->Desc_1_0.Flags = (RootSignatureFlags)Value;
+    break;
+  case RootSignatureVersion::Version_1_1:
+  case RootSignatureVersion::Version_1_2:
+    llvm_unreachable("Not implemented yet");
+    break;
+  }
+  return false;
+}
+
+bool root_signature::MetadataParser::ParseRootSignatureElement(
+    MDNode *Element, VersionedRootSignatureDesc *Desc) {
+  MDString *ElementText = cast<MDString>(Element->getOperand(0));
+
+  assert(ElementText != nullptr && "First preoperty of element is not ");
+
+  RootSignatureElementKind ElementKind =
+      StringSwitch<RootSignatureElementKind>(ElementText->getString())
+          .Case("RootFlags", RootSignatureElementKind::RootFlags)
+          .Case("RootConstants", RootSignatureElementKind::RootConstants)
+          .Case("RootCBV", RootSignatureElementKind::RootDescriptor)
+          .Case("RootSRV", RootSignatureElementKind::RootDescriptor)
+          .Case("RootUAV", RootSignatureElementKind::RootDescriptor)
+          .Case("Sampler", RootSignatureElementKind::RootDescriptor)
+          .Case("DescriptorTable", RootSignatureElementKind::DescriptorTable)
+          .Case("StaticSampler", RootSignatureElementKind::StaticSampler)
+          .Default(RootSignatureElementKind::None);
+
+  switch (ElementKind) {
+
+  case RootSignatureElementKind::RootFlags: {
+    return ParseRootFlags(Element, Desc);
+    break;
+  }
+
+  case RootSignatureElementKind::RootConstants:
+  case RootSignatureElementKind::RootDescriptor:
+  case RootSignatureElementKind::DescriptorTable:
+  case RootSignatureElementKind::StaticSampler:
+  case RootSignatureElementKind::None:
+    llvm_unreachable("Not Implemented yet");
+    break;
+  }
+
+  return true;
+}
+} // namespace dxil
+} // namespace llvm
diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp
index 3b1a6203a1f8fc..f50f68df88ec2a 100644
--- a/llvm/lib/Object/DXContainer.cpp
+++ b/llvm/lib/Object/DXContainer.cpp
@@ -7,9 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Object/DXContainer.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/Object/Error.h"
 #include "llvm/Support/Alignment.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 
 using namespace llvm;
@@ -92,6 +94,14 @@ Error DXContainer::parseHash(StringRef Part) {
   return Error::success();
 }
 
+Error DXContainer::parseRootSignature(StringRef Part) {
+  dxil::root_signature::VersionedRootSignatureDesc Desc;
+  if (Error Err = readStruct(Part, Part.begin(), Desc))
+    return Err;
+  RootSignature = Desc;
+  return Error::success();
+}
+
 Error DXContainer::parsePSVInfo(StringRef Part) {
   if (PSVInfo)
     return parseFailed("More than one PSV0 part is present in the file");
@@ -192,6 +202,11 @@ Error DXContainer::parsePartOffsets() {
         return Err;
       break;
     case dxbc::PartType::Unknown:
+      break;
+    case dxbc::PartType::RTS0:
+      if (Error Err = parseRootSignature(PartData))
+        return Err;
+
       break;
     }
   }
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index 175f1a12f93145..905d409562ff45 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -11,6 +11,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/MC/DXContainerPSVInfo.h"
 #include "llvm/ObjectYAML/ObjectYAML.h"
@@ -261,6 +262,12 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
     }
     case dxbc::PartType::Unknown:
       break; // Skip any handling for unrecognized parts.
+    case dxbc::PartType::RTS0:
+      if (!P.RootSignature.has_value())
+        continue;
+      OS.write(reinterpret_cast<const char *>(&P.RootSignature),
+               sizeof(dxil::root_signature::VersionedRootSignatureDesc));
+      break;
     }
     uint64_t BytesWritten = OS.tell() - DataStart;
     RollingOffset += BytesWritten;
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 5dee1221b27c01..eab3fcc5936f85 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -13,6 +13,7 @@
 
 #include "llvm/ObjectYAML/DXContainerYAML.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -188,6 +189,12 @@ void MappingTraits<DXContainerYAML::Signature>::mapping(
   IO.mapRequired("Parameters", S.Parameters);
 }
 
+void MappingTraits<DXContainerYAML::RootSignature>::mapping(
+    IO &IO, DXContainerYAML::RootSignature &S) {
+  IO.mapRequired("Version", S.Version);
+  IO.mapRequired("Flags", S.Flags);
+}
+
 void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
                                                    DXContainerYAML::Part &P) {
   IO.mapRequired("Name", P.Name);
@@ -197,6 +204,7 @@ void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
   IO.mapOptional("Hash", P.Hash);
   IO.mapOptional("PSVInfo", P.Info);
   IO.mapOptional("Signature", P.Signature);
+  IO.mapOptional("RootSignature", P.RootSignature);
 }
 
 void MappingTraits<DXContainerYAML::Object>::mapping(
@@ -290,6 +298,66 @@ void ScalarEnumerationTraits<dxbc::SigComponentType>::enumeration(
     IO.enumCase(Value, E.Name.str().c_str(), E.Value);
 }
 
+template <>
+struct llvm::yaml::ScalarEnumerationTraits<
+    dxil::root_signature::RootSignatureVersion> {
+  static void enumeration(IO &io,
+                          dxil::root_signature::RootSignatureVersion &Val) {
+    io.enumCase(Val, "1.0",
+                dxil::root_signature::RootSignatureVersion::Version_1);
+    io.enumCase(Val, "1.0",
+                dxil::root_signature::RootSignatureVersion::Version_1_0);
+    io.enumCase(Val, "1.1",
+                dxil::root_signature::RootSignatureVersion::Version_1_1);
+    io.enumCase(Val, "1.2",
+                dxil::root_signature::RootSignatureVersion::Version_1_2);
+  }
+};
+
+template <>
+struct llvm::yaml::ScalarEnumerationTraits<
+    dxil::root_signature::RootSignatureFlags> {
+  static void enumeration(IO &io,
+                          dxil::root_signature::RootSignatureFlags &Val) {
+    io.enumCase(Val, "AllowInputAssemblerInputLayout",
+                dxil::root_signature::RootSignatureFlags::
+                    AllowInputAssemblerInputLayout);
+    io.enumCase(
+        Val, "DenyVertexShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyVertexShaderRootAccess);
+    io.enumCase(
+        Val, "DenyHullShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyHullShaderRootAccess);
+    io.enumCase(
+        Val, "DenyDomainShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyDomainShaderRootAccess);
+    io.enumCase(
+        Val, "DenyGeometryShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyGeometryShaderRootAccess);
+    io.enumCase(
+        Val, "DenyPixelShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyPixelShaderRootAccess);
+    io.enumCase(Val, "AllowStreamOutput",
+                dxil::root_signature::RootSignatureFlags::AllowStreamOutput);
+    io.enumCase(Val, "LocalRootSignature",
+                dxil::root_signature::RootSignatureFlags::LocalRootSignature);
+    io.enumCase(Val, "DenyAmplificationShaderRootAccess",
+                dxil::root_signature::RootSignatureFlags::
+                    DenyAmplificationShaderRootAccess);
+    io.enumCase(
+        Val, "DenyMeshShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyMeshShaderRootAccess);
+    io.enumCase(
+        Val, "CBVSRVUAVHeapDirectlyIndexed",
+        dxil::root_signature::RootSignatureFlags::CBVSRVUAVHeapDirectlyIndexed);
+    io.enumCase(
+        Val, "SamplerHeapDirectlyIndexed",
+        dxil::root_signature::RootSignatureFlags::SamplerHeapDirectlyIndexed);
+    io.enumCase(Val, "AllowLowTierReservedHwCbLimit",
+                dxil::root_signature::RootSignatureFlags::
+                    AllowLowTierReservedHwCbLimit);
+  }
+};
 } // namespace yaml
 
 void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) {
diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
index 7a0bd6a7c88692..e3174d600e6534 100644
--- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
+++ b/llvm/lib/Target/Direct...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Jan 10, 2025

@llvm/pr-subscribers-llvm-analysis

Author: None (joaosaffran)

Changes

This PR adds:

  • Root signature 1.0 definition for RootSignatureFlags
  • Root Signature Generation to DX Container
  • Root Signature RootSignatureFlags extraction from LLVM
  • Root Signature generation to DXIL IR
  • RootSignatureFlags Validation
  • RootSignatureFlags extraction from DXContainer using obj2yaml

Patch is 25.19 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122396.diff

14 Files Affected:

  • (modified) llvm/include/llvm/Analysis/DXILMetadataAnalysis.h (+3)
  • (added) llvm/include/llvm/Analysis/DXILRootSignature.h (+88)
  • (modified) llvm/include/llvm/BinaryFormat/DXContainerConstants.def (+1)
  • (modified) llvm/include/llvm/Object/DXContainer.h (+8)
  • (modified) llvm/include/llvm/ObjectYAML/DXContainerYAML.h (+14)
  • (modified) llvm/lib/Analysis/CMakeLists.txt (+1)
  • (modified) llvm/lib/Analysis/DXILMetadataAnalysis.cpp (+17)
  • (added) llvm/lib/Analysis/DXILRootSignature.cpp (+110)
  • (modified) llvm/lib/Object/DXContainer.cpp (+15)
  • (modified) llvm/lib/ObjectYAML/DXContainerEmitter.cpp (+7)
  • (modified) llvm/lib/ObjectYAML/DXContainerYAML.cpp (+68)
  • (modified) llvm/lib/Target/DirectX/DXContainerGlobals.cpp (+23)
  • (added) llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll (+27)
  • (modified) llvm/tools/obj2yaml/dxcontainer2yaml.cpp (+22)
diff --git a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
index cb535ac14f1c61..89c5bffcdbb954 100644
--- a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
+++ b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
@@ -10,10 +10,12 @@
 #define LLVM_ANALYSIS_DXILMETADATA_H
 
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/Triple.h"
+#include <optional>
 
 namespace llvm {
 
@@ -37,6 +39,7 @@ struct ModuleMetadataInfo {
   Triple::EnvironmentType ShaderProfile{Triple::UnknownEnvironment};
   VersionTuple ValidatorVersion{};
   SmallVector<EntryProperties> EntryPropertyVec{};
+  std::optional<root_signature::VersionedRootSignatureDesc> RootSignatureDesc;
   void print(raw_ostream &OS) const;
 };
 
diff --git a/llvm/include/llvm/Analysis/DXILRootSignature.h b/llvm/include/llvm/Analysis/DXILRootSignature.h
new file mode 100644
index 00000000000000..cb3d6192f4404d
--- /dev/null
+++ b/llvm/include/llvm/Analysis/DXILRootSignature.h
@@ -0,0 +1,88 @@
+//===- DXILRootSignature.h - DXIL Root Signature helper objects -----------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file contains helper objects for working with DXIL Root
+/// Signatures.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DIRECTX_HLSLROOTSIGNATURE_H
+#define LLVM_DIRECTX_HLSLROOTSIGNATURE_H
+
+#include "llvm/IR/Metadata.h"
+#include "llvm/Support/ScopedPrinter.h"
+namespace llvm {
+namespace dxil {
+namespace root_signature {
+
+enum class RootSignatureElementKind {
+  None = 0,
+  RootFlags = 1,
+  RootConstants = 2,
+  RootDescriptor = 3,
+  DescriptorTable = 4,
+  StaticSampler = 5
+};
+
+enum class RootSignatureVersion {
+  Version_1 = 1,
+  Version_1_0 = 1,
+  Version_1_1 = 2,
+  Version_1_2 = 3
+};
+
+enum RootSignatureFlags : uint32_t {
+  None = 0,
+  AllowInputAssemblerInputLayout = 0x1,
+  DenyVertexShaderRootAccess = 0x2,
+  DenyHullShaderRootAccess = 0x4,
+  DenyDomainShaderRootAccess = 0x8,
+  DenyGeometryShaderRootAccess = 0x10,
+  DenyPixelShaderRootAccess = 0x20,
+  AllowStreamOutput = 0x40,
+  LocalRootSignature = 0x80,
+  DenyAmplificationShaderRootAccess = 0x100,
+  DenyMeshShaderRootAccess = 0x200,
+  CBVSRVUAVHeapDirectlyIndexed = 0x400,
+  SamplerHeapDirectlyIndexed = 0x800,
+  AllowLowTierReservedHwCbLimit = 0x80000000,
+  ValidFlags = 0x80000fff
+};
+
+struct DxilRootSignatureDesc1_0 {
+  RootSignatureFlags Flags;
+};
+
+struct VersionedRootSignatureDesc {
+  RootSignatureVersion Version;
+  union {
+    DxilRootSignatureDesc1_0 Desc_1_0;
+  };
+
+  bool isPopulated();
+
+  void swapBytes();
+};
+
+class MetadataParser {
+public:
+  NamedMDNode *Root;
+  MetadataParser(NamedMDNode *Root) : Root(Root) {}
+
+  bool Parse(RootSignatureVersion Version, VersionedRootSignatureDesc *Desc);
+
+private:
+  bool ParseRootFlags(MDNode *RootFlagRoot, VersionedRootSignatureDesc *Desc);
+  bool ParseRootSignatureElement(MDNode *Element,
+                                 VersionedRootSignatureDesc *Desc);
+};
+} // namespace root_signature
+} // namespace dxil
+} // namespace llvm
+
+#endif // LLVM_DIRECTX_HLSLROOTSIGNATURE_H
diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
index 1aacbb2f65b27f..38b69228cd3975 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
+++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
@@ -4,6 +4,7 @@ CONTAINER_PART(DXIL)
 CONTAINER_PART(SFI0)
 CONTAINER_PART(HASH)
 CONTAINER_PART(PSV0)
+CONTAINER_PART(RTS0)
 CONTAINER_PART(ISG1)
 CONTAINER_PART(OSG1)
 CONTAINER_PART(PSG1)
diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h
index 19c83ba6c6e85d..9a6aa8224eddf4 100644
--- a/llvm/include/llvm/Object/DXContainer.h
+++ b/llvm/include/llvm/Object/DXContainer.h
@@ -17,6 +17,7 @@
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBufferRef.h"
@@ -287,6 +288,7 @@ class DXContainer {
   std::optional<uint64_t> ShaderFeatureFlags;
   std::optional<dxbc::ShaderHash> Hash;
   std::optional<DirectX::PSVRuntimeInfo> PSVInfo;
+  std::optional<dxil::root_signature::VersionedRootSignatureDesc> RootSignature;
   DirectX::Signature InputSignature;
   DirectX::Signature OutputSignature;
   DirectX::Signature PatchConstantSignature;
@@ -296,6 +298,7 @@ class DXContainer {
   Error parseDXILHeader(StringRef Part);
   Error parseShaderFeatureFlags(StringRef Part);
   Error parseHash(StringRef Part);
+  Error parseRootSignature(StringRef Part);
   Error parsePSVInfo(StringRef Part);
   Error parseSignature(StringRef Part, DirectX::Signature &Array);
   friend class PartIterator;
@@ -382,6 +385,11 @@ class DXContainer {
 
   std::optional<dxbc::ShaderHash> getShaderHash() const { return Hash; }
 
+  std::optional<dxil::root_signature::VersionedRootSignatureDesc>
+  getRootSignature() const {
+    return RootSignature;
+  }
+
   const std::optional<DirectX::PSVRuntimeInfo> &getPSVInfo() const {
     return PSVInfo;
   };
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index 66ad057ab0e30f..e9da51f61c0a2b 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -16,6 +16,7 @@
 #define LLVM_OBJECTYAML_DXCONTAINERYAML_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/ObjectYAML/YAML.h"
 #include "llvm/Support/YAMLTraits.h"
@@ -149,6 +150,13 @@ struct Signature {
   llvm::SmallVector<SignatureParameter> Parameters;
 };
 
+struct RootSignature {
+  RootSignature() = default;
+
+  dxil::root_signature::RootSignatureVersion Version;
+  dxil::root_signature::RootSignatureFlags Flags;
+};
+
 struct Part {
   Part() = default;
   Part(std::string N, uint32_t S) : Name(N), Size(S) {}
@@ -159,6 +167,7 @@ struct Part {
   std::optional<ShaderHash> Hash;
   std::optional<PSVInfo> Info;
   std::optional<DXContainerYAML::Signature> Signature;
+  std::optional<DXContainerYAML::RootSignature> RootSignature;
 };
 
 struct Object {
@@ -241,6 +250,11 @@ template <> struct MappingTraits<DXContainerYAML::Signature> {
   static void mapping(IO &IO, llvm::DXContainerYAML::Signature &El);
 };
 
+template <> struct MappingTraits<DXContainerYAML::RootSignature> {
+  static void mapping(IO &IO,
+                      llvm::DXContainerYAML::RootSignature &RootSignature);
+};
+
 } // namespace yaml
 
 } // namespace llvm
diff --git a/llvm/lib/Analysis/CMakeLists.txt b/llvm/lib/Analysis/CMakeLists.txt
index 0db5b80f336cb5..8875ddd34fe56c 100644
--- a/llvm/lib/Analysis/CMakeLists.txt
+++ b/llvm/lib/Analysis/CMakeLists.txt
@@ -62,6 +62,7 @@ add_llvm_component_library(LLVMAnalysis
   DominanceFrontier.cpp
   DXILResource.cpp
   DXILMetadataAnalysis.cpp
+  DXILRootSignature.cpp
   FunctionPropertiesAnalysis.cpp
   GlobalsModRef.cpp
   GuardUtils.cpp
diff --git a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
index a7f666a3f8b48f..3bd60bfe203f49 100644
--- a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
+++ b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
@@ -10,12 +10,15 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/InitializePasses.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include <memory>
 
 #define DEBUG_TYPE "dxil-metadata-analysis"
 
@@ -28,6 +31,7 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) {
   MMDAI.DXILVersion = TT.getDXILVersion();
   MMDAI.ShaderModelVersion = TT.getOSVersion();
   MMDAI.ShaderProfile = TT.getEnvironment();
+
   NamedMDNode *ValidatorVerNode = M.getNamedMetadata("dx.valver");
   if (ValidatorVerNode) {
     auto *ValVerMD = cast<MDNode>(ValidatorVerNode->getOperand(0));
@@ -37,6 +41,19 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) {
         VersionTuple(MajorMD->getZExtValue(), MinorMD->getZExtValue());
   }
 
+  NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
+  if (RootSignatureNode) {
+    auto RootSignatureParser =
+        root_signature::MetadataParser(RootSignatureNode);
+
+    root_signature::VersionedRootSignatureDesc Desc;
+
+    RootSignatureParser.Parse(root_signature::RootSignatureVersion::Version_1,
+                              &Desc);
+
+    MMDAI.RootSignatureDesc = Desc;
+  }
+
   // For all HLSL Shader functions
   for (auto &F : M.functions()) {
     if (!F.hasFnAttribute("hlsl.shader"))
diff --git a/llvm/lib/Analysis/DXILRootSignature.cpp b/llvm/lib/Analysis/DXILRootSignature.cpp
new file mode 100644
index 00000000000000..fce97eb27cf8f8
--- /dev/null
+++ b/llvm/lib/Analysis/DXILRootSignature.cpp
@@ -0,0 +1,110 @@
+//===- DXILRootSignature.cpp - DXIL Root Signature helper objects
+//-----------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file contains the parsing logic to extract root signature data
+///       from LLVM IR metadata.
+///
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/DXILRootSignature.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Metadata.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+
+namespace llvm {
+namespace dxil {
+
+bool root_signature::MetadataParser::Parse(RootSignatureVersion Version,
+                                           VersionedRootSignatureDesc *Desc) {
+  Desc->Version = Version;
+  bool HasError = false;
+
+  for (unsigned int Sid = 0; Sid < Root->getNumOperands(); Sid++) {
+    // This should be an if, for error handling
+    MDNode *Node = cast<MDNode>(Root->getOperand(Sid));
+
+    // Not sure what use this for...
+    Metadata *Func = Node->getOperand(0).get();
+
+    // This should be an if, for error handling
+    MDNode *Elements = cast<MDNode>(Node->getOperand(1).get());
+
+    for (unsigned int Eid = 0; Eid < Elements->getNumOperands(); Eid++) {
+      MDNode *Element = cast<MDNode>(Elements->getOperand(Eid));
+
+      HasError = HasError || ParseRootSignatureElement(Element, Desc);
+    }
+  }
+  return HasError;
+}
+
+bool root_signature::MetadataParser::ParseRootFlags(
+    MDNode *RootFlagNode, VersionedRootSignatureDesc *Desc) {
+
+  assert(RootFlagNode->getNumOperands() == 2 &&
+         "Invalid format for RootFlag Element");
+  auto *Flag = mdconst::extract<ConstantInt>(RootFlagNode->getOperand(1));
+  auto Value = (RootSignatureFlags)Flag->getZExtValue();
+
+  if ((Value & ~RootSignatureFlags::ValidFlags) != RootSignatureFlags::None)
+    return true;
+
+  switch (Desc->Version) {
+
+  case RootSignatureVersion::Version_1:
+    Desc->Desc_1_0.Flags = (RootSignatureFlags)Value;
+    break;
+  case RootSignatureVersion::Version_1_1:
+  case RootSignatureVersion::Version_1_2:
+    llvm_unreachable("Not implemented yet");
+    break;
+  }
+  return false;
+}
+
+bool root_signature::MetadataParser::ParseRootSignatureElement(
+    MDNode *Element, VersionedRootSignatureDesc *Desc) {
+  MDString *ElementText = cast<MDString>(Element->getOperand(0));
+
+  assert(ElementText != nullptr && "First preoperty of element is not ");
+
+  RootSignatureElementKind ElementKind =
+      StringSwitch<RootSignatureElementKind>(ElementText->getString())
+          .Case("RootFlags", RootSignatureElementKind::RootFlags)
+          .Case("RootConstants", RootSignatureElementKind::RootConstants)
+          .Case("RootCBV", RootSignatureElementKind::RootDescriptor)
+          .Case("RootSRV", RootSignatureElementKind::RootDescriptor)
+          .Case("RootUAV", RootSignatureElementKind::RootDescriptor)
+          .Case("Sampler", RootSignatureElementKind::RootDescriptor)
+          .Case("DescriptorTable", RootSignatureElementKind::DescriptorTable)
+          .Case("StaticSampler", RootSignatureElementKind::StaticSampler)
+          .Default(RootSignatureElementKind::None);
+
+  switch (ElementKind) {
+
+  case RootSignatureElementKind::RootFlags: {
+    return ParseRootFlags(Element, Desc);
+    break;
+  }
+
+  case RootSignatureElementKind::RootConstants:
+  case RootSignatureElementKind::RootDescriptor:
+  case RootSignatureElementKind::DescriptorTable:
+  case RootSignatureElementKind::StaticSampler:
+  case RootSignatureElementKind::None:
+    llvm_unreachable("Not Implemented yet");
+    break;
+  }
+
+  return true;
+}
+} // namespace dxil
+} // namespace llvm
diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp
index 3b1a6203a1f8fc..f50f68df88ec2a 100644
--- a/llvm/lib/Object/DXContainer.cpp
+++ b/llvm/lib/Object/DXContainer.cpp
@@ -7,9 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Object/DXContainer.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/Object/Error.h"
 #include "llvm/Support/Alignment.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 
 using namespace llvm;
@@ -92,6 +94,14 @@ Error DXContainer::parseHash(StringRef Part) {
   return Error::success();
 }
 
+Error DXContainer::parseRootSignature(StringRef Part) {
+  dxil::root_signature::VersionedRootSignatureDesc Desc;
+  if (Error Err = readStruct(Part, Part.begin(), Desc))
+    return Err;
+  RootSignature = Desc;
+  return Error::success();
+}
+
 Error DXContainer::parsePSVInfo(StringRef Part) {
   if (PSVInfo)
     return parseFailed("More than one PSV0 part is present in the file");
@@ -192,6 +202,11 @@ Error DXContainer::parsePartOffsets() {
         return Err;
       break;
     case dxbc::PartType::Unknown:
+      break;
+    case dxbc::PartType::RTS0:
+      if (Error Err = parseRootSignature(PartData))
+        return Err;
+
       break;
     }
   }
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index 175f1a12f93145..905d409562ff45 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -11,6 +11,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/MC/DXContainerPSVInfo.h"
 #include "llvm/ObjectYAML/ObjectYAML.h"
@@ -261,6 +262,12 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
     }
     case dxbc::PartType::Unknown:
       break; // Skip any handling for unrecognized parts.
+    case dxbc::PartType::RTS0:
+      if (!P.RootSignature.has_value())
+        continue;
+      OS.write(reinterpret_cast<const char *>(&P.RootSignature),
+               sizeof(dxil::root_signature::VersionedRootSignatureDesc));
+      break;
     }
     uint64_t BytesWritten = OS.tell() - DataStart;
     RollingOffset += BytesWritten;
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 5dee1221b27c01..eab3fcc5936f85 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -13,6 +13,7 @@
 
 #include "llvm/ObjectYAML/DXContainerYAML.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/Analysis/DXILRootSignature.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -188,6 +189,12 @@ void MappingTraits<DXContainerYAML::Signature>::mapping(
   IO.mapRequired("Parameters", S.Parameters);
 }
 
+void MappingTraits<DXContainerYAML::RootSignature>::mapping(
+    IO &IO, DXContainerYAML::RootSignature &S) {
+  IO.mapRequired("Version", S.Version);
+  IO.mapRequired("Flags", S.Flags);
+}
+
 void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
                                                    DXContainerYAML::Part &P) {
   IO.mapRequired("Name", P.Name);
@@ -197,6 +204,7 @@ void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
   IO.mapOptional("Hash", P.Hash);
   IO.mapOptional("PSVInfo", P.Info);
   IO.mapOptional("Signature", P.Signature);
+  IO.mapOptional("RootSignature", P.RootSignature);
 }
 
 void MappingTraits<DXContainerYAML::Object>::mapping(
@@ -290,6 +298,66 @@ void ScalarEnumerationTraits<dxbc::SigComponentType>::enumeration(
     IO.enumCase(Value, E.Name.str().c_str(), E.Value);
 }
 
+template <>
+struct llvm::yaml::ScalarEnumerationTraits<
+    dxil::root_signature::RootSignatureVersion> {
+  static void enumeration(IO &io,
+                          dxil::root_signature::RootSignatureVersion &Val) {
+    io.enumCase(Val, "1.0",
+                dxil::root_signature::RootSignatureVersion::Version_1);
+    io.enumCase(Val, "1.0",
+                dxil::root_signature::RootSignatureVersion::Version_1_0);
+    io.enumCase(Val, "1.1",
+                dxil::root_signature::RootSignatureVersion::Version_1_1);
+    io.enumCase(Val, "1.2",
+                dxil::root_signature::RootSignatureVersion::Version_1_2);
+  }
+};
+
+template <>
+struct llvm::yaml::ScalarEnumerationTraits<
+    dxil::root_signature::RootSignatureFlags> {
+  static void enumeration(IO &io,
+                          dxil::root_signature::RootSignatureFlags &Val) {
+    io.enumCase(Val, "AllowInputAssemblerInputLayout",
+                dxil::root_signature::RootSignatureFlags::
+                    AllowInputAssemblerInputLayout);
+    io.enumCase(
+        Val, "DenyVertexShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyVertexShaderRootAccess);
+    io.enumCase(
+        Val, "DenyHullShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyHullShaderRootAccess);
+    io.enumCase(
+        Val, "DenyDomainShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyDomainShaderRootAccess);
+    io.enumCase(
+        Val, "DenyGeometryShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyGeometryShaderRootAccess);
+    io.enumCase(
+        Val, "DenyPixelShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyPixelShaderRootAccess);
+    io.enumCase(Val, "AllowStreamOutput",
+                dxil::root_signature::RootSignatureFlags::AllowStreamOutput);
+    io.enumCase(Val, "LocalRootSignature",
+                dxil::root_signature::RootSignatureFlags::LocalRootSignature);
+    io.enumCase(Val, "DenyAmplificationShaderRootAccess",
+                dxil::root_signature::RootSignatureFlags::
+                    DenyAmplificationShaderRootAccess);
+    io.enumCase(
+        Val, "DenyMeshShaderRootAccess",
+        dxil::root_signature::RootSignatureFlags::DenyMeshShaderRootAccess);
+    io.enumCase(
+        Val, "CBVSRVUAVHeapDirectlyIndexed",
+        dxil::root_signature::RootSignatureFlags::CBVSRVUAVHeapDirectlyIndexed);
+    io.enumCase(
+        Val, "SamplerHeapDirectlyIndexed",
+        dxil::root_signature::RootSignatureFlags::SamplerHeapDirectlyIndexed);
+    io.enumCase(Val, "AllowLowTierReservedHwCbLimit",
+                dxil::root_signature::RootSignatureFlags::
+                    AllowLowTierReservedHwCbLimit);
+  }
+};
 } // namespace yaml
 
 void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) {
diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
index 7a0bd6a7c88692..e3174d600e6534 100644
--- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
+++ b/llvm/lib/Target/Direct...
[truncated]

Copy link

github-actions bot commented Jan 10, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

In the past when we've made changes to support emitting new parts of the container file we've broken the changes up into multiple PRs that land separately. Usually the first PR adds parsing and YAML tooling (with YAML roundtrip tests), and the second PR adds support for generating the data from IR and emitting the final file.

I believe this PR would benefit from being split up that way to make it easier to review.

Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

There is a lot about this PR that needs to change. I'll work through writing detailed feedback next week but some high level things:

  1. Splitting up the change will make it a lot easier to review (I commented this separately too).
  2. There are no tests of the yaml2obj support.
  3. It doesn't look like you're handling endianness on the encoding.
  4. The code structure is all off.

ObjectYAML cannot and should not depend on the IR analysis library. The code for encoding binary structures should be part of the MC library not the analysis library. Take a look at how the code for the PSV0 data is structured because this should be closer to that.

@joaosaffran joaosaffran marked this pull request as draft January 11, 2025 00:14
@joaosaffran joaosaffran force-pushed the roosignatures/backend branch from 988e7b0 to 8adb678 Compare January 13, 2025 22:10
@joaosaffran joaosaffran changed the title [DXIL] Adding support to RootSignatureFlags generation to DXContainer [DXIL] Adding support to RootSignatureFlags in obj2yaml Jan 13, 2025
Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

This is definitely moving in the right direction.

void MappingTraits<DXContainerYAML::RootSignatureDesc>::mapping(
IO &IO, DXContainerYAML::RootSignatureDesc &S) {
IO.mapRequired("Version", S.Version);
IO.mapRequired("Flags", S.Flags);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might look at how we did the ShaderFeatureFlags. That approach makes the flags print nicer and more human readable in the YAML output.

In going that route the one thing I would probably do differently is making each flag "optional" rather than required in the yaml with a default value as false. That will make the printing more concise.

FileSize: 1672
PartCount: 7
PartOffsets: [ 60, 1496, 1512, 1540, 1556, 1572, 1588 ]
Parts:
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is valid to have a root signature in a container by itself, so you shouldn't need a bunch of different parts. This test is an example of generating a root-signature-only container:

https://github.com/microsoft/DirectXShaderCompiler/blob/main/tools/clang/test/DXC/local_rs.hlsl

@joaosaffran joaosaffran marked this pull request as ready for review January 14, 2025 23:43
Copy link
Contributor

@inbelic inbelic left a comment

Choose a reason for hiding this comment

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

Just a collection of nits

if (RS && RS.has_value())
NewPart.RootSignature = DXContainerYAML::RootSignatureDesc(*RS);
break;
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
break;

@@ -153,6 +153,12 @@ dumpDXContainer(MemoryBufferRef Source) {
break;
case dxbc::PartType::Unknown:
break;
case dxbc::PartType::RTS0:
std::optional<dxbc::RootSignatureDesc> RS = Container.getRootSignature();
if (RS && RS.has_value())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (RS && RS.has_value())
if (RS.has_value())

case dxbc::PartType::RTS0:
if (Error Err = parseRootSignature(PartData))
return Err;

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Copy link
Contributor

@damyanp damyanp left a comment

Choose a reason for hiding this comment

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

Some notes - there's things in here that aren't being used yet, it'd be preferable to not include them if they're not necessary.

It'd be good to get approval from someone more familiar in the obj2yaml / yaml2obj area than I am.

Comment on lines 56 to 64
#ifdef ROOT_PARAMETER

ROOT_PARAMETER(DescriptorTable)
ROOT_PARAMETER(Constants32Bit)
ROOT_PARAMETER(CBV)
ROOT_PARAMETER(SRV)
ROOT_PARAMETER(UAV)
#undef ROOT_PARAMETER
#endif // ROOT_PARAMETER
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any uses of ROOT_PARAMETER or SHADER_VISIBILITY. Can we hold off adding them until they're used please?


#ifdef ROOT_ELEMENT_FLAG

ROOT_ELEMENT_FLAG(0, AllowInputAssemblerInputLayout, "The app is opting in to using the Input Assembler")
Copy link
Contributor

Choose a reason for hiding this comment

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

Where do these descriptions of the flags show up? If they don't show up anywhere then it'd be great to remove them so I don't have to review them!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was added as a previous suggestion from Finn #122396 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

You don't have to do everything everyone suggests (my suggestions included).

I don't understand the point of adding these descriptions if they're not used for anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops, my original comment wasn't very clear then. I had intended to ask for a description of the enum as a comment, similar to the other ones. Not to add a description field for each of the flags

@@ -72,6 +73,21 @@ struct ShaderHash {
std::vector<llvm::yaml::Hex8> Digest;
};

#define ROOT_ELEMENT_FLAG(Num, Val, Str) bool Val = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that this is copying the ShaderFeatureFlags example above, but IMO this would be much clearer if the #define was immediately before the #include. I'd be interested to know if there's a reason for this.

Comment on lines 81 to 88
uint32_t getEncodedFlags();
uint32_t Version;
uint32_t NumParameters;
uint32_t RootParametersOffset;
uint32_t NumStaticSamplers;
uint32_t StaticSamplersOffset;

#include "llvm/BinaryFormat/DXContainerConstants.def"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uint32_t getEncodedFlags();
uint32_t Version;
uint32_t NumParameters;
uint32_t RootParametersOffset;
uint32_t NumStaticSamplers;
uint32_t StaticSamplersOffset;
#include "llvm/BinaryFormat/DXContainerConstants.def"
uint32_t Version;
uint32_t NumParameters;
uint32_t RootParametersOffset;
uint32_t NumStaticSamplers;
uint32_t StaticSamplersOffset;
uint32_t getEncodedFlags();
#include "llvm/BinaryFormat/DXContainerConstants.def"

IMO this makes it a bit clearer what's going on and less likely to be confused that there's a getEncodedFlags member variable.

(also, github has messed up the diff of this suggestion and I don't know how to fix it)

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.

This is looking fairly close. A couple of comments in addition to Damyan's here.

Also a couple of notes on the tests:

  1. I see you added a compatibility test that used dxil-dis and then removed it citing feedback on the tests. Was there a conversation that I missed? Is there a reason we don't want to add that test?
  2. The DXContainerTest also needs some negative test cases - what if the buffer is too small? Do we need to validate that the version is what we expect?

Comment on lines 131 to 133
RootSignature(StringRef Data) : Data(Data) {}

Error parse();
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bit awkward to have the invariant that a user must call parse immediately after construction for this object to be valid. I would probably opt for making the constructor private and adding a factory method to parse a valid object, so something like:

  static Expected<RootSignature> parse(StringRef Data);

Also, do we actually need to store the reference to the string in the root signature object? Would just having the parsed integer values be sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked at this a bit: this is following an existing pattern used in the same source file. I wonder if it might be better to get this change in following the same conventions used, and then do a follow up PR that just refactors all the places in here that follow that pattern. Then we can decide if it's the right thing to do or not?

Being consistent with existing code has its virtues.

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds reasonable to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that way to keep the code consistent. I like @damyanp suggestion. I can refactor all cases that this suggestion falls into in a future PR. Thoughts @bogner ?

Comment on lines 837 to 844
const auto &RS = C.getRootSignature();
ASSERT_TRUE(RS.has_value());
ASSERT_EQ(RS->getVersion(), 2);
ASSERT_EQ(RS->getNumParameters(), 0);
ASSERT_EQ(RS->getRootParametersOffset(), 0);
ASSERT_EQ(RS->getNumStaticSamplers(), 0);
ASSERT_EQ(RS->getStaticSamplersOffset(), 0);
ASSERT_EQ(RS->getFlags(), 0x01);
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to Damyan's suggestion above, we should really use non-zero values for the fields here to ensure that we're reading things from the right places. As is, if we changed the order of the fields in the parser arbitrarily this test would still pass, which is not great.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the idea here is that there'll be additional tests in the future that add parameters and samplers, and at that point we'll be testing these fields.

I don't think we can set any of these parameters to non-zero (apart from maybe the offsets?) without actually providing the parameters - or having invalid data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@damyanp is correct. Most of those values need to be 0, mainly NumParameters and NumStaticSamplers. If those values are non zero, dxc and it's tools will try to parse the respective parameters and Static Samplers. Which will be added in the future.

My plan is to add some more testing for those whenever we support those. I modify the other test to have non zero value instead.

@joaosaffran joaosaffran requested a review from bogner February 4, 2025 23:33
Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

A few small comments, otherwise looks good.

Comment on lines 249 to 251
if (Data.size() < 6 * sizeof(uint32_t)) {
return parseFailed("Invalid data. Too small.");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

Suggested change
if (Data.size() < 6 * sizeof(uint32_t)) {
return parseFailed("Invalid data. Too small.");
}
if (Data.size() < 6 * sizeof(uint32_t))
return parseFailed("Invalid data. Too small.");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed that, thanks


// Root Signature headers expects 6 integers to be present.
if (Data.size() < 6 * sizeof(uint32_t)) {
return parseFailed("Invalid data. Too small.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The error here should probably be more descriptive. Imagine having a tool print this error? Without context it doesn't really tell you what went wrong.

Maybe something more like "Invalid root signature, insufficient space for header."


static Expected<uint32_t> validateVersion(uint32_t Version) {
if (Version < 1 || Version > 2)
return llvm::make_error<BinaryStreamError>("Invalid Version");
Copy link
Collaborator

Choose a reason for hiding this comment

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

What version is invalid?

Suggested change
return llvm::make_error<BinaryStreamError>("Invalid Version");
return llvm::make_error<BinaryStreamError>("Invalid Root Signature Version");


static Expected<uint32_t> validateRootFlag(uint32_t Flags) {
if ((Flags & ~0x80000fff) != 0)
return llvm::make_error<BinaryStreamError>("Invalid flag");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return llvm::make_error<BinaryStreamError>("Invalid flag");
return llvm::make_error<BinaryStreamError>("Invalid Root Signature flag");

Copy link
Contributor

@damyanp damyanp left a comment

Choose a reason for hiding this comment

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

LGTM, assuming llvm-beanz's feedback is addressed.

@joaosaffran joaosaffran merged commit 76985fd into llvm:main Feb 7, 2025
8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 7, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-lld-multistage-test running on ppc64le-lld-multistage-test while building llvm at step 12 "build-stage2-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/8488

Here is the relevant piece of the build log for the reference
Step 12 (build-stage2-unified-tree) failure: build (failure)
...
5.780 [1/8/15] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangOptionDocEmitter.cpp.o
7.902 [1/7/16] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangOpenCLBuiltinEmitter.cpp.o
9.802 [1/6/17] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/RISCVVEmitter.cpp.o
10.506 [1/5/18] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o
11.077 [1/4/19] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/SveEmitter.cpp.o
13.703 [1/3/20] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/MveEmitter.cpp.o
14.917 [1/2/21] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/NeonEmitter.cpp.o
89.851 [1/1/22] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.cpp.o
91.190 [0/1/23] Linking CXX executable bin/clang-tblgen
108.681 [3976/555/1925] Building CXX object unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o
FAILED: unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/install/stage1/bin/clang++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/unittests/Object -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/Object -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o -MF unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o.d -o unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/Object/DXContainerTest.cpp
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/Object/DXContainerTest.cpp:15:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/include/llvm/Testing/Support/Error.h:13:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/include/llvm/Testing/Support/SupportHelpers.h:17:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googlemock/include/gmock/gmock-matchers.h:274:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h:50:
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1379:11: error: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Werror,-Wsign-compare]
 1379 |   if (lhs == rhs) {
      |       ~~~ ^  ~~~
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1398:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here
 1398 |     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
      |            ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/Object/DXContainerTest.cpp:840:5: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here
  840 |     ASSERT_EQ(RS->getVersion(), 2);
      |     ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1898:31: note: expanded from macro 'ASSERT_EQ'
 1898 | #define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
      |                               ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1882:54: note: expanded from macro 'GTEST_ASSERT_EQ'
 1882 |   ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
      |                                                      ^
1 error generated.
128.774 [3976/256/2224] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/ComplexDeinterleavingPass.cpp.o
129.381 [3976/254/2226] Building CXX object unittests/Transforms/Utils/CMakeFiles/UtilsTests.dir/CodeExtractorTest.cpp.o
129.751 [3976/253/2227] Building CXX object lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AccelTable.cpp.o
129.771 [3976/252/2228] Building CXX object lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/DeadStoreElimination.cpp.o
129.841 [3976/251/2229] Building CXX object lib/Analysis/CMakeFiles/LLVMAnalysis.dir/StackSafetyAnalysis.cpp.o
130.081 [3976/250/2230] Building CXX object lib/IR/CMakeFiles/LLVMCore.dir/AsmWriter.cpp.o
130.212 [3976/249/2231] Building CXX object lib/DWARFLinker/Parallel/CMakeFiles/LLVMDWARFLinkerParallel.dir/DWARFLinkerUnit.cpp.o
130.401 [3976/248/2232] Building CXX object lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/GVN.cpp.o
130.521 [3976/247/2233] Building CXX object lib/IR/CMakeFiles/LLVMCore.dir/AutoUpgrade.cpp.o
130.581 [3976/246/2234] Building CXX object lib/Analysis/CMakeFiles/LLVMAnalysis.dir/InstructionSimplify.cpp.o
130.601 [3976/245/2235] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/ShrinkWrap.cpp.o
130.681 [3976/244/2236] Building CXX object unittests/ObjectYAML/CMakeFiles/ObjectYAMLTests.dir/MinidumpYAMLTest.cpp.o
130.769 [3976/243/2237] Building CXX object unittests/Analysis/CMakeFiles/AnalysisTests.dir/AssumeBundleQueriesTest.cpp.o
130.921 [3976/242/2238] Building CXX object unittests/tools/llvm-profdata/CMakeFiles/LLVMProfdataTests.dir/OutputSizeLimitTest.cpp.o
131.161 [3976/241/2239] Building CXX object lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/MemProfiler.cpp.o
131.212 [3976/240/2240] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MachineInstr.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 7, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-5 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/14306

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 7, 2025

LLVM Buildbot has detected a new failure on builder clang-ppc64le-rhel running on ppc64le-clang-rhel-test while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/4993

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
0.198 [2/3/1] Building CXX object compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_dynamic_version_script_dummy.powerpc64le.dir/dummy.cpp.o
0.199 [1/3/2] Building CXX object compiler-rt/lib/asan/CMakeFiles/RTAsan_dynamic_version_script_dummy.powerpc64le.dir/dummy.cpp.o
0.431 [0/3/3] Linking CXX shared library /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.ubsan_standalone.so
0.456 [0/2/4] Linking CXX shared library /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.asan.so
1.171 [0/1/5] Generating /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/compile_commands.json
23.881 [5/3/1211] cd /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/runtimes/runtimes-bins && /home/buildbots/llvm-external-buildbots/cmake-3.31.2/bin/cmake --build /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/runtimes/runtimes-bins/ --target runtimes-test-depends --config Release
ninja: no work to do.
23.948 [4/3/1212] No install step for 'runtimes'
23.971 [3/3/1214] Completed 'runtimes'
24.436 [3/2/1215] Building CXX object unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o
FAILED: unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/clang.19.1.7/bin/clang++ --gcc-toolchain=/gcc-toolchain/usr -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/unittests/Object -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/unittests/Object -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googletest/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o -MF unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o.d -o unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/unittests/Object/DXContainerTest.cpp
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/unittests/Object/DXContainerTest.cpp:15:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include/llvm/Testing/Support/Error.h:13:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include/llvm/Testing/Support/SupportHelpers.h:17:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googlemock/include/gmock/gmock-matchers.h:274:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h:50:
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1379:11: error: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Werror,-Wsign-compare]
 1379 |   if (lhs == rhs) {
      |       ~~~ ^  ~~~
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1398:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here
 1398 |     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
      |            ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/unittests/Object/DXContainerTest.cpp:840:5: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here
  840 |     ASSERT_EQ(RS->getVersion(), 2);
      |     ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1898:31: note: expanded from macro 'ASSERT_EQ'
 1898 | #define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
      |                               ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1882:54: note: expanded from macro 'GTEST_ASSERT_EQ'
 1882 |   ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
      |                                                      ^
1 error generated.
26.995 [3/1/1216] Building CXX object unittests/ObjectYAML/CMakeFiles/ObjectYAMLTests.dir/DXContainerYAMLTest.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 8, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/22315

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Misc/Posix/static-link.cpp (94203 of 98228)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/suppressions.cpp (94204 of 98228)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Misc/Posix/ubsan_options.cpp (94205 of 98228)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Misc/bool.cpp (94206 of 98228)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/Misc/local_bounds.cpp (94207 of 98228)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/usub-overflow.cpp (94208 of 98228)
UNSUPPORTED: UBSan-Standalone-lld-x86_64 :: TestCases/Misc/no-interception.cpp (94209 of 98228)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/ImplicitConversion/bitfield-conversion.c (94210 of 98228)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Misc/bool.m (94211 of 98228)
TIMEOUT: MLIR :: Examples/standalone/test.toy (94212 of 98228)
******************** TEST 'MLIR :: Examples/standalone/test.toy' FAILED ********************
Exit Code: 1
Timeout: Reached timeout of 60 seconds

Command Output (stdout):
--
# RUN: at line 1
"/etc/cmake/bin/cmake" "/build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone" -G "Ninja"  -DCMAKE_CXX_COMPILER=/usr/bin/clang++  -DCMAKE_C_COMPILER=/usr/bin/clang   -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir  -DLLVM_USE_LINKER=lld  -DPython3_EXECUTABLE="/usr/bin/python3.10"
# executed command: /etc/cmake/bin/cmake /build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir -DLLVM_USE_LINKER=lld -DPython3_EXECUTABLE=/usr/bin/python3.10
# .---command stdout------------
# | -- The CXX compiler identification is Clang 16.0.6
# | -- The C compiler identification is Clang 16.0.6
# | -- Detecting CXX compiler ABI info
# | -- Detecting CXX compiler ABI info - done
# | -- Check for working CXX compiler: /usr/bin/clang++ - skipped
# | -- Detecting CXX compile features
# | -- Detecting CXX compile features - done
# | -- Detecting C compiler ABI info
# | -- Detecting C compiler ABI info - done
# | -- Check for working C compiler: /usr/bin/clang - skipped
# | -- Detecting C compile features
# | -- Detecting C compile features - done
# | -- Looking for histedit.h
# | -- Looking for histedit.h - found
# | -- Found LibEdit: /usr/include (found version "2.11") 
# | -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
# | -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.13") 
# | -- Using MLIRConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir
# | -- Using LLVMConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/llvm
# | -- Linker detection: unknown
# | -- Performing Test LLVM_LIBSTDCXX_MIN
# | -- Performing Test LLVM_LIBSTDCXX_MIN - Success
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR - Success
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Success
# | -- Performing Test C_SUPPORTS_FPIC
# | -- Performing Test C_SUPPORTS_FPIC - Success
# | -- Performing Test CXX_SUPPORTS_FPIC

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 8, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-win running on as-worker-93 while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2249

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Support/./SupportTests.exe/38/87' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-15428-38-87.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=38 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied




********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 8, 2025

LLVM Buildbot has detected a new failure on builder clang-ppc64-aix running on aix-ppc64 while building llvm at step 3 "clean-build-dir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/64/builds/2207

Here is the relevant piece of the build log for the reference
Step 3 (clean-build-dir) failure: Delete failed. (failure) (timed out)
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
...
594.050 [334/50/672] Building CXX object unittests/IR/CMakeFiles/IRTests.dir/MetadataTest.cpp.o
594.477 [333/50/673] Building CXX object unittests/IR/CMakeFiles/IRTests.dir/PatternMatch.cpp.o
594.632 [332/50/674] Building CXX object unittests/ExecutionEngine/Orc/CMakeFiles/OrcJITTests.dir/LazyCallThroughAndReexportsTest.cpp.o
595.770 [331/50/675] Building CXX object unittests/ExecutionEngine/Orc/CMakeFiles/OrcJITTests.dir/LookupAndRecordAddrsTest.cpp.o
595.908 [330/50/676] Building CXX object unittests/ExecutionEngine/Orc/CMakeFiles/OrcJITTests.dir/OrcCAPITest.cpp.o
596.033 [329/50/677] Building CXX object unittests/ExecutionEngine/Orc/CMakeFiles/OrcJITTests.dir/ResourceTrackerTest.cpp.o
596.243 [328/50/678] Building CXX object unittests/ExecutionEngine/Orc/CMakeFiles/OrcJITTests.dir/JITLinkRedirectionManagerTest.cpp.o
596.393 [327/50/679] Building CXX object unittests/ExecutionEngine/Orc/CMakeFiles/OrcJITTests.dir/ReOptimizeLayerTest.cpp.o
596.680 [326/50/680] Building CXX object unittests/MIR/CMakeFiles/MIRTests.dir/MachineMetadata.cpp.o
597.042 [325/50/681] Building CXX object unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o
FAILED: unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o 
/usr/local/clang-17.0.2/bin/clang++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_LARGE_FILE_API -D_XOPEN_SOURCE=700 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/unittests/Object -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Object -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/include -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/include -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googletest/include -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googlemock/include -mcmodel=large -fPIC -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o -MF unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o.d -o unittests/Object/CMakeFiles/ObjectTests.dir/DXContainerTest.cpp.o -c /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Object/DXContainerTest.cpp
In file included from /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Object/DXContainerTest.cpp:15:
In file included from /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/include/llvm/Testing/Support/Error.h:13:
In file included from /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/include/llvm/Testing/Support/SupportHelpers.h:17:
In file included from /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googlemock/include/gmock/gmock-matchers.h:274:
In file included from /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h:50:
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1379:11: error: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Werror,-Wsign-compare]
 1379 |   if (lhs == rhs) {
      |       ~~~ ^  ~~~
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1398:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here
 1398 |     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
      |            ^
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Object/DXContainerTest.cpp:840:5: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here
  840 |     ASSERT_EQ(RS->getVersion(), 2);
      |     ^
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1898:31: note: expanded from macro 'ASSERT_EQ'
 1898 | #define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
      |                               ^
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1882:54: note: expanded from macro 'GTEST_ASSERT_EQ'
 1882 |   ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
      |                                                      ^
1 error generated.
597.057 [325/49/682] Building CXX object unittests/Object/CMakeFiles/ObjectTests.dir/MinidumpTest.cpp.o
597.069 [325/48/683] Building CXX object unittests/MI/CMakeFiles/MITests.dir/LiveIntervalTest.cpp.o
597.075 [325/47/684] Building CXX object unittests/ObjectYAML/CMakeFiles/ObjectYAMLTests.dir/YAMLTest.cpp.o
597.090 [325/46/685] Building CXX object unittests/Remarks/CMakeFiles/RemarksTests.dir/BitstreamRemarksFormatTest.cpp.o
597.093 [325/45/686] Building CXX object unittests/Remarks/CMakeFiles/RemarksTests.dir/RemarksAPITest.cpp.o
597.099 [325/44/687] Building CXX object unittests/Passes/PassBuilderBindings/CMakeFiles/PassesBindingsTests.dir/PassBuilderBindingsTest.cpp.o
597.601 [325/43/688] Building CXX object unittests/Remarks/CMakeFiles/RemarksTests.dir/RemarksStrTabParsingTest.cpp.o
599.011 [325/42/689] Building CXX object unittests/ObjectYAML/CMakeFiles/ObjectYAMLTests.dir/YAML2ObjTest.cpp.o
599.788 [325/41/690] Building CXX object unittests/ProfileData/CMakeFiles/ProfileDataTests.dir/InstrProfDataTest.cpp.o
601.429 [325/40/691] Building CXX object unittests/Object/CMakeFiles/ObjectTests.dir/ELFObjectFileTest.cpp.o
602.608 [325/39/692] Building CXX object unittests/Remarks/CMakeFiles/RemarksTests.dir/BitstreamRemarksSerializerTest.cpp.o
602.872 [325/38/693] Building CXX object unittests/Remarks/CMakeFiles/RemarksTests.dir/RemarksLinkingTest.cpp.o
602.949 [325/37/694] Building CXX object unittests/ProfileData/CMakeFiles/ProfileDataTests.dir/ItaniumManglingCanonicalizerTest.cpp.o
603.111 [325/36/695] Building CXX object unittests/Remarks/CMakeFiles/RemarksTests.dir/YAMLRemarksSerializerTest.cpp.o
603.692 [325/35/696] Building CXX object unittests/ProfileData/CMakeFiles/ProfileDataTests.dir/SymbolRemappingReaderTest.cpp.o
603.985 [325/34/697] Building CXX object unittests/Option/CMakeFiles/OptionTests.dir/OptionMarshallingTest.cpp.o

Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
This PR adds:
- `RootSignatureFlags` extraction from DXContainer using `obj2yaml`


This PR is part of: llvm#121493

---------

Co-authored-by: joaosaffran <[email protected]>
@damyanp damyanp moved this to Closed in HLSL Support Apr 25, 2025
@damyanp damyanp removed this from HLSL Support Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX llvm:analysis Includes value tracking, cost tables and constant folding llvm:binary-utilities objectyaml
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[HLSL] Disassemble DX Container Root Signatures
7 participants