13#include "llvm/IR/IntrinsicsDirectX.h"
17#define DEBUG_TYPE "dx-debug-info"
30 Constant *ZeroOffset = ConstantInt::get(Int64Ty, 0);
46 Function *
F = getDeclarationIfExists(&M, Intrinsic::dbg_value);
54 {FT->getParamType(0), Int64Ty, FT->getParamType(1), FT->getParamType(2)},
60 for (
User *U :
F->users()) {
75 DL->eraseFromParent();
86 [](
Metadata *M) { return isa<DILabel>(M); }),
88 SP->replaceRetainedNodes(
MDTuple::get(M.getContext(), MDs));
106 M.getContext(), Lang,
CU->getFile(),
CU->getProducer(),
107 CU->isOptimized(),
CU->getFlags(),
CU->getRuntimeVersion(),
108 CU->getSplitDebugFilename(),
CU->getEmissionKind(),
109 CU->getEnumTypes(),
CU->getRetainedTypes(),
CU->getGlobalVariables(),
110 CU->getImportedEntities(),
CU->getMacros(),
CU->getDWOId(),
111 CU->getSplitDebugInlining(),
CU->getDebugInfoForProfiling(),
112 CU->getNameTableKind(),
CU->getRangesBaseAddress(),
CU->getSysRoot(),
118 std::vector<std::pair<const DICompileUnit *, const Metadata *>> CUSubprograms;
130 static constexpr auto SupportedDIFlags =
132 static constexpr auto SupportedDISPFlags =
134 if (SP->isDistinct() || SP->getFlags() & ~SupportedDIFlags ||
135 SP->getSPFlags() & ~SupportedDISPFlags) {
137 M.getContext(), SP->getScope(), SP->getName(), SP->getLinkageName(),
138 SP->getFile(), SP->getLine(), SP->getType(), SP->getScopeLine(),
139 SP->getContainingType(), SP->getVirtualIndex(),
140 SP->getThisAdjustment(), SP->getFlags() & SupportedDIFlags,
141 SP->getSPFlags() & SupportedDISPFlags, SP->getUnit(),
142 SP->getTemplateParams(), SP->getDeclaration(), SP->getRetainedNodes(),
143 SP->getThrownTypes(), SP->getAnnotations(), SP->getTargetFuncName(),
144 SP->getKeyInstructionsEnabled());
149 const Metadata *FunctionMD = It->second;
156 CUSubprograms.push_back(
157 {SP->getUnit(),
static_cast<const Metadata *
>(SP)});
161 CUSubprograms.begin(), CUSubprograms.end(), [](
auto &&
A,
auto &&
B) {
162 return std::less<const DICompileUnit *>()(A.first, B.first);
164 for (
auto It = CUSubprograms.begin(), End = CUSubprograms.end(); It != End;) {
171 }
while (++It != End && It->first ==
CU);
172 const auto *SubprogramsMD =
MDTuple::get(M.getContext(), Subprograms);
181 SR->getContext(), dwarf::DW_TAG_base_type, SR->getName(),
182 SR->getSizeInBits(), SR->getAlignInBits(), dwarf::DW_ATE_unsigned,
183 SR->getNumExtraInhabitants(), 0, SR->getFlags());
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static void replaceDbgVariableIntr(DbgVariableIntrinsic *DVI, Function *NewF, DXILDebugInfoMap &Res)
static void replaceDbgValue(Module &M, DXILDebugInfoMap &Res)
This file contains constants used for implementing Dwarf debug support.
Module.h This file contains the declarations for the Module class.
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
void setTailCall(bool IsTc=true)
This is an important base class in LLVM.
Wrapper structure that holds source language identity metadata that includes language name,...
uint32_t getVersion() const
Returns language version. Only valid for versioned language names.
bool hasVersionedName() const
uint16_t getName() const
Returns a versioned or unversioned language name.
Subprogram description. Uses SubclassData1.
DISPFlags
Debug info subprogram flags.
This is the common base class for debug info intrinsics for variables.
Utility to find all debug info in a module.
LLVM_ABI void processModule(const Module &M)
Process entire module and collect debug info anchors.
LLVM_ABI void reset()
Clear all lists.
iterator_range< subprogram_iterator > subprograms() const
iterator_range< type_iterator > types() const
iterator_range< compile_unit_iterator > compile_units() const
iterator find(const_arg_type_t< KeyT > Val)
bool erase(const KeyT &Val)
ValueT lookup_or(const_arg_type_t< KeyT > Val, U &&Default) const
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
FunctionType * getFunctionType() const
Returns the FunctionType for me.
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
A Module instance is used to store all the information related to an LLVM module.
iterator erase(const_iterator CI)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Value * getOperand(unsigned i) const
LLVM Value Representation.
LLVMContext & getContext() const
All values hold a context through their type.
InstMap InstReplace
Completely replace one instruction with another in ValueEnumerator.
MDMap MDExtra
Enumerate extra metadata when Key is encountered in ValueEnumerator.
FuncMap FuncReplace
Completely replace one function with another in ValueEnumerator.
MDMap MDReplace
Completely replace one metadata with another in ValueEnumerator.
std::optional< SourceLanguage > toDW_LANG(SourceLanguageName name, uint32_t version)
Convert a DWARF 6 pair of language name and version to a DWARF 5 DW_LANG.
DXILDebugInfoMap run(Module &M)
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.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
auto cast_or_null(const Y &Val)
auto reverse(ContainerTy &&C)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.