23#define DEBUG_TYPE "dx-debug-info"
31 bool Modified = M.convertFromNewDbgValues();
45 std::pair<Instruction *, DbgValueInst *>>
54 F.removeFnAttrs(AttrMask);
55 F.removeRetAttrs(AttrMask);
56 for (
unsigned ArgNo = 0; ArgNo !=
F.arg_size(); ++ArgNo)
57 F.removeParamAttrs(ArgNo, AttrMask);
59 bool IsEntryBlock =
true;
60 DbgVariablesSeen.
clear();
64 DbgValueFragments.
clear();
66 I.eraseMetadataIf([](
unsigned KindID,
MDNode *) {
67 return KindID == LLVMContext::MD_DIAssignID;
70 NextNonDebugInst = &
I;
74 DL->eraseFromParent();
91 bool Replace = DV->getIntrinsicID() != Intrinsic::dbg_value;
107 std::pair<Instruction *, DbgValueInst *> &
DbgValue = DbgValues[V];
108 std::pair<Instruction *, DbgValueInst *> &DbgValueFragment =
109 DbgValueFragments[{V,
E}];
113 if (DbgValueFragment.first == NextNonDebugInst) {
114 DV->eraseFromParent();
122 if (DbgValueFragment.second &&
123 DbgValueFragment.second ==
DbgValue.second &&
124 DbgValueFragment.second->getValue() == DV->getValue()) {
136 if (
A.isStringAttribute() ||
137 (
A.getKindAsEnum() != Attribute::NoUnwind &&
138 A.getKindAsEnum() != Attribute::Memory))
144 std::next(DV->getIterator())));
147 DV->eraseFromParent();
152 DbgValue = DbgValueFragment = {NextNonDebugInst, NewDV};
161 if (!DV || DbgVariablesSeen.
contains(DV->getVariable()))
164 DV->eraseFromParent();
168 DbgVariablesSeen.
insert(DV->getVariable());
171 IsEntryBlock =
false;
180 [](
Metadata *M) { return isa<DILabel>(M); }),
182 SP->replaceRetainedNodes(
MDTuple::get(M.getContext(), MDs));
196class DXILDebugInfoLegacy :
public ModulePass {
210char DXILDebugInfoLegacy::ID = 0;
216 return new DXILDebugInfoLegacy();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool lowerDXILDebugInfo(Module &M)
This file defines the DenseSet and SmallDenseSet classes.
This file contains constants used for implementing Dwarf debug support.
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Class recording the (high level) value of a variable.
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
This class stores enough information to efficiently remove some attributes from an existing AttrBuild...
AttributeMask & addAttribute(Attribute::AttrKind Val)
Add an attribute to the mask.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM Basic Block Representation.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
void setTailCall(bool IsTc=true)
Subprogram description. Uses SubclassData1.
This represents the llvm.dbg.value instruction.
Utility to find all debug info in a module.
LLVM_ABI void processModule(const Module &M)
Process entire module and collect debug info anchors.
iterator_range< subprogram_iterator > subprograms() const
Implements a dense probed hash-table based set.
void removeFnAttrs(const AttributeMask &Attrs)
AttributeList getAttributes() const
Return the attribute list for this Function.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
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.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
iterator erase(const_iterator CI)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
const AttributeMask & getNonDXILAttributeMask()
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)
ModulePass * createDXILDebugInfoLegacyPass()
Pass to downgrade debug information to forms supported by DXIL.
auto reverse(ContainerTy &&C)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.