38#define DEBUG_TYPE "dwarfdebug"
44void DIEDwarfExpression::emitOp(uint8_t
Op,
const char* Comment) {
45 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Op);
48void DIEDwarfExpression::emitSigned(int64_t
Value) {
49 CU.addSInt(getActiveDIE(), dwarf::DW_FORM_sdata,
Value);
53 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_udata,
Value);
56void DIEDwarfExpression::emitData1(uint8_t
Value) {
57 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Value);
60void DIEDwarfExpression::emitBaseTypeRef(
uint64_t Idx) {
61 CU.addBaseTypeRef(getActiveDIE(),
Idx);
64void DIEDwarfExpression::enableTemporaryBuffer() {
65 assert(!IsBuffering &&
"Already buffering?");
69void DIEDwarfExpression::disableTemporaryBuffer() { IsBuffering =
false; }
71unsigned DIEDwarfExpression::getTemporaryBufferSize() {
75void DIEDwarfExpression::commitTemporaryBuffer() { OutDIE.
takeValues(TmpDIE); }
79 return MachineReg ==
TRI.getFrameRegister(*AP.
MF);
85 :
DIEUnit(UnitTag), UniqueID(UniqueID), CUNode(Node), Asm(
A), DD(DW),
91 :
DwarfUnit(dwarf::DW_TAG_type_unit,
CU.getCUNode(),
A, DW, DWU, UniqueID),
92 CU(
CU), SplitLineTable(SplitLineTable) {}
101int64_t DwarfUnit::getDefaultLowerBound()
const {
107 case dwarf::DW_LANG_C:
108 case dwarf::DW_LANG_C89:
109 case dwarf::DW_LANG_C_plus_plus:
112 case dwarf::DW_LANG_Fortran77:
113 case dwarf::DW_LANG_Fortran90:
117 case dwarf::DW_LANG_C99:
118 case dwarf::DW_LANG_ObjC:
119 case dwarf::DW_LANG_ObjC_plus_plus:
124 case dwarf::DW_LANG_Fortran95:
130 case dwarf::DW_LANG_D:
131 case dwarf::DW_LANG_Java:
132 case dwarf::DW_LANG_Python:
133 case dwarf::DW_LANG_UPC:
138 case dwarf::DW_LANG_Ada83:
139 case dwarf::DW_LANG_Ada95:
140 case dwarf::DW_LANG_Cobol74:
141 case dwarf::DW_LANG_Cobol85:
142 case dwarf::DW_LANG_Modula2:
143 case dwarf::DW_LANG_Pascal83:
144 case dwarf::DW_LANG_PLI:
150 case dwarf::DW_LANG_BLISS:
151 case dwarf::DW_LANG_C11:
152 case dwarf::DW_LANG_C_plus_plus_03:
153 case dwarf::DW_LANG_C_plus_plus_11:
154 case dwarf::DW_LANG_C_plus_plus_14:
155 case dwarf::DW_LANG_Dylan:
156 case dwarf::DW_LANG_Go:
157 case dwarf::DW_LANG_Haskell:
158 case dwarf::DW_LANG_OCaml:
159 case dwarf::DW_LANG_OpenCL:
160 case dwarf::DW_LANG_RenderScript:
161 case dwarf::DW_LANG_Rust:
162 case dwarf::DW_LANG_Swift:
167 case dwarf::DW_LANG_Fortran03:
168 case dwarf::DW_LANG_Fortran08:
169 case dwarf::DW_LANG_Julia:
170 case dwarf::DW_LANG_Modula3:
190 return (isa<DIType>(
D) ||
191 (isa<DISubprogram>(
D) && !cast<DISubprogram>(
D)->isDefinition())) &&
224 assert(
Form != dwarf::DW_FORM_implicit_const &&
225 "DW_FORM_implicit_const is used only for signed integers");
235 std::optional<dwarf::Form>
Form, int64_t
Integer) {
258 isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp;
260 auto StringPoolEntry =
267 IxForm = dwarf::DW_FORM_strx1;
269 if (
Index > 0xffffff)
270 IxForm = dwarf::DW_FORM_strx4;
271 else if (
Index > 0xffff)
272 IxForm = dwarf::DW_FORM_strx3;
273 else if (
Index > 0xff)
274 IxForm = dwarf::DW_FORM_strx2;
293unsigned DwarfTypeUnit::getOrCreateSourceID(
const DIFile *File) {
296 if (!UsedLineTable) {
297 UsedLineTable =
true;
301 return SplitLineTable->
getFile(
307 bool UseAddrOffsetFormOrExpressions =
311 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
317 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx);
320 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
325 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_const4u);
327 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
342 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
361 addFlag(Die, dwarf::DW_AT_declaration);
363 addAttribute(Die, dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
370 const DIEUnit *EntryCU = Entry.getEntry().getUnit();
379 EntryCU ==
CU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
413 addUInt(Die, dwarf::DW_AT_decl_file, std::nullopt, FileID);
414 addUInt(Die, dwarf::DW_AT_decl_line, std::nullopt, Line);
470 addUInt(Die, dwarf::DW_AT_const_value,
471 Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
480 if (CIBitWidth <= 64) {
495 for (
int i = 0; i < NumBytes; i++) {
498 c = Ptr64[i / 8] >> (8 * (i & 7));
500 c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
511 : dwarf::DW_AT_MIPS_linkage_name,
517 for (
const auto *Element : TParams) {
518 if (
auto *TTP = dyn_cast<DITemplateTypeParameter>(Element))
519 constructTemplateTypeParameterDIE(Buffer, TTP);
520 else if (
auto *TVP = dyn_cast<DITemplateValueParameter>(Element))
521 constructTemplateValueParameterDIE(Buffer, TVP);
527 for (
const auto *Ty : ThrownTypes) {
535 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
538 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
541 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
548 if (
auto *
T = dyn_cast<DIType>(
Context))
550 if (
auto *NS = dyn_cast<DINamespace>(
Context))
552 if (
auto *SP = dyn_cast<DISubprogram>(
Context))
554 if (
auto *M = dyn_cast<DIModule>(
Context))
571 updateAcceleratorTables(
Context, Ty, TyDIE);
580 updateAcceleratorTables(
Context, Ty, TyDIE);
582 if (
auto *
BT = dyn_cast<DIBasicType>(Ty))
584 else if (
auto *ST = dyn_cast<DIStringType>(Ty))
586 else if (
auto *STy = dyn_cast<DISubroutineType>(Ty))
588 else if (
auto *CTy = dyn_cast<DICompositeType>(Ty)) {
590 (Ty->
getRawName() || CTy->getRawIdentifier())) {
592 if (
MDString *TypeId = CTy->getRawIdentifier())
595 finishNonUnitTypeDIE(TyDIE, CTy);
610 auto *Ty = cast<DIType>(TyNode);
622 auto *
Context = Ty->getScope();
633void DwarfUnit::updateAcceleratorTables(
const DIScope *Context,
636 bool IsImplementation =
false;
637 if (
auto *CT = dyn_cast<DICompositeType>(Ty)) {
640 IsImplementation = CT->getRuntimeLang() == 0 || CT->isObjcClassComplete();
646 if (!Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) ||
647 isa<DINamespace>(Context) || isa<DICommonBlock>(Context))
654 assert(Ty &&
"Trying to add a type that doesn't exist?");
668 while (!isa<DICompileUnit>(
Context)) {
682 if (
Name.empty() && isa<DINamespace>(Ctx))
683 Name =
"(anonymous namespace)";
700 if (BTy->
getTag() == dwarf::DW_TAG_unspecified_type)
703 if (BTy->
getTag() != dwarf::DW_TAG_string_type)
704 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
708 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
711 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_big);
713 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_little);
724 if (
auto *VarDIE =
getDIE(Var))
725 addDIEEntry(Buffer, dwarf::DW_AT_string_length, *VarDIE);
732 DwarfExpr.setMemoryLocationKind();
733 DwarfExpr.addExpression(Expr);
734 addBlock(Buffer, dwarf::DW_AT_string_length, DwarfExpr.finalize());
737 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
745 DwarfExpr.setMemoryLocationKind();
746 DwarfExpr.addExpression(Expr);
747 addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
752 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
764 const DIType *FromTy = DTy->getBaseType();
778 if (AlignInBytes > 0)
779 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
784 if (
Size &&
Tag != dwarf::DW_TAG_pointer_type
785 &&
Tag != dwarf::DW_TAG_ptr_to_member_type
786 &&
Tag != dwarf::DW_TAG_reference_type
787 &&
Tag != dwarf::DW_TAG_rvalue_reference_type)
788 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
790 if (
Tag == dwarf::DW_TAG_ptr_to_member_type)
803 if (DTy->getDWARFAddressSpace())
804 addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,
805 *DTy->getDWARFAddressSpace());
806 if (
auto PtrAuthData = DTy->getPtrAuthData()) {
807 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_key, dwarf::DW_FORM_data1,
809 if (PtrAuthData->isAddressDiscriminated())
810 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_address_discriminated);
811 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_extra_discriminator,
812 dwarf::DW_FORM_data2, PtrAuthData->extraDiscriminator());
813 if (PtrAuthData->isaPointer())
814 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_isa_pointer);
815 if (PtrAuthData->authenticatesNullValues())
816 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_authenticates_null_values);
821 for (
unsigned i = 1,
N = Args.size(); i <
N; ++i) {
822 const DIType *Ty = Args[i];
824 assert(i ==
N-1 &&
"Unspecified parameter must be the last argument");
830 addFlag(Arg, dwarf::DW_AT_artificial);
837 auto Elements = cast<DISubroutineType>(CTy)->getTypeArray();
839 if (
auto RTy = Elements[0])
842 bool isPrototyped =
true;
843 if (Elements.size() == 2 && !Elements[1])
844 isPrototyped =
false;
851 addFlag(Buffer, dwarf::DW_AT_prototyped);
854 if (CTy->
getCC() && CTy->
getCC() != dwarf::DW_CC_normal)
855 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
859 addFlag(Buffer, dwarf::DW_AT_reference);
862 addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
870 const MDNode *MD = cast<MDNode>(Annotation);
875 addString(AnnotationDie, dwarf::DW_AT_name,
Name->getString());
876 if (
const auto *
Data = dyn_cast<MDString>(
Value))
877 addString(AnnotationDie, dwarf::DW_AT_const_value,
Data->getString());
878 else if (
const auto *
Data = dyn_cast<ConstantAsMetadata>(
Value))
882 assert(
false &&
"Unsupported annotation value type");
894 case dwarf::DW_TAG_array_type:
895 constructArrayTypeDIE(Buffer, CTy);
897 case dwarf::DW_TAG_enumeration_type:
898 constructEnumTypeDIE(Buffer, CTy);
900 case dwarf::DW_TAG_variant_part:
901 case dwarf::DW_TAG_structure_type:
902 case dwarf::DW_TAG_union_type:
903 case dwarf::DW_TAG_class_type:
904 case dwarf::DW_TAG_namelist: {
907 if (
Tag == dwarf::DW_TAG_variant_part) {
914 DIE &DiscMember = constructMemberDIE(Buffer, Discriminator);
915 addDIEEntry(Buffer, dwarf::DW_AT_discr, DiscMember);
920 if (
Tag == dwarf::DW_TAG_class_type ||
921 Tag == dwarf::DW_TAG_structure_type ||
Tag == dwarf::DW_TAG_union_type)
926 for (
const auto *Element : Elements) {
929 if (
auto *SP = dyn_cast<DISubprogram>(Element))
931 else if (
auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
932 if (DDTy->getTag() == dwarf::DW_TAG_friend) {
934 addType(ElemDie, DDTy->getBaseType(), dwarf::DW_AT_friend);
935 }
else if (DDTy->isStaticMember()) {
937 }
else if (
Tag == dwarf::DW_TAG_variant_part) {
942 dyn_cast_or_null<ConstantInt>(DDTy->getDiscriminantValue())) {
944 addUInt(Variant, dwarf::DW_AT_discr_value, std::nullopt,
947 addSInt(Variant, dwarf::DW_AT_discr_value, std::nullopt,
950 constructMemberDIE(Variant, DDTy);
952 constructMemberDIE(Buffer, DDTy);
954 }
else if (
auto *Property = dyn_cast<DIObjCProperty>(Element)) {
956 StringRef PropertyName = Property->getName();
957 addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
958 if (Property->getType())
959 addType(ElemDie, Property->getType());
961 StringRef GetterName = Property->getGetterName();
962 if (!GetterName.
empty())
963 addString(ElemDie, dwarf::DW_AT_APPLE_property_getter, GetterName);
964 StringRef SetterName = Property->getSetterName();
965 if (!SetterName.
empty())
966 addString(ElemDie, dwarf::DW_AT_APPLE_property_setter, SetterName);
967 if (
unsigned PropertyAttributes = Property->getAttributes())
968 addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, std::nullopt,
970 }
else if (
auto *Composite = dyn_cast<DICompositeType>(Element)) {
971 if (Composite->getTag() == dwarf::DW_TAG_variant_part) {
975 }
else if (
Tag == dwarf::DW_TAG_namelist) {
976 auto *Var = dyn_cast<DINode>(Element);
977 auto *VarDIE =
getDIE(Var);
980 addDIEEntry(ItemDie, dwarf::DW_AT_namelist_item, *VarDIE);
986 addFlag(Buffer, dwarf::DW_AT_APPLE_block);
989 addFlag(Buffer, dwarf::DW_AT_export_symbols);
1000 addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
1007 CC = dwarf::DW_CC_pass_by_value;
1009 CC = dwarf::DW_CC_pass_by_reference;
1011 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
1026 if (
Tag == dwarf::DW_TAG_enumeration_type ||
1027 Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
1028 Tag == dwarf::DW_TAG_union_type) {
1034 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
1037 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, 0);
1041 addFlag(Buffer, dwarf::DW_AT_declaration);
1053 addUInt(Buffer, dwarf::DW_AT_APPLE_runtime_class, dwarf::DW_FORM_data1,
1058 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1063void DwarfUnit::constructTemplateTypeParameterDIE(
1072 if (TP->
isDefault() && isCompatibleWithVersion(5))
1073 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1076void DwarfUnit::constructTemplateValueParameterDIE(
1082 if (VP->
getTag() == dwarf::DW_TAG_template_value_parameter)
1086 if (VP->
isDefault() && isCompatibleWithVersion(5))
1087 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1089 if (
ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Val))
1091 else if (
GlobalValue *GV = mdconst::dyn_extract<GlobalValue>(Val)) {
1094 if (!GV->hasDLLImportStorageClass()) {
1101 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
1102 addBlock(ParamDIE, dwarf::DW_AT_location, Loc);
1104 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1105 assert(isa<MDString>(Val));
1106 addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
1107 cast<MDString>(Val)->getString());
1108 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1127 Name =
"(anonymous namespace)";
1131 addFlag(NDie, dwarf::DW_AT_export_symbols);
1144 if (!M->getName().empty()) {
1145 addString(MDie, dwarf::DW_AT_name, M->getName());
1148 if (!M->getConfigurationMacros().empty())
1149 addString(MDie, dwarf::DW_AT_LLVM_config_macros,
1150 M->getConfigurationMacros());
1151 if (!M->getIncludePath().empty())
1152 addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
1153 if (!M->getAPINotesFile().empty())
1154 addString(MDie, dwarf::DW_AT_LLVM_apinotes, M->getAPINotesFile());
1156 addUInt(MDie, dwarf::DW_AT_decl_file, std::nullopt,
1159 addUInt(MDie, dwarf::DW_AT_decl_line, std::nullopt, M->getLineNo());
1161 addFlag(MDie, dwarf::DW_AT_declaration);
1176 if (
auto *SPDecl = SP->getDeclaration()) {
1190 if (SP->isDefinition())
1199 DIE &SPDie,
bool Minimal) {
1200 DIE *DeclDie =
nullptr;
1202 if (
auto *SPDecl = SP->getDeclaration()) {
1205 DeclArgs = SPDecl->getType()->getTypeArray();
1206 DefinitionArgs = SP->getType()->getTypeArray();
1208 if (DeclArgs.
size() && DefinitionArgs.
size())
1209 if (DefinitionArgs[0] !=
nullptr && DeclArgs[0] != DefinitionArgs[0])
1210 addType(SPDie, DefinitionArgs[0]);
1212 DeclDie =
getDIE(SPDecl);
1213 assert(DeclDie &&
"This DIE should've already been constructed when the "
1214 "definition DIE was created in "
1215 "getOrCreateSubprogramDIE");
1218 DeclLinkageName = SPDecl->getLinkageName();
1221 if (DeclID != DefID)
1222 addUInt(SPDie, dwarf::DW_AT_decl_file, std::nullopt, DefID);
1224 if (SP->getLine() != SPDecl->getLine())
1225 addUInt(SPDie, dwarf::DW_AT_decl_line, std::nullopt, SP->getLine());
1236 "decl has a linkage name and it is different");
1237 if (DeclLinkageName.
empty() &&
1247 addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
1252 bool SkipSPAttributes) {
1255 bool SkipSPSourceLocation = SkipSPAttributes &&
1257 if (!SkipSPSourceLocation)
1267 if (!SkipSPSourceLocation)
1271 if (SkipSPAttributes)
1277 addFlag(SPDie, dwarf::DW_AT_prototyped);
1279 if (SP->isObjCDirect())
1280 addFlag(SPDie, dwarf::DW_AT_APPLE_objc_direct);
1285 Args = SPTy->getTypeArray();
1290 if (
CC &&
CC != dwarf::DW_CC_normal)
1291 addUInt(SPDie, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
CC);
1296 if (
auto Ty = Args[0])
1299 unsigned VK = SP->getVirtuality();
1301 addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
1302 if (SP->getVirtualIndex() != -1u) {
1304 addUInt(*
Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1305 addUInt(*
Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1311 if (!SP->isDefinition()) {
1312 addFlag(SPDie, dwarf::DW_AT_declaration);
1321 if (SP->isArtificial())
1322 addFlag(SPDie, dwarf::DW_AT_artificial);
1324 if (!SP->isLocalToUnit())
1325 addFlag(SPDie, dwarf::DW_AT_external);
1328 if (SP->isOptimized())
1329 addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
1332 addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag,
isa);
1335 if (SP->isLValueReference())
1336 addFlag(SPDie, dwarf::DW_AT_reference);
1338 if (SP->isRValueReference())
1339 addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
1341 if (SP->isNoReturn())
1342 addFlag(SPDie, dwarf::DW_AT_noreturn);
1346 if (SP->isExplicit())
1347 addFlag(SPDie, dwarf::DW_AT_explicit);
1349 if (SP->isMainSubprogram())
1350 addFlag(SPDie, dwarf::DW_AT_main_subprogram);
1352 addFlag(SPDie, dwarf::DW_AT_pure);
1353 if (SP->isElemental())
1354 addFlag(SPDie, dwarf::DW_AT_elemental);
1355 if (SP->isRecursive())
1356 addFlag(SPDie, dwarf::DW_AT_recursive);
1358 if (!SP->getTargetFuncName().empty())
1359 addString(SPDie, dwarf::DW_AT_trampoline, SP->getTargetFuncName());
1362 addFlag(SPDie, dwarf::DW_AT_deleted);
1365void DwarfUnit::constructSubrangeDIE(
DIE &Buffer,
const DISubrange *SR,
1368 addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IndexTy);
1374 int64_t DefaultLowerBound = getDefaultLowerBound();
1377 DISubrange::BoundType Bound) ->
void {
1378 if (
auto *BV = dyn_cast_if_present<DIVariable *>(Bound)) {
1379 if (
auto *VarDIE =
getDIE(BV))
1381 }
else if (
auto *BE = dyn_cast_if_present<DIExpression *>(Bound)) {
1384 DwarfExpr.setMemoryLocationKind();
1385 DwarfExpr.addExpression(BE);
1386 addBlock(DW_Subrange, Attr, DwarfExpr.finalize());
1387 }
else if (
auto *BI = dyn_cast_if_present<ConstantInt *>(Bound)) {
1388 if (Attr == dwarf::DW_AT_count) {
1389 if (BI->getSExtValue() != -1)
1390 addUInt(DW_Subrange, Attr, std::nullopt, BI->getSExtValue());
1391 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1392 BI->getSExtValue() != DefaultLowerBound)
1393 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1397 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1399 AddBoundTypeEntry(dwarf::DW_AT_count, SR->
getCount());
1401 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1403 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, SR->
getStride());
1406void DwarfUnit::constructGenericSubrangeDIE(
DIE &Buffer,
1409 DIE &DwGenericSubrange =
1411 addDIEEntry(DwGenericSubrange, dwarf::DW_AT_type, *IndexTy);
1413 int64_t DefaultLowerBound = getDefaultLowerBound();
1417 if (
auto *BV = dyn_cast_if_present<DIVariable *>(Bound)) {
1418 if (
auto *VarDIE =
getDIE(BV))
1420 }
else if (
auto *BE = dyn_cast_if_present<DIExpression *>(Bound)) {
1421 if (BE->isConstant() &&
1423 *BE->isConstant()) {
1424 if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1425 static_cast<int64_t
>(BE->getElement(1)) != DefaultLowerBound)
1426 addSInt(DwGenericSubrange, Attr, dwarf::DW_FORM_sdata,
1431 DwarfExpr.setMemoryLocationKind();
1432 DwarfExpr.addExpression(BE);
1433 addBlock(DwGenericSubrange, Attr, DwarfExpr.finalize());
1438 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, GSR->
getLowerBound());
1439 AddBoundTypeEntry(dwarf::DW_AT_count, GSR->
getCount());
1440 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, GSR->
getUpperBound());
1441 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, GSR->
getStride());
1444DIE *DwarfUnit::getIndexTyDie() {
1464 assert(CTy && CTy->
isVector() &&
"Composite type is not a vector");
1474 assert(Elements.size() == 1 &&
1475 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type &&
1476 "Invalid vector element array, expected one element of type subrange");
1477 const auto Subrange = cast<DISubrange>(Elements[0]);
1478 const auto NumVecElements =
1479 Subrange->getCount()
1480 ? cast<ConstantInt *>(Subrange->getCount())->getSExtValue()
1485 assert(ActualSize >= (NumVecElements * ElementSize) &&
"Invalid vector size");
1486 return ActualSize != (NumVecElements * ElementSize);
1491 addFlag(Buffer, dwarf::DW_AT_GNU_vector);
1493 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
1498 if (
auto *VarDIE =
getDIE(Var))
1499 addDIEEntry(Buffer, dwarf::DW_AT_data_location, *VarDIE);
1503 DwarfExpr.setMemoryLocationKind();
1504 DwarfExpr.addExpression(Expr);
1505 addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
1509 if (
auto *VarDIE =
getDIE(Var))
1510 addDIEEntry(Buffer, dwarf::DW_AT_associated, *VarDIE);
1514 DwarfExpr.setMemoryLocationKind();
1515 DwarfExpr.addExpression(Expr);
1516 addBlock(Buffer, dwarf::DW_AT_associated, DwarfExpr.finalize());
1520 if (
auto *VarDIE =
getDIE(Var))
1521 addDIEEntry(Buffer, dwarf::DW_AT_allocated, *VarDIE);
1525 DwarfExpr.setMemoryLocationKind();
1526 DwarfExpr.addExpression(Expr);
1527 addBlock(Buffer, dwarf::DW_AT_allocated, DwarfExpr.finalize());
1531 addSInt(Buffer, dwarf::DW_AT_rank, dwarf::DW_FORM_sdata,
1532 RankConst->getSExtValue());
1533 }
else if (
auto *RankExpr = CTy->
getRankExp()) {
1536 DwarfExpr.setMemoryLocationKind();
1537 DwarfExpr.addExpression(RankExpr);
1538 addBlock(Buffer, dwarf::DW_AT_rank, DwarfExpr.finalize());
1547 DIE *IdxTy = getIndexTyDie();
1551 for (
DINode *E : Elements) {
1553 if (
auto *Element = dyn_cast_or_null<DINode>(E)) {
1554 if (Element->getTag() == dwarf::DW_TAG_subrange_type)
1555 constructSubrangeDIE(Buffer, cast<DISubrange>(Element), IdxTy);
1556 else if (Element->getTag() == dwarf::DW_TAG_generic_subrange)
1557 constructGenericSubrangeDIE(Buffer, cast<DIGenericSubrange>(Element),
1570 addFlag(Buffer, dwarf::DW_AT_enum_class);
1574 bool IndexEnumerators = !
Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) ||
1575 isa<DINamespace>(Context) || isa<DICommonBlock>(Context);
1579 for (
const DINode *E : Elements) {
1580 auto *
Enum = dyn_cast_or_null<DIEnumerator>(E);
1586 if (IndexEnumerators)
1594 DIE &SPDie = *
P.first;
1601 addDIEEntry(SPDie, dwarf::DW_AT_containing_type, *NDie);
1613 if (
DIType *Resolved = DT->getBaseType())
1625 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
1626 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1627 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1629 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_minus);
1630 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1631 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
1633 addBlock(MemberDie, dwarf::DW_AT_data_member_location, VBaseLocationDie);
1644 addUInt(MemberDie, dwarf::DW_AT_byte_size, std::nullopt, FieldSize / 8);
1645 addUInt(MemberDie, dwarf::DW_AT_bit_size, std::nullopt,
Size);
1652 uint32_t AlignMask = ~(AlignInBits - 1);
1654 uint64_t StartBitOffset = Offset - (Offset & AlignMask);
1656 OffsetInBytes = (Offset - StartBitOffset) / 8;
1659 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
1660 uint64_t FieldOffset = (HiMark - FieldSize);
1661 Offset -= FieldOffset;
1665 Offset = FieldSize - (Offset +
Size);
1667 addUInt(MemberDie, dwarf::DW_AT_bit_offset, std::nullopt, Offset);
1668 OffsetInBytes = FieldOffset >> 3;
1670 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, std::nullopt, Offset);
1676 addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1682 addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
1683 addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
1684 addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
1691 addUInt(MemberDie, dwarf::DW_AT_data_member_location,
1692 dwarf::DW_FORM_udata, OffsetInBytes);
1694 addUInt(MemberDie, dwarf::DW_AT_data_member_location, std::nullopt,
1702 addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1,
1703 dwarf::DW_VIRTUALITY_virtual);
1709 dwarf::DW_FORM_ref4,
DIEEntry(*PDie));
1712 addFlag(MemberDie, dwarf::DW_AT_artificial);
1725 "Static member should belong to a type.");
1728 return StaticMemberDIE;
1732 const DIType *Ty = DT->getBaseType();
1737 addFlag(StaticMemberDIE, dwarf::DW_AT_external);
1738 addFlag(StaticMemberDIE, dwarf::DW_AT_declaration);
1750 addUInt(StaticMemberDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1753 return &StaticMemberDIE;
1760 isDwoUnit() ?
"debug_info_dwo" :
"debug_info",
"Length of Unit");
1801 : dwarf::DW_UT_type);
1803 Asm->
OutStreamer->emitIntValue(TypeSignature,
sizeof(TypeSignature));
1823bool DwarfTypeUnit::isDwoUnit()
const {
1839const MCSymbol *DwarfUnit::getCrossSectionRelativeBaseAddress()
const {
1856 "DW_AT_rnglists_base requires DWARF version 5 or later");
1867bool DwarfUnit::isCompatibleWithVersion(
uint16_t Version)
const {
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static bool hasVectorBeenPadded(const DICompositeType *CTy)
Returns true if the vector's size differs from the sum of sizes of elements the user specified.
unsigned const TargetRegisterInfo * TRI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static enum BaseType getBaseType(const Value *Val)
Return the baseType for Val which states whether Val is exclusively derived from constant/null,...
static unsigned getSize(unsigned Kind)
APInt bitcastToAPInt() const
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
unsigned getBitWidth() const
Return the number of bits in the APInt.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
int64_t getSExtValue() const
Get sign extended value.
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
void resetUsedFlag(bool HasBeenUsed=false)
Annotations lets you mark points and ranges inside source code, for tests:
This class is intended to be used as a driving class for all asm writers.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
MCSymbol * getSymbol(const GlobalValue *GV) const
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
void emitDwarfLengthOrOffset(uint64_t Value) const
Emit 32- or 64-bit value depending on the DWARF format.
TargetMachine & TM
Target machine description.
const MCAsmInfo * MAI
Target Asm Printer information.
MachineFunction * MF
The current machine function.
void emitInt8(int Value) const
Emit a byte directive and value.
void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const
Emit a unit length field.
MCContext & OutContext
This is the context for the output file that we are streaming.
MCSymbol * createTempSymbol(const Twine &Name) const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
void emitInt16(int Value) const
Emit a short directive and value.
const DataLayout & getDataLayout() const
Return information about data layout.
dwarf::FormParams getDwarfFormParams() const
Returns information about the byte size of DW_FORM values.
bool doesDwarfUseRelocationsAcrossSections() const
ConstantFP - Floating Point Values [float, double].
const APFloat & getValueAPF() const
This is the shared class of boolean and integer constants.
const APInt & getValue() const
Return the constant as an APInt value reference.
Basic type, like 'int' or 'float'.
unsigned getEncoding() const
bool getDebugInfoForProfiling() const
bool isDebugDirectivesOnly() const
static std::optional< DebugNameTableKind > getNameTableKind(StringRef Str)
DIExpression * getRankExp() const
DIExpression * getAssociatedExp() const
DIVariable * getAllocated() const
DIExpression * getDataLocationExp() const
DIVariable * getAssociated() const
DIDerivedType * getDiscriminator() const
DIVariable * getDataLocation() const
unsigned getRuntimeLang() const
DINodeArray getElements() const
DITemplateParameterArray getTemplateParams() const
DIExpression * getAllocatedExp() const
DIType * getVTableHolder() const
DINodeArray getAnnotations() const
ConstantInt * getRankConst() const
DIType * getBaseType() const
DINodeArray getAnnotations() const
Get annotations associated with this derived type.
DIObjCProperty * getObjCProperty() const
Constant * getConstant() const
DIEBlock - Represents a block of values.
A simple label difference DIE.
DwarfExpression implementation for singular DW_AT_location.
DIEDwarfExpression(const AsmPrinter &AP, DwarfCompileUnit &CU, DIELoc &DIE)
A pointer to another debug information entry.
A container for inline string values.
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
DIELoc - Represents an expression location.
unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
A container for string pool string values.
Represents a compile or type unit.
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
void takeValues(DIEValueList &Other)
Take ownership of the nodes in Other, and append them to the back of the list.
A structured debug information entry.
DIE & addChild(DIE *Child)
Add a child to the DIE.
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to.
dwarf::Tag getTag() const
BoundType getLowerBound() const
BoundType getCount() const
BoundType getUpperBound() const
BoundType getStride() const
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
DIScope * getScope() const
StringRef getName() const
bool getExportSymbols() const
Tagged DWARF-like metadata node.
dwarf::Tag getTag() const
Base class for scope-like contexts.
StringRef getName() const
DIScope * getScope() const
String type, Fortran CHARACTER(n)
unsigned getEncoding() const
DIExpression * getStringLengthExp() const
DIVariable * getStringLength() const
DIExpression * getStringLocationExp() const
BoundType getUpperBound() const
BoundType getStride() const
BoundType getLowerBound() const
BoundType getCount() const
Type array for a subprogram.
StringRef getName() const
Metadata * getValue() const
bool isLittleEndian() const
bool isLValueReference() const
bool isObjcClassComplete() const
MDString * getRawName() const
bool isAppleBlockExtension() const
uint64_t getOffsetInBits() const
StringRef getName() const
bool isForwardDecl() const
bool isTypePassByValue() const
uint64_t getSizeInBits() const
uint32_t getAlignInBytes() const
bool isRValueReference() const
bool isArtificial() const
bool getExportSymbols() const
DIScope * getScope() const
bool isTypePassByReference() const
Base class for variables.
This class represents an Operation in the Expression.
bool isLittleEndian() const
Layout endianness...
static bool isUnsignedDIType(const DIType *Ty)
Return true if type encoding is unsigned.
static uint64_t getBaseTypeSize(const DIType *Ty)
If this type is derived from a base type then return base type size.
void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context)
Add a new global name present in a type unit to this compile unit.
unsigned getOrCreateSourceID(const DIFile *File) override
Look up the source ID for the given file.
void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context)
Add a new global type present in a type unit to this compile unit.
Collects and handles dwarf debug information.
std::optional< MD5::MD5Result > getMD5AsBytes(const DIFile *File) const
If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
bool useAddrOffsetForm() const
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
void addAccelNamespace(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
bool useAppleExtensionAttributes() const
bool useInlineStrings() const
Returns whether to use inline strings.
bool generateTypeUnits() const
Returns whether to generate DWARF v4 type units.
AddressPool & getAddressPool()
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
bool shareAcrossDWOCUs() const
const MCSymbol * getSectionLabel(const MCSection *S)
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support.
bool useDWARF2Bitfields() const
Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format.
bool useAddrOffsetExpressions() const
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &Die, const DICompositeType *CTy)
Add a DIE to the set of types that we're going to pull into type units.
void addAccelType(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die, char Flags)
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
MCSymbol * getStringOffsetsStartSym() const
MCSymbol * getRnglistsTableBaseSym() const
DwarfStringPool & getStringPool()
Returns the string pool.
DenseMap< const DILocalScope *, DIE * > & getAbstractScopeDIEs()
void insertDIE(const MDNode *TypeMD, DIE *Die)
DIE * getDIE(const MDNode *TypeMD)
unsigned getIndex() const
EntryRef getEntry(AsmPrinter &Asm, StringRef Str)
Get a reference to an entry in the string pool.
EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str)
Same as getEntry, except that you can use EntryRef::getIndex to obtain a unique ID of this entry (e....
DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID, MCDwarfDwoLineTable *SplitLineTable=nullptr)
void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context) override
Add a new global type to the compile unit.
DwarfCompileUnit & getCU() override
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.
This dwarf writer support class manages information associated with a source file.
virtual DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
void addThrownTypes(DIE &Die, DINodeArray ThrownTypes)
Add thrown types.
void addStringOffsetsStart()
Add the DW_AT_str_offsets_base attribute to the unit DIE.
void addAnnotation(DIE &Buffer, DINodeArray Annotations)
Add DW_TAG_LLVM_annotation.
std::vector< DIEBlock * > DIEBlocks
A list of all the DIEBlocks in use.
std::vector< DIELoc * > DIELocs
A list of all the DIELocs in use.
uint16_t getLanguage() const
void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc)
Add block data.
void addTemplateParams(DIE &Buffer, DINodeArray TParams)
Add template parameters in buffer.
virtual DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
bool useSegmentedStringOffsetsTable() const
bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal)
DIELoc * getDIELoc()
Returns a fresh newly allocated DIELoc.
void addAttribute(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
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...
void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)
Add a string attribute data and value.
void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty)
Add constant value entry in variable DIE.
DIE * getOrCreateNameSpace(const DINamespace *NS)
void insertDIE(const DINode *Desc, DIE *D)
Insert DIE into the map.
void addAccess(DIE &Die, DINode::DIFlags Flags)
Add the accessibility attribute.
void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
addSectionDelta - Add a label delta attribute data and value.
DIE * createTypeDIE(const DIScope *Context, DIE &ContextDIE, const DIType *Ty)
Creates type DIE with specific context.
DenseMap< DIE *, const DINode * > ContainingTypeMap
This map is used to keep track of subprogram DIEs that need DW_AT_containing_type attribute.
const DICompileUnit * CUNode
MDNode for the compile unit.
virtual unsigned getOrCreateSourceID(const DIFile *File)=0
Look up the source ID for the given file.
void addDIETypeSignature(DIE &Die, uint64_t Signature)
Add a type's DW_AT_signature and set the declaration flag.
virtual void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context)=0
Add a new global type to the compile unit.
virtual DwarfCompileUnit & getCU()=0
DIE * getDIE(const DINode *D) const
Returns the DIE map slot for the specified debug variable.
virtual unsigned getHeaderSize() const
Compute the size of a header for this unit, not including the initial length field.
void constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args)
Construct function argument DIEs.
MCSymbol * LabelBegin
The start of the unit within its section.
void addSInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, int64_t Integer)
Add an signed integer attribute data and value.
DwarfUnit(dwarf::Tag, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID=0)
void addLabelDelta(DIEValueList &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
Add a label delta attribute data and value.
void addLinkageName(DIE &Die, StringRef LinkageName)
Add a linkage name, if it isn't empty.
std::string getParentContextString(const DIScope *Context) const
Get string containing language specific context for a global name.
void addSourceLine(DIE &Die, unsigned Line, const DIFile *File)
Add location information to specified debug information entry.
void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT)
Emit the common part of the header for this unit.
BumpPtrAllocator DIEValueAllocator
DIE * IndexTyDie
An anonymous type for index type. Owned by DIEUnit.
void addRnglistsBase()
Add the DW_AT_rnglists_base attribute to the unit DIE.
DIE * getOrCreateModule(const DIModule *M)
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.
void addSectionOffset(DIE &Die, dwarf::Attribute Attribute, uint64_t Integer)
Add an offset into a section attribute data and value.
DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)
Create new static data member DIE.
void addLabel(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
Add a Dwarf label attribute data and value.
void addConstantFPValue(DIE &Die, const ConstantFP *CFP)
Add constant value entry in variable DIE.
void constructContainingTypeDIEs()
Construct DIEs for types that contain vtables.
DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal=false)
void addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
Add a Dwarf section label attribute data and value.
bool isShareableAcrossCUs(const DINode *D) const
Check whether the DIE for this MDNode can be shared across CUs.
void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label)
DenseMap< const MDNode *, DIE * > MDNodeToDieMap
Tracks the mapping of unit level debug information variables to debug information entries.
void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy)
virtual void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context)=0
Add a new global name to the compile unit.
MCSymbol * EndLabel
Emitted at the end of the CU and used to compute the CU Length field.
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
AsmPrinter * Asm
Target of Dwarf emission.
void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)
Add a new type attribute to the specified entity.
void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool SkipSPAttributes=false)
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)
Add a DIE attribute data and value.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
uint16_t getDwarfVersion() const
unsigned getFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, uint16_t DwarfVersion, std::optional< StringRef > Source)
MCSection * getDwarfStrOffSection() const
MCSection * getDwarfRnglistsSection() const
MCSection * getDwarfAbbrevSection() const
MCSymbol * getBeginSymbol()
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MDOperand & getOperand(unsigned I) const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Wrapper class representing virtual and physical registers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
unsigned DebugStrictDwarf
When set to true, don't use DWARF extensions in later DWARF versions.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVM Value Representation.
UnitType
Constants for unit types in DWARF v5.
bool isCPlusPlus(SourceLanguage S)
TypeKind getArrayIndexTypeEncoding(SourceLanguage S)
@ DW_FLAG_type_implementation
bool isC(SourceLanguage S)
This is an optimization pass for GlobalISel generic memory operations.
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...
Description of the encoding of one expression Op.