Go to the documentation of this file.
52 return dwarf::DW_TAG_skeleton_unit;
54 return dwarf::DW_TAG_compile_unit;
76 bool UseAddrOffsetFormOrExpressions =
80 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
87 : dwarf::DW_FORM_GNU_addr_index,
95 "Addr+offset expressions are only valuable when using debug_addr (to "
96 "reduce relocations) available in DWARFv5 or higher");
127 if (LastFile != File) {
131 File->getSource(), CUID);
147 auto *CB = GVContext ? dyn_cast<DICommonBlock>(GVContext) :
nullptr;
156 assert(SDMDecl->isStaticMember() &&
"Expected static member decl");
160 addDIEEntry(*VariableDIE, dwarf::DW_AT_specification, *VariableSpecDIE);
163 if (GTy != SDMDecl->getBaseType())
169 if (!DisplayName.
empty())
176 addFlag(*VariableDIE, dwarf::DW_AT_external);
183 addFlag(*VariableDIE, dwarf::DW_AT_declaration);
190 addUInt(*VariableDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
204 bool addToAccelTable =
false;
207 std::unique_ptr<DIEDwarfExpression> DwarfExpr;
208 for (
const auto &
GE : GlobalExprs) {
216 if (GlobalExprs.size() == 1 && Expr && Expr->
isConstant()) {
217 addToAccelTable =
true;
220 DIExpression::SignedOrUnsignedConstant::UnsignedConstant ==
228 if (Global && Global->hasDLLImportStorageClass())
232 if (!Global && (!Expr || !Expr->
isConstant()))
235 if (Global && Global->isThreadLocal() &&
240 addToAccelTable =
true;
242 DwarfExpr = std::make_unique<DIEDwarfExpression>(*
Asm, *
this, *Loc);
252 unsigned LocalNVPTXAddressSpace;
258 NVPTXAddressSpace = LocalNVPTXAddressSpace;
261 DwarfExpr->addFragmentOffset(Expr);
268 auto GetPointerSizedFormAndOp = [
this]() {
271 "Add support for other sizes if necessary");
277 ? FormAndOp{dwarf::DW_FORM_data4, dwarf::DW_OP_const4u}
278 : FormAndOp{dwarf::DW_FORM_data8, dwarf::DW_OP_const8u};
280 if (Global->isThreadLocal()) {
287 auto FormAndOp = GetPointerSizedFormAndOp();
289 addUInt(*Loc, dwarf::DW_FORM_data1, FormAndOp.Op);
295 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_const_index);
296 addUInt(*Loc, dwarf::DW_FORM_udata,
300 addUInt(*Loc, dwarf::DW_FORM_data1,
302 : dwarf::DW_OP_form_tls_address);
306 auto FormAndOp = GetPointerSizedFormAndOp();
308 addUInt(*Loc, dwarf::DW_FORM_data1, FormAndOp.Op);
315 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + BaseReg);
317 addSInt(*Loc, dwarf::DW_FORM_sdata, 0);
319 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
329 if (DwarfExpr->isUnknownLocation())
330 DwarfExpr->setMemoryLocationKind();
331 DwarfExpr->addExpression(Expr);
338 const unsigned NVPTX_ADDR_global_space = 5;
339 addUInt(*VariableDIE, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,
340 NVPTXAddressSpace ? *NVPTXAddressSpace : NVPTX_ADDR_global_space);
343 addBlock(*VariableDIE, dwarf::DW_AT_location, DwarfExpr->finalize());
348 if (addToAccelTable) {
380 bool SameAsPrevCU =
this == PrevCU;
386 if (CURanges.empty() || !SameAsPrevCU ||
387 (&CURanges.back().End->getSection() !=
392 CURanges.push_back(Range);
396 CURanges.back().End = Range.
End;
428 assert(Begin &&
"Begin label should not be null!");
429 assert(End &&
"End label should not be null!");
431 assert(End->isDefined() &&
"Invalid end label");
450 BB_List.push_back({R.second.BeginLabel, R.second.EndLabel});
457 addFlag(*SPDie, dwarf::DW_AT_APPLE_omit_frame_ptr);
464 switch (FrameBase.
Kind) {
468 addAddress(*SPDie, dwarf::DW_AT_frame_base, Location);
474 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_call_frame_cfa);
475 addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);
485 auto SPSym = cast<MCSymbolWasm>(
498 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_WASM_location);
501 addLabel(*Loc, dwarf::DW_FORM_data4, SPSym);
509 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
510 addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);
534 DIE &ParentScopeDIE) {
538 auto *
DS =
Scope->getScopeNode();
541 "Only handle inlined subprograms here, use "
542 "constructSubprogramScopeDIE for non-inlined "
546 if (
Scope->getParent() && isa<DISubprogram>(
DS)) {
562 assert(ScopeDIE &&
"Scope DIE should not be null.");
571 HasRangeLists =
true;
578 uint32_t Index = IndexAndList.first;
579 auto &
List = *IndexAndList.second;
587 addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_rnglistx, Index);
605 (Ranges.size() == 1 &&
608 Ranges.front().Begin))) {
619 List.reserve(Ranges.size());
624 const auto *BeginMBB = R.first->getParent();
625 const auto *EndMBB = R.second->getParent();
627 const auto *
MBB = BeginMBB;
639 : MBBSectionRange.BeginLabel,
654 auto *
DS =
Scope->getScopeNode();
658 DIE *OriginDIE = getAbstractSPDies()[InlinedSP];
659 assert(OriginDIE &&
"Unable to find original DIE for an inlined subprogram.");
662 addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *OriginDIE);
670 addUInt(*ScopeDIE, dwarf::DW_AT_call_line,
None, IA->getLine());
672 addUInt(*ScopeDIE, dwarf::DW_AT_call_column,
None, IA->getColumn());
674 addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator,
None,
675 IA->getDiscriminator());
691 if (
Scope->isAbstractScope())
701 auto D = constructVariableDIEImpl(DV, Abstract);
710 DL.setDIE(*LabelDie);
712 if (
Scope.isAbstractScope())
718 DIE *DwarfCompileUnit::constructVariableDIEImpl(
const DbgVariable &DV,
736 addUInt(*VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
743 if (!DVal->isVariadic()) {
745 if (Entry->isLocation()) {
747 }
else if (Entry->isInt()) {
749 if (Expr && Expr->getNumElements()) {
753 DwarfExpr.addFragmentOffset(Expr);
754 DwarfExpr.addUnsignedConstant(Entry->getInt());
755 DwarfExpr.addExpression(Expr);
756 addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
757 if (DwarfExpr.TagOffset)
758 addUInt(*VariableDie, dwarf::DW_AT_LLVM_tag_offset,
759 dwarf::DW_FORM_data1, *DwarfExpr.TagOffset);
762 }
else if (Entry->isConstantFP()) {
764 }
else if (Entry->isConstantInt()) {
766 }
else if (Entry->isTargetIndexLocation()) {
772 addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
779 return Entry.isLocation() && !Entry.getLoc().getReg();
783 assert(Expr &&
"Variadic Debug Value must have an Expression.");
786 DwarfExpr.addFragmentOffset(Expr);
792 if (Entry.isLocation()) {
793 if (!DwarfExpr.addMachineRegExpression(
TRI, Cursor,
794 Entry.getLoc().getReg()))
796 }
else if (Entry.isInt()) {
798 DwarfExpr.addUnsignedConstant(Entry.getInt());
799 }
else if (Entry.isConstantFP()) {
804 APInt RawBytes = Entry.getConstantFP()->getValueAPF().bitcastToAPInt();
808 }
else if (Entry.isConstantInt()) {
809 APInt RawBytes = Entry.getConstantInt()->getValue();
813 }
else if (Entry.isTargetIndexLocation()) {
825 if (!DwarfExpr.addExpression(
828 return AddEntry(DVal->getLocEntries()[Idx], Cursor);
833 addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
834 if (DwarfExpr.TagOffset)
835 addUInt(*VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
836 *DwarfExpr.TagOffset);
854 DwarfExpr.addFragmentOffset(Expr);
866 unsigned LocalNVPTXAddressSpace;
872 NVPTXAddressSpace = LocalNVPTXAddressSpace;
878 DwarfExpr.setMemoryLocationKind();
882 DwarfExpr.addMachineRegExpression(
884 DwarfExpr.addExpression(
std::move(Cursor));
891 const unsigned NVPTX_ADDR_local_space = 6;
892 addUInt(*VariableDie, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,
893 NVPTXAddressSpace ? *NVPTXAddressSpace : NVPTX_ADDR_local_space);
895 addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
896 if (DwarfExpr.TagOffset)
897 addUInt(*VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
898 *DwarfExpr.TagOffset);
905 DIE *&ObjectPointer) {
915 auto *Array = dyn_cast<DICompositeType>(Var->
getType());
916 if (!Array || Array->getTag() != dwarf::DW_TAG_array_type)
918 if (
auto *DLVar = Array->getDataLocation())
919 Result.push_back(DLVar);
920 if (
auto *AsVar = Array->getAssociated())
921 Result.push_back(AsVar);
922 if (
auto *AlVar = Array->getAllocated())
923 Result.push_back(AlVar);
924 for (
auto *El : Array->getElements()) {
925 if (
auto *Subrange = dyn_cast<DISubrange>(El)) {
926 if (
auto Count = Subrange->getCount())
927 if (
auto *Dependency = Count.dyn_cast<
DIVariable *>())
928 Result.push_back(Dependency);
929 if (
auto LB = Subrange->getLowerBound())
930 if (
auto *Dependency = LB.dyn_cast<
DIVariable *>())
931 Result.push_back(Dependency);
932 if (
auto UB = Subrange->getUpperBound())
933 if (
auto *Dependency = UB.dyn_cast<
DIVariable *>())
934 Result.push_back(Dependency);
935 if (
auto ST = Subrange->getStride())
937 Result.push_back(Dependency);
938 }
else if (
auto *GenericSubrange = dyn_cast<DIGenericSubrange>(El)) {
939 if (
auto Count = GenericSubrange->getCount())
940 if (
auto *Dependency = Count.dyn_cast<
DIVariable *>())
941 Result.push_back(Dependency);
942 if (
auto LB = GenericSubrange->getLowerBound())
943 if (
auto *Dependency = LB.dyn_cast<
DIVariable *>())
944 Result.push_back(Dependency);
945 if (
auto UB = GenericSubrange->getUpperBound())
946 if (
auto *Dependency = UB.dyn_cast<
DIVariable *>())
947 Result.push_back(Dependency);
948 if (
auto ST = GenericSubrange->getStride())
950 Result.push_back(Dependency);
970 for (
auto Var :
reverse(Input)) {
971 DbgVar.
insert({Var->getVariable(), Var});
972 WorkList.push_back({Var, 0});
976 while (!WorkList.empty()) {
977 auto Item = WorkList.back();
979 bool visitedAllDependencies = Item.getInt();
985 if (Visited.
count(Var))
989 if (visitedAllDependencies) {
991 Result.push_back(Var);
996 auto Res = Visiting.
insert(Var);
998 assert(
false &&
"dependency cycle in local variables");
1004 WorkList.push_back({Var, 1});
1007 if (
const auto *Dep = dyn_cast<const DILocalVariable>(Dependency))
1009 WorkList.push_back({Var, 0});
1026 addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
1035 if (FnArgs.
size() > 1 && !FnArgs[FnArgs.
size() - 1] &&
1045 DIE *ObjectPointer =
nullptr;
1049 for (
auto &DV : Vars.Args)
1059 for (
const auto *
IE : ImportedEntities[
Scope->getScopeNode()])
1069 if (isa<DISubprogram>(
LS->getScopeNode()))
1072 if (!Vars.Args.empty() || !Vars.Locals.empty())
1075 !ImportedEntities[
LS->getScopeNode()].
empty())
1082 if (needToEmitLexicalScope(
LS))
1088 return ObjectPointer;
1093 DIE *&AbsDef = getAbstractSPDies()[
Scope->getScopeNode()];
1097 auto *SP = cast<DISubprogram>(
Scope->getScopeNode());
1108 else if (
auto *SPDecl = SP->getDeclaration()) {
1121 AbsDef = &ContextCU->
createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE,
nullptr);
1123 ContextCU->
addSInt(*AbsDef, dwarf::DW_AT_inline,
1125 : dwarf::DW_FORM_implicit_const,
1128 ContextCU->
addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
1139 case dwarf::DW_TAG_call_site:
1140 return dwarf::DW_TAG_GNU_call_site;
1141 case dwarf::DW_TAG_call_site_parameter:
1142 return dwarf::DW_TAG_GNU_call_site_parameter;
1153 case dwarf::DW_AT_call_all_calls:
1154 return dwarf::DW_AT_GNU_all_call_sites;
1155 case dwarf::DW_AT_call_target:
1156 return dwarf::DW_AT_GNU_call_site_target;
1157 case dwarf::DW_AT_call_origin:
1158 return dwarf::DW_AT_abstract_origin;
1159 case dwarf::DW_AT_call_return_pc:
1160 return dwarf::DW_AT_low_pc;
1161 case dwarf::DW_AT_call_value:
1162 return dwarf::DW_AT_GNU_call_site_value;
1163 case dwarf::DW_AT_call_tail_call:
1164 return dwarf::DW_AT_GNU_tail_call;
1175 case dwarf::DW_OP_entry_value:
1176 return dwarf::DW_OP_GNU_entry_value;
1198 assert(CalleeDIE &&
"Could not create DIE for call site entry origin");
1230 assert(PCAddr &&
"Missing return PC information for a call");
1240 for (
const auto &
Param : Params) {
1242 auto CallSiteDieParam =
1246 addAddress(*CallSiteDieParam, dwarf::DW_AT_location,
1258 CallSiteDIE.
addChild(CallSiteDieParam);
1267 auto *Entity =
Module->getEntity();
1268 if (
auto *NS = dyn_cast<DINamespace>(Entity))
1270 else if (
auto *
M = dyn_cast<DIModule>(Entity))
1272 else if (
auto *SP = dyn_cast<DISubprogram>(Entity))
1274 else if (
auto *
T = dyn_cast<DIType>(Entity))
1276 else if (
auto *GV = dyn_cast<DIGlobalVariable>(Entity))
1279 EntityDie =
getDIE(Entity);
1282 addDIEEntry(*IMDie, dwarf::DW_AT_import, *EntityDie);
1289 DINodeArray Elements =
Module->getElements();
1290 for (
const auto *Element : Elements) {
1302 if (
DIE *AbsSPDIE = getAbstractSPDies().
lookup(SP)) {
1305 addDIEEntry(*
D, dwarf::DW_AT_abstract_origin, *AbsSPDIE);
1317 auto *Die = Entity->
getDIE();
1321 if (AbsEntity && AbsEntity->
getDIE()) {
1323 Label = dyn_cast<const DbgLabel>(Entity);
1325 if (
const DbgVariable *Var = dyn_cast<const DbgVariable>(Entity))
1327 else if ((Label = dyn_cast<const DbgLabel>(Entity)))
1334 if (
const auto *Sym = Label->getSymbol())
1339 auto &AbstractEntities = getAbstractEntities();
1340 auto I = AbstractEntities.find(Node);
1341 if (
I != AbstractEntities.end())
1342 return I->second.get();
1349 auto &Entity = getAbstractEntities()[Node];
1350 if (isa<const DILocalVariable>(Node)) {
1351 Entity = std::make_unique<DbgVariable>(
1352 cast<const DILocalVariable>(Node),
nullptr );;
1354 }
else if (isa<const DILabel>(Node)) {
1355 Entity = std::make_unique<DbgLabel>(
1356 cast<const DILabel>(Node),
nullptr );
1370 : dwarf::DW_UT_compile;
1399 GlobalNames[FullName] = &Die;
1420 GlobalTypes[FullName] = &Die;
1440 addAddress(Die, dwarf::DW_AT_location, Location);
1448 if (Location.isIndirect())
1461 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1492 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1500 ? dwarf::DW_FORM_loclistx
1512 if (
uint32_t AlignInBytes = DIVar->getAlignInBytes())
1513 addUInt(VariableDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1521 addFlag(VariableDie, dwarf::DW_AT_artificial);
1529 const auto *
DILabel = Label.getLabel();
1541 auto *SPDecl = SP->getDeclaration();
1547 bool DwarfCompileUnit::isDwoUnit()
const {
1565 : dwarf::DW_AT_GNU_addr_base,
1586 addUInt(Die, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Btr.Encoding);
DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, UnitKind Kind=UnitKind::Full)
DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)
Create new static data member DIE.
MCSection * getDwarfRangesSection() const
void addSourceLine(DIE &Die, unsigned Line, const DIFile *File)
Add location information to specified debug information entry.
MCSection * getDwarfAddrSection() const
void emitHeader(bool UseOffsets) override
Emit the header for this unit, not including the initial length field.
void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context) override
Add a new global name to the compile unit.
StringRef AttributeEncodingString(unsigned Encoding)
DIE & constructSubprogramScopeDIE(const DISubprogram *Sub, LexicalScope *Scope)
Construct a DIE for this subprogram scope.
DwarfCompileUnit & getCU() override
This is an optimization pass for GlobalISel generic memory operations.
uint32_t getAlignInBytes() const
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
DIE * constructInlinedScopeDIE(LexicalScope *Scope)
This scope represents inlined body of a function.
std::vector< BaseTypeRef > ExprRefedBaseTypes
AddressPool & getAddressPool()
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
bool useGNUTLSOpcode() const
Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opc...
Information about stack frame layout on the target.
This class is defined as the common parent of DbgVariable and DbgLabel such that it could levarage po...
A DeclContext is a named program scope that is used for ODR uniquing of types.
MCSymbol * createTempSymbol(const Twine &Name) const
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::lookup ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT)
Emit the common part of the header for this unit.
This struct describes target specific location.
MCSymbol * getBeginSymbol()
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
DIE * createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE)
LexicalScope - This class is used to track scope information.
void addLabelDelta(DIEValueList &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
Add a label delta attribute data and value.
const MCRegisterInfo * getMCRegisterInfo() const
void addLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)
addLabelAddress - Add a dwarf label attribute data and value using either DW_FORM_addr or DW_FORM_GNU...
unsigned getDebugLocListIndex() const
int getDwarfRegNum(MCRegister RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die)
Implements a dense probed hash-table based set with some number of buckets stored inline.
void terminateLineTable(const DwarfCompileUnit *CU)
Terminate the line table by adding the last range label.
virtual void getOffsetOpcodes(const StackOffset &Offset, SmallVectorImpl< uint64_t > &Ops) const
Gets the DWARF expression opcodes for Offset.
void insertDIE(const DINode *Desc, DIE *D)
Insert DIE into the map.
void addOpAddress(DIELoc &Die, const MCSymbol *Sym)
Add a dwarf op address data and value using the form given and an op of either DW_FORM_addr or DW_FOR...
@ WASM_SYMBOL_TYPE_GLOBAL
DIE * getDIE(const DINode *D) const
Returns the DIE map slot for the specified debug variable.
StringRef getName() const
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal=false)
virtual const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const
Create a symbol reference to describe the given TLS variable when emitting the address in debug info.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool addScopeVariable(LexicalScope *LS, DbgVariable *Var)
void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)
Add a new type attribute to the specified entity.
const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to.
virtual const MCExpr * getIndirectSymViaRWPI(const MCSymbol *Sym) const
Get the target specific RWPI relocation.
DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
void attachRangesOrLowHighPC(DIE &D, SmallVector< RangeSpan, 2 > Ranges)
Optional< uint8_t > TagOffset
unsigned getBitWidth() const
Return the number of bits in the APInt.
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)
Add a string attribute data and value.
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
StringRef getDisplayName() const
void createBaseTypeDIEs()
DIE & updateSubprogramScopeDIE(const DISubprogram *SP)
Find DIE for the given subprogram and attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes.
virtual DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const
Return the frame base information to be encoded in the DWARF subprogram debug info.
StringRef getName() const
A structured debug information entry.
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
void addSInt(DIEValueList &Die, dwarf::Attribute Attribute, Optional< dwarf::Form > Form, int64_t Integer)
Add an signed integer attribute data and value.
This class is used to track label information.
DIE * getOrCreateCommonBlock(const DICommonBlock *CB, ArrayRef< GlobalExpr > GlobalExprs)
DIE * constructLexicalScopeDIE(LexicalScope *Scope)
Construct new DW_TAG_lexical_block for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels.
void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy)
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
DIE * constructLabelDIE(DbgLabel &DL, const LexicalScope &Scope)
Construct a DIE for the given DbgLabel.
unsigned const TargetRegisterInfo * TRI
void setLocation(const MachineLocation &Loc, const DIExpression *DIExpr)
Set the location (Loc) and DIExpression (DIExpr) to describe.
bool isArtificial() const
Return true if DbgVariable is artificial.
struct WasmFrameBase WasmLoc
void setCallSiteParamValueFlag()
Lock this down to become a call site parameter location.
uint64_t getElement(unsigned I) const
void insertSectionLabel(const MCSymbol *S)
DbgEntity * getExistingAbstractEntity(const DINode *Node)
DIE & addChild(DIE *Child)
Add a child to the DIE.
void constructScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE)
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null.
union llvm::TargetFrameLowering::DwarfFrameBase::@227 Location
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
void addScopeRangeList(DIE &ScopeDIE, SmallVector< RangeSpan, 2 > Range)
A helper function to construct a RangeSpanList for a given lexical scope.
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Optional< MD5::MD5Result > getMD5AsBytes(const DIFile *File) const
If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
element_iterator elements_begin() const
bool isLocalToUnit() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
dwarf::Attribute getDwarf5OrGNUAttr(dwarf::Attribute Attr) const
This takes a DWARF 5 attribute and returns it or a GNU analog.
void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty)
Add constant value entry in variable DIE.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP, DIE &Die)
void addAnnotation(DIE &Buffer, DINodeArray Annotations)
Add DW_TAG_LLVM_annotation.
Represents a pointer to a location list in the debug_loc section.
DIE & addChildFront(DIE *Child)
const Triple & getTargetTriple() const
void addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
Add a Dwarf section label attribute data and value.
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
const MachineFunction * getCurrentFunction() const
bool alwaysUseRanges() const
Returns whether range encodings should be used for single entry range lists.
bool useAddrOffsetForm() const
std::string getParentContextString(const DIScope *Context) const
Get string containing language specific context for a global name.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const DICompileUnit * CUNode
MDNode for the compile unit.
dwarf::Tag getTag() const
DIE * constructVariableDIE(DbgVariable &DV, bool Abstract=false)
constructVariableDIE - Construct a DIE for the given DbgVariable.
StringRef getName() const
void addExpression(DIExpressionCursor &&Expr)
Emit all remaining operations in the DIExpressionCursor.
void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index)
Add a Dwarf loclistptr attribute data and value.
void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool SkipSPAttributes=false)
void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
addSectionDelta - Add a label delta attribute data and value.
void addTemplateParams(DIE &Buffer, DINodeArray TParams)
Add template parameters in buffer.
bool isObjectPointer() const
void setMemoryLocationKind()
Lock this down to become a memory location description.
bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, llvm::Register MachineReg, unsigned FragmentOffsetInBits=0)
Emit a machine register location.
const DICompileUnit * getCUNode() const
void addLocationAttribute(DIE *ToDIE, const DIGlobalVariable *GV, ArrayRef< GlobalExpr > GlobalExprs)
void addWasmLocation(unsigned Index, uint64_t Offset)
Emit location information expressed via WebAssembly location + offset The Index is an identifier for ...
uint64_t getZExtValue() const
Get zero extended value.
static Optional< DebugEmissionKind > getEmissionKind(StringRef Str)
uint64_t getDWOId() const
void addBaseTypeRef(DIEValueList &Die, int64_t Idx)
void addLinkageName(DIE &Die, StringRef LinkageName)
Add a linkage name, if it isn't empty.
enum llvm::TargetFrameLowering::DwarfFrameBase::FrameBaseKind Kind
DIEBlock - Represents a block of values.
DenseMap< LexicalScope *, LabelList > & getScopeLabels()
This class is used to track local variable information.
void applySubprogramAttributesToDefinition(const DISubprogram *SP, DIE &SPDie)
dwarf::Tag getTag() const
void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End)
ArchType getArch() const
Get the parsed architecture type of this triple.
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
BumpPtrAllocator DIEValueAllocator
static SmallVector< const DIVariable *, 2 > dependencies(DbgVariable *Var)
Return all DIVariables that appear in count: expressions.
bool hasFrameIndexExprs() const
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope)
DwarfCompileUnit * lookupCU(const DIE *Die)
Find the matching DwarfCompileUnit for the given CU DIE.
unsigned getSectionIDNum() const
Returns the unique section ID number of this basic block.
dwarf::LocationAtom getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const
This takes a DWARF 5 location atom and either returns it or a GNU analog.
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool useAddrOffsetExpressions() const
bool isDefinition() const
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
DIE * getOrCreateModule(const DIModule *M)
void emitInt64(uint64_t Value) const
Emit a long long directive and value.
void addVariableAddress(const DbgVariable &DV, DIE &Die, MachineLocation Location)
Add DW_AT_location attribute for a DbgVariable based on provided MachineLocation.
uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator)
Returns the integer ceil(Numerator / Denominator).
StringRef getName() const
Get a short "name" for the module.
DIE * getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV, ArrayRef< GlobalExpr > GlobalExprs)
Get or create global variable DIE.
static const DIExpression * extractAddressClass(const DIExpression *Expr, unsigned &AddrClass)
Checks if the last 4 elements of the expression are DW_OP_constu <DWARF Address Space> DW_OP_swap DW_...
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
bool hasDwarfPubSections() const
Collects and handles dwarf debug information.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
AccelTableKind getAccelTableKind() const
Returns what kind (if any) of accelerator tables to emit.
void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context)
Add a new global name present in a type unit to this compile unit.
llvm::Optional< SignedOrUnsignedConstant > isConstant() const
Determine whether this represents a constant value, if so.
DwarfExpression implementation for singular DW_AT_location.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support.
unsigned getOrCreateSourceID(const DIFile *File) override
Look up the source ID for the given file.
void beginEntryValueExpression(DIExpressionCursor &ExprCursor)
Begin emission of an entry value dwarf operation.
bool supportDebugThreadLocalLocation() const
Target supports TLS offset relocation in debug section?
An imported module (C++ using directive or similar).
void finishSubprogramDefinition(const DISubprogram *SP)
DIELoc - Represents an expression location.
UnitType
Constants for unit types in DWARF v5.
AsmPrinter * Asm
Target of Dwarf emission.
void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context) override
Add a new global type to the compile unit.
constexpr uint64_t PointerSize
x86_64 pointer size.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual const MCSymbol * getFunctionFrameSymbol() const
Return symbol for the function pseudo stack if the stack frame is not a register based.
MCSymbol * getSymbol(const GlobalValue *GV) const
bool isDebugDirectivesOnly() const
void finishEntityDefinition(const DbgEntity *Entity)
MachineFunction * MF
The current machine function.
static SmallVector< DbgVariable *, 8 > sortLocalVars(SmallVectorImpl< DbgVariable * > &Input)
Sort local variables so that variables appearing inside of helper expressions come first.
StringRef getName() const
A Module instance is used to store all the information related to an LLVM module.
DIE * constructImportedEntityDIE(const DIImportedEntity *Module)
Construct import_module DIE.
StringRef getName() const
void addComplexAddress(const DbgVariable &DV, DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)
Start with the address based on the location provided, and generate the DWARF information necessary t...
const DbgValueLoc * getValueLoc() const
Basic type, like 'int' or 'float'.
Class for arbitrary precision integers.
DIScope * getScope() const
std::pair< const MachineInstr *, const MachineInstr * > InsnRange
InsnRange - This is used to track range of instructions with identical lexical scope.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
void addScopeLabel(LexicalScope *LS, DbgLabel *Label)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
DIE & createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N=nullptr)
Create a DIE with the given Tag, add the DIE to its parent, and call insertDIE if MD is not null.
StringRef getLinkageName() const
void applyLabelAttributes(const DbgLabel &Label, DIE &LabelDie)
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
StringRef - Represent a constant reference to a string, i.e.
Tagged DWARF-like metadata node.
const DINode * getEntity() const
Accessors.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void addRange(RangeSpan Range)
addRange - Add an address range to the list of ranges for this unit.
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
void addAddrTableBase()
Add the DW_AT_addr_base attribute to the unit DIE.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MDTuple * getTemplateParams() const
void addArangeLabel(SymbolCU SCU)
Add a label so that arange data can be generated for it.
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
void applyVariableAttributes(const DbgVariable &Var, DIE &VariableDie)
Base class for variables.
virtual MCRegister getStaticBase() const
Returns the register used as static base in RWPI variants.
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
MCSymbol * EndLabel
Emitted at the end of the CU and used to compute the CU Length field.
Wrapper class representing virtual and physical registers.
const MCSymbol * getSectionLabel(const MCSection *S)
LLVM_NODISCARD bool empty() const
static Optional< DebugNameTableKind > getNameTableKind(StringRef Str)
DIE * getOrCreateNameSpace(const DINamespace *NS)
DIDerivedType * getStaticDataMemberDeclaration() const
ArrayRef< FrameIndexExpr > getFrameIndexExprs() const
Get the FI entries, sorted by fragment offset.
static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr)
const DwarfCompileUnit * getPrevCU() const
Returns the previous CU that was being updated.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool useAppleExtensionAttributes() const
bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
virtual const TargetFrameLowering * getFrameLowering() const
void addFragmentOffset(const DIExpression *Expr)
If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by Ex...
void createAbstractEntity(const DINode *Node, LexicalScope *Scope)
void addAttribute(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
Base class for scope-like contexts.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool isEndSection() const
Returns true if this block ends any section.
void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, Optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
bool useGNUAnalogForDwarf5Feature() const
Whether to use the GNU analog for a DWARF5 tag, attribute, or location atom.
DINodeArray getAnnotations() const
DIScope * getScope() const
virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
A single location or constant within a variable location description, with either a single entry (wit...
DIScope * getScope() const
void applyStmtList(DIE &D)
Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context)
Add a new global type present in a type unit to this compile unit.
void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)
addLocalLabelAddress - Add a dwarf label attribute data and value using DW_FORM_addr only.
void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc)
Add block data.
This class is intended to be used as a driving class for all asm writers.
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
bool includeMinimalInlineScopes() const
DenseMap< LexicalScope *, ScopeVars > & getScopeVariables()
const DIExpression * getSingleExpression() const
void constructCallSiteParmEntryDIEs(DIE &CallSiteDIE, SmallVector< DbgCallSiteParam, 4 > &Params)
Construct call site parameter DIEs for the CallSiteDIE.
MapVector< unsigned, MBBSectionRange > MBBSectionRanges
void addLabel(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
Add a Dwarf label attribute data and value.
TargetMachine & TM
Target machine description.
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
Holds a DIExpression and keeps track of how many operands have been consumed so far.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
dwarf::Tag getDwarf5OrGNUTag(dwarf::Tag Tag) const
This takes a DWARF 5 tag and returns it or a GNU analog.
const DILocalVariable * getVariable() const
const Triple & getTargetTriple() const
unsigned getLineNo() const
static dwarf::Tag GetCompileUnitType(UnitKind Kind, DwarfDebug *DW)
const DataLayout & getDataLayout() const
Return information about data layout.
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
void setPrevCU(const DwarfCompileUnit *PrevCU)
This dwarf writer support class manages information associated with a source file.
bool hasComplexAddress() const
bool useRangesSection() const
Returns whether ranges section should be emitted.
element_iterator elements_end() const
DIE & constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram *CalleeSP, bool IsTail, const MCSymbol *PCAddr, const MCSymbol *CallAddr, unsigned CallReg)
Construct a call site entry DIE describing a call within Scope to a callee described by CalleeSP.
DIGlobalVariable * getDecl() const
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
void addConstantFPValue(DIE &Die, const ConstantFP *CFP)
Add constant value entry in variable DIE.
MCSection * getDwarfLineSection() const
Helper used to pair up a symbol and its DWARF compile unit.
void addAddress(DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)
Add an address attribute to a die based on the location provided.
unsigned getUniqueID() const
Base class for the full range of assembler expressions which are needed for parsing.
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
const DIType * getType() const
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)
Add a DIE attribute data and value.
Optional< uint8_t > getDebugLocListTagOffset() const
bool sameSection(const MachineBasicBlock *MBB) const
Returns true if this and MBB belong to the same section.
void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr)
Add a Dwarf expression attribute data and value.