llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-llvm-binary-utilities Author: Vladislav Dzhidzhoev (dzhidzhoev) <details> <summary>Changes</summary> In DXC, when `/Qpdb_in_private` flag is specified, debug info PDB is emitted into PRIV part of the output DXContainer (as well as into separate PDB file, if its name is specified with `/Fd`). This patch reimplements similar behavior in llc and Clang. MC is modified to be able to emit PRIV part. Depends on https://github.com/llvm/llvm-project/pull/204166, https://github.com/llvm/llvm-project/pull/204899. --- Patch is 32.76 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/204903.diff 25 Files Affected: - (modified) clang/include/clang/Options/Options.td (+3) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+4) - (modified) clang/test/Driver/dxc_debug.hlsl (+2) - (modified) clang/test/Driver/dxc_section_emission.hlsl (+11) - (modified) llvm/include/llvm/BinaryFormat/DXContainerConstants.def (+1) - (modified) llvm/include/llvm/Object/DXContainer.h (+4) - (modified) llvm/include/llvm/ObjectYAML/DXContainerYAML.h (+1) - (modified) llvm/lib/MC/MCDXContainerWriter.cpp (+17-5) - (modified) llvm/lib/Object/DXContainer.cpp (+14) - (modified) llvm/lib/ObjectYAML/DXContainerEmitter.cpp (+15) - (modified) llvm/lib/ObjectYAML/DXContainerYAML.cpp (+9) - (modified) llvm/lib/Target/DirectX/DXContainerGlobals.cpp (+19-14) - (modified) llvm/lib/Target/DirectX/DXContainerPDB.cpp (+42-4) - (added) llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-fd.test (+17) - (added) llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-flag.test (+5) - (added) llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-pdbname.ll (+10) - (added) llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate.ll (+18) - (added) llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate.test (+33) - (added) llvm/test/ObjectYAML/DXContainer/PRIV-not-last.yaml (+29) - (added) llvm/test/tools/llvm-objcopy/DXContainer/dump-section-priv.yaml (+35) - (added) llvm/test/tools/obj2yaml/DXContainer/PRIVPart.yaml (+42) - (modified) llvm/unittests/MC/CMakeLists.txt (+2) - (added) llvm/unittests/MC/DXContainerWriterTest.cpp (+83) - (modified) llvm/unittests/Object/DXContainerTest.cpp (+30) - (modified) llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp (+29) ``````````diff diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index ceb430029aba1..6f904a1444403 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -9769,6 +9769,9 @@ def dxc_gis : DXCFlag<"Gis">, def dxc_Qembed_debug : DXCFlag<"Qembed_debug">, HelpText<"Embed PDB in shader container (must be used with /Zi)">; +def dxc_Qpdb_in_private : DXCFlag<"Qpdb_in_private">, + Flags<[HelpHidden]>, + HelpText<"Store PDB in private user data">; def spirv : DXCFlag<"spirv">, HelpText<"Generate SPIR-V code">; def metal : DXCFlag<"metal">, HelpText<"Generate Metal library">; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 1a4f4fcec2c9a..e62e415620062 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3869,6 +3869,10 @@ static void RenderHLSLOptions(const Driver &D, const ArgList &Args, CmdArgs.push_back("-mllvm"); CmdArgs.push_back("--dx-embed-debug"); } + if (Args.hasArg(options::OPT_dxc_Qpdb_in_private)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("--dx-pdb-in-private"); + } if (Fd) { CmdArgs.push_back("-mllvm"); CmdArgs.push_back(Args.MakeArgString("--dx-Fd=" + Twine(Fd->getValue()))); diff --git a/clang/test/Driver/dxc_debug.hlsl b/clang/test/Driver/dxc_debug.hlsl index d90be0bb5bad2..49979896c7076 100644 --- a/clang/test/Driver/dxc_debug.hlsl +++ b/clang/test/Driver/dxc_debug.hlsl @@ -3,6 +3,7 @@ // RUN: %clang_dxc -Tlib_6_7 -### /Zi /Qembed_debug %s 2>&1 | FileCheck %s -check-prefixes=CHECK,CHECK-EMBED // RUN: %clang_dxc -Tlib_6_7 -### -Zi %s 2>&1 | FileCheck %s // RUN: %clang_dxc -Tlib_6_7 -### -Zi -Qembed_debug %s 2>&1 | FileCheck %s -check-prefixes=CHECK,CHECK-EMBED +// RUN: %clang_dxc -Tlib_6_7 -### /Zi /Qpdb_in_private %s 2>&1 | FileCheck %s -check-prefixes=CHECK,CHECK-PRIV // RUN: %clang_dxc -Tlib_6_7 -### -Zi /Fd %t.pdb %s 2>&1 | FileCheck %s -check-prefixes=CHECK,CHECK-FD // RUN: %clang_dxc -Tlib_6_7 -### -Zi -Fd=%t.pdb %s 2>&1 | FileCheck %s -check-prefixes=CHECK,CHECK-FD // RUN: %clang_dxc -Tlib_6_7 -### -Zi -Zss %s 2>&1 | FileCheck %s --check-prefix=CHECK,CHECK-ZSS @@ -19,6 +20,7 @@ // Check that the flags are converted to their llc equivalents. // CHECK-EMBED-SAME: --dx-embed-debug // CHECK-FD-SAME: --dx-Fd= +// CHECK-PRIV-SAME: --dx-pdb-in-private // CHECK-ZSS-SAME: -dx-Zss // Make sure dxc command line arguments are passed to clang invocation. // CHECK-SAME: -fdx-record-command-line diff --git a/clang/test/Driver/dxc_section_emission.hlsl b/clang/test/Driver/dxc_section_emission.hlsl index b27232f6b7d27..be8081e884c78 100644 --- a/clang/test/Driver/dxc_section_emission.hlsl +++ b/clang/test/Driver/dxc_section_emission.hlsl @@ -22,4 +22,15 @@ // CHECK: - Name: ILDN +// Check that /Qpdb_in_private emits a PRIV part in the output container. +// RUN: %clang_dxc -Tlib_6_7 /Fo %t-priv.dxbc /Zi /Qpdb_in_private %s 2>&1 +// RUN: obj2yaml %t-priv.dxbc | FileCheck %s --check-prefix=CHECK-PRIV + +// Without /Qpdb_in_private, PRIV is not emitted. +// RUN: %clang_dxc -Tlib_6_7 /Fo %t-no-priv.dxbc /Zi %s 2>&1 +// RUN: obj2yaml %t-no-priv.dxbc | FileCheck %s --check-prefix=CHECK-NO-PRIV + +// CHECK-PRIV: - Name: PRIV +// CHECK-NO-PRIV-NOT: - Name: PRIV + [numthreads(1, 1, 1)] void main() {} diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def index 419e78c8a87d4..a6f8aaad6487f 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def +++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def @@ -3,6 +3,7 @@ CONTAINER_PART(DXIL) CONTAINER_PART(ILDB) CONTAINER_PART(ILDN) +CONTAINER_PART(PRIV) CONTAINER_PART(SFI0) CONTAINER_PART(SRCI) CONTAINER_PART(HASH) diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h index ce3b9bc94ba97..545e8930f1458 100644 --- a/llvm/include/llvm/Object/DXContainer.h +++ b/llvm/include/llvm/Object/DXContainer.h @@ -480,6 +480,7 @@ class DXContainer { std::optional<mcdxbc::DebugName> DebugName; std::optional<mcdxbc::CompilerVersion> VersionInfo; std::optional<mcdxbc::SourceInfo> SourceInfo; + std::optional<StringRef> PrivateData; Error parseHeader(); Error parsePartOffsets(); @@ -492,6 +493,7 @@ class DXContainer { Error parseSignature(StringRef Part, DirectX::Signature &Array); Error parseCompilerVersionInfo(StringRef Part); Error parseSourceInfo(StringRef Part); + Error parsePrivateData(StringRef Part); friend class PartIterator; public: @@ -613,6 +615,8 @@ class DXContainer { const std::optional<mcdxbc::SourceInfo> &getSourceInfo() const { return SourceInfo; } + + const std::optional<StringRef> &getPrivateData() const { return PrivateData; } }; class LLVM_ABI DXContainerObjectFile : public ObjectFile { diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h index 29f6b9bcae000..1d3e044bbb22f 100644 --- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h +++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h @@ -401,6 +401,7 @@ struct Part { std::optional<DXContainerYAML::DebugName> DebugName; std::optional<DXContainerYAML::CompilerVersion> CompilerVersion; std::optional<DXContainerYAML::SourceInfo> SourceInfo; + std::optional<std::vector<llvm::yaml::Hex8>> PrivateData; }; struct Object { diff --git a/llvm/lib/MC/MCDXContainerWriter.cpp b/llvm/lib/MC/MCDXContainerWriter.cpp index 994b90fbcb66b..f5cedf0b542b0 100644 --- a/llvm/lib/MC/MCDXContainerWriter.cpp +++ b/llvm/lib/MC/MCDXContainerWriter.cpp @@ -34,14 +34,22 @@ void MCDXContainerBaseWriter::write(raw_ostream &OS, const Triple &TT) { // 16 part offsets gives us a little room for growth. llvm::SmallVector<uint64_t, 16> PartOffsets; uint64_t PartOffset = 0; + bool HasPrivate = false; for (const MCDXContainerPart &Part : Parts) { + if (HasPrivate) + reportFatalInternalError( + "PRIV must be the last section in a DXContainer"); + if (Part.Name == "PRIV") + HasPrivate = true; + uint64_t SectionSize = Part.Data.size(); assert(SectionSize < std::numeric_limits<uint32_t>::max() && "Section size too large for DXContainer"); PartOffsets.push_back(PartOffset); PartOffset += sizeof(dxbc::PartHeader) + SectionSize; - PartOffset = alignTo(PartOffset, Align(4ul)); + if (!HasPrivate) + PartOffset = alignTo(PartOffset, Align(4ul)); // The DXIL part also writes a program header, so we need to include its // size when computing the offset for a part after the DXIL part. if (dxbc::isProgramPart(Part.Name)) @@ -81,8 +89,10 @@ void MCDXContainerBaseWriter::write(raw_ostream &OS, const Triple &TT) { if (dxbc::isProgramPart(Part.Name)) PartSize += sizeof(dxbc::ProgramHeader); - // DXContainer parts should be 4-byte aligned. - PartSize = alignTo(PartSize, Align(4)); + // DXContainer part should be 4-byte aligned, unless it is PRIV part. + bool IsPrivate = Part.Name == "PRIV"; + if (!IsPrivate) + PartSize = alignTo(PartSize, Align(4)); W.write<uint32_t>(static_cast<uint32_t>(PartSize)); if (dxbc::isProgramPart(Part.Name)) { dxbc::ProgramHeader Header; @@ -112,8 +122,10 @@ void MCDXContainerBaseWriter::write(raw_ostream &OS, const Triple &TT) { sizeof(dxbc::ProgramHeader))); } W.write<char>(Part.Data); - unsigned Size = W.OS.tell() - Start; - W.OS.write_zeros(offsetToAlignment(Size, Align(4))); + if (!IsPrivate) { + unsigned Size = W.OS.tell() - Start; + W.OS.write_zeros(offsetToAlignment(Size, Align(4))); + } } } diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp index 52d3c3780bf71..947a0f32776d5 100644 --- a/llvm/lib/Object/DXContainer.cpp +++ b/llvm/lib/Object/DXContainer.cpp @@ -127,6 +127,13 @@ Error DXContainer::parseDebugName(StringRef Part) { return Error::success(); } +Error DXContainer::parsePrivateData(StringRef Part) { + if (PrivateData) + return parseFailed("more than one PRIV part is present in the file"); + PrivateData.emplace(Part); + return Error::success(); +} + Error DXContainer::parseShaderFeatureFlags(StringRef Part) { if (ShaderFeatureFlags) return parseFailed("More than one SFI0 part is present in the file"); @@ -536,6 +543,9 @@ Error DXContainer::parsePartOffsets() { sizeof(dxbc::Header) + (Header.PartCount * sizeof(uint32_t)); const char *Current = Data.getBuffer().data() + sizeof(dxbc::Header); for (uint32_t Part = 0; Part < Header.PartCount; ++Part) { + if (PrivateData) + return parseFailed("PRIV must be the last section in a DXContainer"); + uint32_t PartOffset; if (Error Err = readInteger(Data.getBuffer(), Current, PartOffset)) return Err; @@ -577,6 +587,10 @@ Error DXContainer::parsePartOffsets() { if (Error Err = parseDebugName(PartData)) return Err; break; + case dxbc::PartType::PRIV: + if (Error Err = parsePrivateData(PartData)) + return Err; + break; case dxbc::PartType::SFI0: if (Error Err = parseShaderFeatureFlags(PartData)) return Err; diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp index ff43eb71d57c7..5b0639a012e12 100644 --- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp +++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp @@ -125,9 +125,15 @@ assignSectionHeader(dxbc::SourceInfo::SectionHeader &Dst, } Error DXContainerWriter::writeParts(raw_ostream &OS) { + bool HasPrivate = false; uint32_t RollingOffset = sizeof(dxbc::Header) + (ObjectFile.Header.PartCount * sizeof(uint32_t)); for (auto I : llvm::zip(ObjectFile.Parts, *ObjectFile.Header.PartOffsets)) { + if (HasPrivate) + return createStringError( + errc::invalid_argument, + "PRIV must be the last section in a DXContainer"); + if (RollingOffset < std::get<1>(I)) { uint32_t PadBytes = std::get<1>(I) - RollingOffset; OS.write_zeros(PadBytes); @@ -205,6 +211,15 @@ Error DXContainerWriter::writeParts(raw_ostream &OS) { DebugName.write(OS); break; } + case dxbc::PartType::PRIV: { + if (!P.PrivateData) + continue; + + HasPrivate = true; + OS.write(reinterpret_cast<char *>(P.PrivateData->data()), + P.PrivateData->size()); + break; + } case dxbc::PartType::SFI0: { // If we don't have any flags we can continue here and the data will be // zeroed out. diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp index ba766dfffd91d..1671ec2afed9b 100644 --- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp +++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp @@ -567,6 +567,7 @@ void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO, IO.mapOptional("DebugName", P.DebugName); IO.mapOptional("CompilerVersion", P.CompilerVersion); IO.mapOptional("SourceInfo", P.SourceInfo); + IO.mapOptional("PrivateData", P.PrivateData); } void MappingTraits<DXContainerYAML::Object>::mapping( @@ -981,6 +982,14 @@ DXContainerYAML::fromDXContainer(object::DXContainer &Container) { DebugName->Filename.str()}; break; } + case dxbc::PartType::PRIV: { + std::optional<StringRef> PrivateData = Container.getPrivateData(); + assert(PrivateData && "Since we are iterating and found a PRIV part, " + "this should never not have a value"); + NewPart.PrivateData.emplace(PrivateData->data(), + PrivateData->data() + PrivateData->size()); + break; + } case dxbc::PartType::SFI0: { std::optional<uint64_t> Flags = Container.getShaderFeatureFlags(); // Omit the flags in the YAML if they are missing or zero. diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp index 16facaf13b96b..fb72e8d96949c 100644 --- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp +++ b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp @@ -46,6 +46,8 @@ cl::opt<std::string> PdbDebugPath( cl::desc("Write debug information to the given file, or automatically " "named file in directory when ending in '/'"), cl::value_desc("filename")); +cl::opt<bool> PdbInPrivate("dx-pdb-in-private", + cl::desc("Store PDB in private user data")); namespace { class DXContainerGlobals : public llvm::ModulePass { @@ -162,22 +164,25 @@ void DXContainerGlobals::computeShaderHashAndDebugName( SmallString<40> DebugNameStr; Digest.stringifyResult(MD5, DebugNameStr); DebugNameStr += ".pdb"; - if (!PdbDebugPath.empty()) { - StringRef DebugFile = PdbDebugPath.getValue(); - SmallString<256> AbsoluteDebugName; - if (sys::path::is_separator(DebugFile.back())) { - // If /Fd was specified as a directory, put the MD5.pdb file there. - AbsoluteDebugName = DebugFile; - sys::path::append(AbsoluteDebugName, DebugNameStr); - } else { - // Otherwise, use /Fd value as a user-provided PDB file name. - DebugNameStr = DebugFile; - AbsoluteDebugName = DebugNameStr; + if (!PdbDebugPath.empty() || PdbInPrivate) { + if (!PdbDebugPath.empty()) { + StringRef DebugFile = PdbDebugPath.getValue(); + SmallString<256> AbsoluteDebugName; + if (sys::path::is_separator(DebugFile.back())) { + // If /Fd was specified as a directory, put the MD5.pdb file there. + AbsoluteDebugName = DebugFile; + sys::path::append(AbsoluteDebugName, DebugNameStr); + } else { + // Otherwise, use /Fd value as a user-provided PDB file name. + DebugNameStr = DebugFile; + AbsoluteDebugName = DebugNameStr; + } + + // Pass PDB name to DXContainerPDBPass via PDBNAME section. + addSection(M, Globals, AbsoluteDebugName, "dx.pdb.name", + PdbFileNameSectionName); } - // Pass PDB name to DXContainerPDBPass via PDBNAME section. - addSection(M, Globals, AbsoluteDebugName, "dx.pdb.name", - PdbFileNameSectionName); // Pass module hash to DXContainerPDBPass. Globals.emplace_back(buildContainerGlobal( M, ConstantDataArray::get(M.getContext(), ArrayRef(HashData.Digest)), diff --git a/llvm/lib/Target/DirectX/DXContainerPDB.cpp b/llvm/lib/Target/DirectX/DXContainerPDB.cpp index 49fb9f4b290fb..a90be89c54699 100644 --- a/llvm/lib/Target/DirectX/DXContainerPDB.cpp +++ b/llvm/lib/Target/DirectX/DXContainerPDB.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "DirectX.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringSet.h" #include "llvm/BinaryFormat/DXContainer.h" #include "llvm/DebugInfo/CodeView/GUID.h" @@ -17,9 +18,14 @@ #include "llvm/IR/Module.h" #include "llvm/MC/MCDXContainerWriter.h" #include "llvm/Pass.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Transforms/Utils/ModuleUtils.h" using namespace llvm; +extern cl::opt<bool> PdbInPrivate; + namespace { class DXContainerPDB : public ModulePass, MCDXContainerBaseWriter { @@ -84,10 +90,22 @@ ArrayRef<MCDXContainerPart> DXContainerPDB::collectParts() { return Parts; } +static GlobalVariable *createPrivateDataGlobal(Module &M, StringRef Data) { + Constant *Content = + ConstantDataArray::getString(M.getContext(), Data, /*AddNull*/ false); + auto *GV = + new GlobalVariable(M, Content->getType(), true, + GlobalValue::PrivateLinkage, Content, "dx.priv"); + GV->setSection("PRIV"); + GV->setAlignment(Align(1)); + return GV; +} + bool DXContainerPDB::runOnModule(Module &M) { + llvm::scope_exit Cleanup([&]() { reset(); }); this->M = &M; - StringRef DebugFileName; + SmallString<128> DebugFileName; ArrayRef<char> ModuleHash; for (const GlobalVariable &GV : M.globals()) { if (GV.getSection() == PdbFileNameSectionName) { @@ -101,11 +119,23 @@ bool DXContainerPDB::runOnModule(Module &M) { } // PDB emission was not requested. - if (DebugFileName.empty()) + if (DebugFileName.empty() && !PdbInPrivate) return false; if (ModuleHash.empty()) report_fatal_error("Module hash for PDB not found"); + bool DeleteAfterRead = false; + if (DebugFileName.empty()) { + if (std::error_code EC = + sys::fs::createTemporaryFile("dxil", "pdb", DebugFileName)) + reportFatalInternalError("Failed to create temporary PDB file"); + DeleteAfterRead = true; + } + llvm::scope_exit FileCleanup([&]() { + if (DeleteAfterRead) + sys::fs::remove(DebugFileName); + }); + BumpPtrAllocator Allocator; pdb::PDBFileBuilder Builder(Allocator); @@ -148,9 +178,17 @@ bool DXContainerPDB::runOnModule(Module &M) { reportFatalUsageError("Couldn't write to PDB file: " + Twine(toString(std::move(Err)))); - reset(); + if (!PdbInPrivate) + return false; + + ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getFile( + DebugFileName, /*IsText=*/false, /*RequiresNullTerminator=*/false); + if (!Buf) + reportFatalInternalError("Failed to read PDB for PRIV embedding"); + + appendToCompilerUsed(M, createPrivateDataGlobal(M, (*Buf)->getBuffer())); - return false; + return true; } char DXContainerPDB::ID = 0; diff --git a/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-fd.test b/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-fd.test new file mode 100644 index 0000000000000..dd9efe0c070af --- /dev/null +++ b/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-fd.test @@ -0,0 +1,17 @@ +## Check that --dx-pdb-in-private generates a PDB in PRIV without --dx-Fd. + +# RUN: llc %S/Inputs/SourceInfo.ll --filetype=obj -o %t.dxbc --dx-pdb-in-private +# RUN: obj2yaml %t.dxbc | FileCheck %s +# RUN: llvm-objcopy --dump-section=PRIV=%t.priv %t.dxbc +# RUN: llvm-pdbutil pdb2yaml --dxcontainer %t.priv | FileCheck %s --check-prefix=PDB + +# CHECK: - Name: PRIV +# CHECK-NEXT: Size: + +# PDB: PartCount: 5 +# PDB: Parts: +# PDB-DAG: - Name: ILDB +# PDB-DAG: - Name: HASH +# PDB-DAG: - Name: ILDN +# PDB-DAG: - Name: VERS +# PDB-DAG: - Name: SRCI diff --git a/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-flag.test b/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-flag.test new file mode 100644 index 0000000000000..4a185ed7842dd --- /dev/null +++ b/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-flag.test @@ -0,0 +1,5 @@ +## Check that PRIV is not emitted unless --dx-pdb-in-private is specified. + +# RUN: llc %S/Inputs/SourceInfo.ll --filetype=obj -o - | obj2yaml | FileCheck %s --implicit-check-not='PRIV' + +# CHECK: - Name: DXIL diff --git a/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-pdbname.ll b/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-pdbname.ll new file mode 100644 index 0000000000000..f07d19416b267 --- /dev/null +++ b/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate-no-pdbname.ll @@ -0,0 +1,10 @@ +;; Check that dxil-pdb can emit PRIV using a temporary PDB when PDBNAME is absent. +; RUN: opt %s -dxil-pdb --dx-pdb-in-private -S -o - | FileCheck %s + +;; CHECK: @dx.priv = private constant {{.*}} section "PRIV" + +target triple = "dxilv1.3-pc-shadermodel6.3-library" + [email protected] = private constant [4 x i8] c"BC\C0\DE", section "ILDB", align 4 [email protected] = private constant [16 x i8] c"dummymodulehash!", section "PDBHASH", align 4 [email protected] = appending global [2 x ptr] [ptr @dx.ildb, ptr @dx.pdb.hash], section "llvm.metadata" diff --git a/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate.ll b/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate.ll new file mode 100644 index 0000000000000..7edc3fd8918d1 --- /dev/null +++ b/llvm/test/CodeGen/DirectX/ContainerData/PdbInPrivate.ll @@ -0,0 +1,18 @@ +; RUN: opt %s -dxil-pdb --dx-pdb-in-private -S -o - | FileCheck %s --check-prefix=CHECK-IR +; RUN: opt %s -dxil-pdb --dx-pdb-in-private -o /dev/null +; RUN: llvm-pdbutil pdb2yaml --dxco... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/204903 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
