43 DXContainerPDB() : ModulePass(ID) {}
45 StringRef getPassName()
const override {
return "DirectX PDB Emitter"; }
47 bool runOnModule(
Module &M)
override;
49 void getAnalysisUsage(AnalysisUsage &AU)
const override {
53 bool shouldSkipSection(StringRef SectionName,
size_t SectionSize)
override;
65 static const StringSet<> DebugSections{
"ILDB",
"ILDN",
"HASH",
"PDBI",
66 "SRCI",
"STAT",
"RDAT",
"VERS"};
67 return !DebugSections.
contains(SectionName);
72 if (
const auto *
Data =
74 return Data->getRawDataValues();
80 for (
const GlobalVariable &GV :
M->globals()) {
81 StringRef
Name = GV.getSection();
86 if (shouldSkipSection(Name,
Data.size()))
100 GV->setSection(
"PRIV");
101 GV->setAlignment(
Align(1));
105bool DXContainerPDB::runOnModule(
Module &M) {
109 SmallString<128> DebugFileName;
111 for (
const GlobalVariable &GV :
M.globals()) {
113 assert(DebugFileName.
empty() &&
"Duplicate PDBNAME section");
128 bool DeleteAfterRead =
false;
129 if (DebugFileName.
empty()) {
130 if (std::error_code EC =
133 DeleteAfterRead =
true;
144 if (
Error Err = Builder.initialize(512))
149 "First 5 streams should be empty in DirectX PDB file");
151 if (
auto Err = Builder.getMsfBuilder().addStream(0).takeError())
156 if (
auto Err = Builder.getMsfBuilder().addStream(0).takeError())
161 codeview::GUID PdbGuid;
163 "Module hash length must be match GUID length");
166 auto &InfoBuilder = Builder.getInfoBuilder();
167 InfoBuilder.setAge(1);
168 InfoBuilder.setGuid(PdbGuid);
169 InfoBuilder.setSignature(0);
170 InfoBuilder.setVersion(pdb::PdbRaw_ImplVer::PdbImplVC70);
173 raw_svector_ostream OS(*Builder.getDXContainerData());
174 write(OS,
M.getTargetTriple());
179 codeview::GUID IgnoredOutGuid;
180 if (
Error Err = Builder.commit(DebugFileName, &IgnoredOutGuid))
188 DebugFileName,
false,
false);
197char DXContainerPDB::ID = 0;
198INITIALIZE_PASS(DXContainerPDB,
"dxil-pdb",
"DirectX PDB Emitter",
false,
true)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
cl::opt< bool > PdbInPrivate("dx-pdb-in-private", cl::desc("Store PDB in private user data"))
static StringRef getGlobalData(const GlobalVariable &GV)
static GlobalVariable * createPrivateDataGlobal(Module &M, StringRef Data)
ManagedStatic< HTTPClientCleanup > Cleanup
Module.h This file contains the declarations for the Module class.
Machine Check Debug Module
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the scope_exit class, which executes user-defined cleanup logic at scope exit.
StringSet - A set-like wrapper for the StringMap.
void setPreservesAll()
Set by analyses that do not transform their input at all.
static LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true, bool ByteString=false)
This method constructs a CDS and initializes it with a text string.
This is an important base class in LLVM.
@ PrivateLinkage
Like Internal, but omit from symbol table.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
virtual bool shouldSkipSection(StringRef SectionName, size_t SectionSize)
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
void push_back(const T &Elt)
Represent a constant reference to a string, i.e.
bool contains(StringRef key) const
Check if the set contains the given key.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
LLVM_ABI std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None)
Create a file in the system temporary directory.
ScopedSetting scopedDisable()
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
scope_exit(Callable) -> scope_exit< Callable >
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
static constexpr StringLiteral ModuleHashSectionName
Contains module hash.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
ArrayRef(const T &OneElt) -> ArrayRef< T >
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
LLVM_ABI Error write(DWPWriter &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue, Dwarf64StrOffsetsPromotion StrOffsetsOptValue, raw_pwrite_stream *OS=nullptr)
ModulePass * createDXContainerPDBPass()
Pass for emitting DirectX PDB files.
static constexpr StringLiteral PdbFileNameSectionName
Contains PDB output file name.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
This struct is a compact representation of a valid (non-zero power of two) alignment.