27#define DEBUG_TYPE "dwarfdebug"
33std::optional<DbgVariableLocation>
43 Location.FragmentInfo.reset();
59 switch (
Op->getOp()) {
60 case dwarf::DW_OP_constu: {
64 switch (
Op->getOp()) {
65 case dwarf::DW_OP_minus:
68 case dwarf::DW_OP_plus:
76 case dwarf::DW_OP_plus_uconst:
80 Location.FragmentInfo = {
Op->getArg(1),
Op->getArg(0)};
82 case dwarf::DW_OP_deref:
83 Location.LoadChain.push_back(
Offset);
96 Location.LoadChain.push_back(
Offset);
106 if (M->debug_compile_units().empty())
117 while (!WorkList.
empty()) {
121 if (!Children.empty())
122 WorkList.
append(Children.begin(), Children.end());
128 assert(R.first &&
"InsnRange does not have first instruction!");
129 assert(R.second &&
"InsnRange does not have second instruction!");
139 assert(Label &&
"Didn't insert label before instruction");
152 unsigned Tag = Ty->getTag();
154 if (
Tag != dwarf::DW_TAG_member &&
Tag != dwarf::DW_TAG_typedef &&
155 Tag != dwarf::DW_TAG_const_type &&
Tag != dwarf::DW_TAG_volatile_type &&
156 Tag != dwarf::DW_TAG_restrict_type &&
Tag != dwarf::DW_TAG_atomic_type &&
157 Tag != dwarf::DW_TAG_immutable_type &&
158 Tag != dwarf::DW_TAG_template_alias)
159 return Ty->getSizeInBits();
173 if (
BaseType->getTag() == dwarf::DW_TAG_reference_type ||
174 BaseType->getTag() == dwarf::DW_TAG_rvalue_reference_type)
175 return Ty->getSizeInBits();
192 Ty = SRTy->getBaseType();
198 if (CTy->getTag() == dwarf::DW_TAG_enumeration_type) {
199 if (!(Ty = CTy->getBaseType()))
216 if (
T == dwarf::DW_TAG_pointer_type ||
217 T == dwarf::DW_TAG_ptr_to_member_type ||
218 T == dwarf::DW_TAG_reference_type ||
219 T == dwarf::DW_TAG_rvalue_reference_type)
221 assert(
T == dwarf::DW_TAG_typedef ||
T == dwarf::DW_TAG_const_type ||
222 T == dwarf::DW_TAG_volatile_type ||
223 T == dwarf::DW_TAG_restrict_type ||
T == dwarf::DW_TAG_atomic_type ||
224 T == dwarf::DW_TAG_immutable_type ||
225 T == dwarf::DW_TAG_template_alias);
226 assert(DTy->getBaseType() &&
"Expected valid base type");
231 unsigned Encoding = BTy->getEncoding();
232 assert((Encoding == dwarf::DW_ATE_unsigned ||
233 Encoding == dwarf::DW_ATE_unsigned_char ||
234 Encoding == dwarf::DW_ATE_signed ||
235 Encoding == dwarf::DW_ATE_signed_char ||
236 Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF ||
237 Encoding == dwarf::DW_ATE_boolean ||
238 Encoding == dwarf::DW_ATE_complex_float ||
239 Encoding == dwarf::DW_ATE_signed_fixed ||
240 Encoding == dwarf::DW_ATE_unsigned_fixed ||
241 (Ty->getTag() == dwarf::DW_TAG_unspecified_type &&
242 Ty->getName() ==
"decltype(nullptr)")) &&
243 "Unsupported encoding");
244 return Encoding == dwarf::DW_ATE_unsigned ||
245 Encoding == dwarf::DW_ATE_unsigned_char ||
246 Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean ||
247 Encoding == llvm::dwarf::DW_ATE_unsigned_fixed ||
248 Ty->getTag() == dwarf::DW_TAG_unspecified_type;
256 auto EK = SP->getUnit()->getEmissionKind();
286 InstOrdering.initialize(*MF);
293 const auto &Entries =
I.second;
299 [](
auto &MO) { return MO.isReg() && MO.getReg(); });
312 Entries.front().getInstr()->getDebugVariable();
315 if (!IsDescribedByReg(Entries.front().getInstr()))
317 if (Entries.front().getInstr()->getDebugExpression()->isFragment()) {
319 for (
const auto *
I = Entries.begin();
I != Entries.end(); ++
I) {
320 if (!
I->isDbgValue())
322 const DIExpression *Fragment =
I->getInstr()->getDebugExpression();
323 if (std::any_of(Entries.begin(),
I,
325 return Pred.isDbgValue() &&
326 Fragment->fragmentsOverlap(
327 Pred.getInstr()->getDebugExpression());
334 if (IsDescribedByReg(
I->getInstr()))
341 for (
const auto &Entry : Entries) {
342 if (Entry.isDbgValue())
361 if (!
Asm || !
Asm->hasDebugInfo())
387 if (!
Asm || !
Asm->hasDebugInfo())
393 if (!
CurMI->isMetaInstruction()) {
411 if (
CurMI->getParent()->isEndSection() &&
CurMI->getNextNode() ==
nullptr) {
428 InstOrdering.clear();
433 if (!
MBB.isEntryBlock())
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static cl::opt< bool > TrimVarLocs("trim-var-locs", cl::Hidden, cl::init(true))
If true, we drop variable location ranges which exist entirely outside the variable's lexical scope i...
static bool hasDebugInfo(const MachineFunction *MF)
Module.h This file contains the declarations for the Module class.
This class is intended to be used as a driving class for all asm writers.
expr_op_iterator expr_op_begin() const
Visit the elements via ExprOperand wrappers.
expr_op_iterator expr_op_end() const
DILocalScope * getScope() const
Get the local scope for this variable.
Specifies a change in a variable's debug value history.
static bool isUnsignedDIType(const DIType *Ty)
Return true if type encoding is unsigned.
const MachineInstr * CurMI
If nonnull, stores the current machine instruction we're processing.
AsmPrinter * Asm
Target of debug info emission.
virtual void endFunctionImpl(const MachineFunction *MF)=0
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
MachineModuleInfo * MMI
Collected machine module information.
void endBasicBlockSection(const MachineBasicBlock &MBB) override
Process the end of a basic-block-section within a function.
void identifyScopeMarkers()
Indentify instructions that are marking the beginning of or ending of a scope.
virtual void skippedNonDebugFunction()
void endFunction(const MachineFunction *MF) override
Gather post-function debug information.
DebugLoc PrevInstLoc
Previous instruction's location information.
void beginFunction(const MachineFunction *MF) override
Gather pre-function debug information.
void endInstruction() override
Process end of an instruction.
virtual ~DebugHandlerBase() override
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
DebugHandlerBase(AsmPrinter *A)
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
const MachineBasicBlock * PrevInstBB
virtual void beginFunctionImpl(const MachineFunction *MF)=0
void requestLabelAfterInsn(const MachineInstr *MI)
Ensure that a label will be emitted after MI.
void beginBasicBlockSection(const MachineBasicBlock &MBB) override
Process the beginning of a new basic-block-section within a function.
DbgValueHistoryMap DbgValues
History of DBG_VALUE and clobber instructions for each user variable.
DbgLabelInstrMap DbgLabels
Mapping of inlined labels and DBG_LABEL machine instruction.
DenseMap< const MachineInstr *, MCSymbol * > LabelsBeforeInsn
Maps instruction with label emitted before instruction.
void beginModule(Module *M) override
DenseMap< const MachineInstr *, MCSymbol * > LabelsAfterInsn
Maps instruction with label emitted after instruction.
void requestLabelBeforeInsn(const MachineInstr *MI)
Ensure that a label will be emitted before MI.
const MachineBasicBlock * EpilogBeginBlock
This block includes epilogue instructions.
static uint64_t getBaseTypeSize(const DIType *Ty)
If this type is derived from a base type then return base type size.
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
DISubprogram * getSubprogram() const
Get the attached subprogram.
LexicalScope - This class is used to track scope information.
SmallVectorImpl< LexicalScope * > & getChildren()
SmallVectorImpl< InsnRange > & getRanges()
bool isAbstractScope() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
A Module instance is used to store all the information related to an LLVM module.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
initializer< Ty > init(const Ty &Val)
@ DW_OP_LLVM_fragment
Only used in LLVM metadata.
@ DW_OP_LLVM_arg
Only used in LLVM metadata.
This is an optimization pass for GlobalISel generic memory operations.
void calculateDbgEntityHistory(const MachineFunction *MF, const TargetRegisterInfo *TRI, DbgValueHistoryMap &DbgValues, DbgLabelInstrMap &DbgLabels)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
std::pair< const MachineInstr *, const MachineInstr * > InsnRange
InsnRange - This is used to track range of instructions with identical lexical scope.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
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...
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Represents the location at which a variable is stored.
static std::optional< DbgVariableLocation > extractFromMachineInstruction(const MachineInstr &Instruction)
Extract a VariableLocation from a MachineInstr.
MCRegister Register
Base register.