39#define DEBUG_TYPE "dwarfdebug"
45void DIEDwarfExpression::emitOp(
uint8_t Op,
const char* Comment) {
46 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Op);
49void DIEDwarfExpression::emitSigned(int64_t
Value) {
50 CU.addSInt(getActiveDIE(), dwarf::DW_FORM_sdata,
Value);
54 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_udata,
Value);
57void DIEDwarfExpression::emitData1(uint8_t
Value) {
58 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Value);
61void DIEDwarfExpression::emitBaseTypeRef(
uint64_t Idx) {
62 CU.addBaseTypeRef(getActiveDIE(), Idx);
65void DIEDwarfExpression::emitRelocatedAddress(
const MCSymbol *Sym) {
66 CU.addLabel(getActiveDIE(), dwarf::DW_FORM_addr, Sym);
70 assert(!IsBuffering &&
"Already buffering?");
77 return TmpDIE.computeSize(AP.getDwarfFormParams());
84 return MachineReg ==
TRI.getFrameRegister(*AP.MF);
97 CU(
CU), SplitLineTable(SplitLineTable) {}
106int64_t DwarfUnit::getDefaultLowerBound()
const {
112 case dwarf::DW_LANG_C:
113 case dwarf::DW_LANG_C89:
114 case dwarf::DW_LANG_C_plus_plus:
117 case dwarf::DW_LANG_Fortran77:
118 case dwarf::DW_LANG_Fortran90:
122 case dwarf::DW_LANG_C99:
123 case dwarf::DW_LANG_ObjC:
124 case dwarf::DW_LANG_ObjC_plus_plus:
129 case dwarf::DW_LANG_Fortran95:
135 case dwarf::DW_LANG_D:
136 case dwarf::DW_LANG_Java:
137 case dwarf::DW_LANG_Python:
138 case dwarf::DW_LANG_UPC:
143 case dwarf::DW_LANG_Ada83:
144 case dwarf::DW_LANG_Ada95:
145 case dwarf::DW_LANG_Cobol74:
146 case dwarf::DW_LANG_Cobol85:
147 case dwarf::DW_LANG_Modula2:
148 case dwarf::DW_LANG_Pascal83:
149 case dwarf::DW_LANG_PLI:
155 case dwarf::DW_LANG_BLISS:
156 case dwarf::DW_LANG_C11:
157 case dwarf::DW_LANG_C_plus_plus_03:
158 case dwarf::DW_LANG_C_plus_plus_11:
159 case dwarf::DW_LANG_C_plus_plus_14:
160 case dwarf::DW_LANG_Dylan:
161 case dwarf::DW_LANG_Go:
162 case dwarf::DW_LANG_Haskell:
163 case dwarf::DW_LANG_OCaml:
164 case dwarf::DW_LANG_OpenCL:
165 case dwarf::DW_LANG_RenderScript:
166 case dwarf::DW_LANG_Rust:
167 case dwarf::DW_LANG_Swift:
172 case dwarf::DW_LANG_Fortran03:
173 case dwarf::DW_LANG_Fortran08:
174 case dwarf::DW_LANG_Julia:
175 case dwarf::DW_LANG_Modula3:
198 if (
DD->getDwarfVersion() == 2)
200 if (isDwoUnit() && !
DD->shareAcrossDWOCUs())
204 !
DD->generateTypeUnits();
209 return DU->getDIE(
D);
226 if (
DD->getDwarfVersion() >= 4)
233 std::optional<dwarf::Form> Form, uint64_t
Integer) {
236 assert(Form != dwarf::DW_FORM_implicit_const &&
237 "DW_FORM_implicit_const is used only for signed integers");
254 for (
int i = 0; i < NumBytes; i++) {
257 c = Ptr64[i / 8] >> (8 * (i & 7));
259 c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
273 std::optional<dwarf::Form>
Form;
274 std::optional<APInt> Widened;
276 if (NumBytes > 16 ||
DD->getDwarfVersion() < 5) {
283 Widened = Val.
zext(128);
285 Widened = Val.
sext(128);
288 Form = dwarf::DW_FORM_data16;
291 addIntToBlock(*
Block, Widened ? *Widened : Val);
292 Block->computeSize(
Asm->getDwarfFormParams());
294 if (!
Form.has_value()) {
301 bool Unsigned, std::optional<dwarf::Form> Form) {
303 if (CIBitWidth <= 64) {
315 std::optional<dwarf::Form> Form, int64_t
Integer) {
328 if (
CUNode->isDebugDirectivesOnly())
331 if (
DD->useInlineStrings()) {
338 isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp;
340 auto StringPoolEntry =
342 ?
DU->getStringPool().getIndexedEntry(*
Asm,
String)
347 IxForm = dwarf::DW_FORM_strx1;
348 unsigned Index = StringPoolEntry.getIndex();
349 if (Index > 0xffffff)
350 IxForm = dwarf::DW_FORM_strx4;
351 else if (Index > 0xffff)
352 IxForm = dwarf::DW_FORM_strx3;
353 else if (Index > 0xff)
354 IxForm = dwarf::DW_FORM_strx2;
373unsigned DwarfTypeUnit::getOrCreateSourceID(
const DIFile *File) {
376 if (!UsedLineTable) {
377 UsedLineTable =
true;
381 return SplitLineTable->
getFile(
387 bool UseAddrOffsetFormOrExpressions =
388 DD->useAddrOffsetForm() ||
DD->useAddrOffsetExpressions();
391 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
392 Base =
DD->getSectionLabel(&Label->getSection());
396 if (
DD->getDwarfVersion() >= 5) {
397 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx);
398 addUInt(Die, dwarf::DW_FORM_addrx, Index);
400 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
401 addUInt(Die, dwarf::DW_FORM_GNU_addr_index, Index);
405 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_const4u);
407 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
412 if (
DD->getDwarfVersion() >= 5) {
417 if (
DD->useSplitDwarf()) {
422 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
423 addLabel(Die, dwarf::DW_FORM_addr, Sym);
441 addFlag(Die, dwarf::DW_AT_declaration);
443 addAttribute(Die, dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
450 const DIEUnit *EntryCU = Entry.getEntry().getUnit();
456 assert(EntryCU ==
CU || !
DD->useSplitDwarf() ||
DD->shareAcrossDWOCUs() ||
459 EntryCU ==
CU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
471 Loc->computeSize(
Asm->getDwarfFormParams());
478 Block->computeSize(
Asm->getDwarfFormParams());
503 addUInt(Die, dwarf::DW_AT_decl_file, std::nullopt, FileID);
504 addUInt(Die, dwarf::DW_AT_decl_line, std::nullopt, Line);
507 addUInt(Die, dwarf::DW_AT_decl_column, std::nullopt, Column);
531 addSourceLine(Die, L->getLine(), L->getColumn(), L->getFile());
569 addUInt(Die, dwarf::DW_AT_const_value,
570 Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
579 if (CIBitWidth <= 64) {
585 addIntAsBlock(Die, dwarf::DW_AT_const_value, Val,
Unsigned);
591 DD->getDwarfVersion() >= 4 ? dwarf::DW_AT_linkage_name
592 : dwarf::DW_AT_MIPS_linkage_name,
598 for (
const auto *Element : TParams) {
600 constructTemplateTypeParameterDIE(Buffer, TTP);
602 constructTemplateValueParameterDIE(Buffer, TVP);
608 for (
const auto *Ty : ThrownTypes) {
616 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
619 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
622 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
641 auto *Context = Ty->getScope();
661 auto construct = [&](
const auto *Ty) {
667 if (
DD->generateTypeUnits() && !Ty->isForwardDecl() &&
668 (Ty->getRawName() || CTy->getRawIdentifier())) {
670 if (
MDString *TypeId = CTy->getRawIdentifier()) {
672 DD->addDwarfTypeUnitType(
getCU(), TypeId->getString(), TyDIE, CTy);
675 finishNonUnitTypeDIE(TyDIE, CTy);
689 constructSubrangeDIE(TyDIE, SRTy);
703 if (Ty->getTag() == dwarf::DW_TAG_restrict_type &&
DD->getDwarfVersion() <= 2)
707 if (Ty->getTag() == dwarf::DW_TAG_atomic_type &&
DD->getDwarfVersion() < 5)
712 auto *Context = Ty->getScope();
720 ->createTypeDIE(Context, *ContextDIE, Ty);
728 const DIType *NameSource = Ty;
731 NameSource = CT ? CT->getSpecification() :
nullptr;
736 if (Ty->isForwardDecl())
745 if (CT->getRuntimeLang() == 0 || CT->isObjcClassComplete())
749 DD->addAccelType(*
this,
CUNode->getNameTableKind(), Name, TyDIE, Flags);
752 if (Name != CT->getIdentifier() &&
753 CT->getRuntimeLang() == dwarf::DW_LANG_Swift)
754 DD->addAccelType(*
this,
CUNode->getNameTableKind(), CT->getIdentifier(),
760 if (!Ty->getName().empty())
773 assert(Ty &&
"Trying to add a type that doesn't exist?");
779 const auto &Lang = getLanguage();
781 if (!Lang.hasVersionedName())
801 Parents.push_back(Context);
815 Name =
"(anonymous namespace)";
829 addString(Buffer, dwarf::DW_AT_name, Name);
832 if (BTy->
getTag() == dwarf::DW_TAG_unspecified_type)
835 if (BTy->
getTag() != dwarf::DW_TAG_string_type)
836 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
840 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, SizeInBytes);
841 if (BTy->
getTag() == dwarf::Tag::DW_TAG_base_type) {
849 DataSizeInBits && DataSizeInBits != SizeInBytes * 8)
850 addUInt(Buffer, dwarf::DW_AT_bit_size, std::nullopt, DataSizeInBits);
854 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_big);
856 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_little);
859 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
860 NumExtraInhabitants);
868 addSInt(Buffer, dwarf::DW_AT_binary_scale, dwarf::DW_FORM_sdata,
871 addSInt(Buffer, dwarf::DW_AT_decimal_scale, dwarf::DW_FORM_sdata,
892 addString(Buffer, dwarf::DW_AT_name, Name);
894 if (DIVariable *Var = STy->getStringLength()) {
895 if (
auto *VarDIE =
getDIE(Var))
896 addDIEEntry(Buffer, dwarf::DW_AT_string_length, *VarDIE);
897 }
else if (DIExpression *Expr = STy->getStringLengthExp()) {
898 addBlock(Buffer, dwarf::DW_AT_string_length, Expr);
901 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
904 if (DIExpression *Expr = STy->getStringLocationExp()) {
905 addBlock(Buffer, dwarf::DW_AT_data_location, Expr);
908 if (STy->getEncoding()) {
910 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
914 if (STy->getCharType())
915 addType(Buffer, STy->getCharType());
925 const DIType *FromTy = DTy->getBaseType();
931 addString(Buffer, dwarf::DW_AT_name, Name);
937 if (
Tag == dwarf::DW_TAG_typedef &&
DD->getDwarfVersion() >= 5) {
939 if (AlignInBytes > 0)
940 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
945 if (
Size &&
Tag != dwarf::DW_TAG_pointer_type
946 &&
Tag != dwarf::DW_TAG_ptr_to_member_type
947 &&
Tag != dwarf::DW_TAG_reference_type
948 &&
Tag != dwarf::DW_TAG_rvalue_reference_type)
949 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
951 if (
Tag == dwarf::DW_TAG_ptr_to_member_type)
964 if (std::optional<unsigned> AS = DTy->getDWARFAddressSpace())
965 addUInt(Buffer,
Asm->getTypeAddressSpaceAttribute(), dwarf::DW_FORM_data4,
969 if (
Tag == dwarf::DW_TAG_template_alias)
972 if (
auto PtrAuthData = DTy->getPtrAuthData()) {
973 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_key, dwarf::DW_FORM_data1,
975 if (PtrAuthData->isAddressDiscriminated())
976 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_address_discriminated);
977 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_extra_discriminator,
978 dwarf::DW_FORM_data2, PtrAuthData->extraDiscriminator());
979 if (PtrAuthData->isaPointer())
980 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_isa_pointer);
981 if (PtrAuthData->authenticatesNullValues())
982 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_authenticates_null_values);
986std::optional<unsigned>
989 std::optional<unsigned> ObjectPointerIndex;
990 for (
unsigned i = 1,
N = Args.size(); i <
N; ++i) {
991 const DIType *Ty = Args[i];
993 assert(i ==
N-1 &&
"Unspecified parameter must be the last argument");
998 if (Ty->isArtificial())
999 addFlag(Arg, dwarf::DW_AT_artificial);
1001 if (Ty->isObjectPointer()) {
1002 assert(!ObjectPointerIndex &&
1003 "Can't have more than one object pointer");
1004 ObjectPointerIndex = i;
1009 return ObjectPointerIndex;
1015 if (Elements.size())
1016 if (
auto RTy = Elements[0])
1019 bool isPrototyped =
true;
1020 if (Elements.size() == 2 && !Elements[1])
1021 isPrototyped =
false;
1028 addFlag(Buffer, dwarf::DW_AT_prototyped);
1031 if (CTy->
getCC() && CTy->
getCC() != dwarf::DW_CC_normal)
1032 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
1036 addFlag(Buffer, dwarf::DW_AT_reference);
1039 addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
1052 addString(AnnotationDie, dwarf::DW_AT_name, Name->getString());
1054 addString(AnnotationDie, dwarf::DW_AT_const_value,
Data->getString());
1059 assert(
false &&
"Unsupported annotation value type");
1063void DwarfUnit::addDiscriminant(
DIE &Variant,
Constant *Discriminant,
1066 addInt(Variant, dwarf::DW_AT_discr_value, CI->getValue(), IsUnsigned);
1067 }
else if (
const auto *CA =
1070 unsigned NElems = CA->getNumElements();
1071 if (NElems % 2 != 0) {
1077 auto AddInt = [&](
const APInt &Val) {
1084 for (
unsigned I = 0;
I < NElems;
I += 2) {
1085 APInt LV = CA->getElementAsAPInt(
I);
1086 APInt HV = CA->getElementAsAPInt(
I + 1);
1107 case dwarf::DW_TAG_array_type:
1108 constructArrayTypeDIE(Buffer, CTy);
1110 case dwarf::DW_TAG_enumeration_type:
1111 constructEnumTypeDIE(Buffer, CTy);
1113 case dwarf::DW_TAG_variant_part:
1114 case dwarf::DW_TAG_variant:
1115 case dwarf::DW_TAG_structure_type:
1116 case dwarf::DW_TAG_union_type:
1117 case dwarf::DW_TAG_class_type:
1118 case dwarf::DW_TAG_namelist: {
1121 if (
Tag == dwarf::DW_TAG_variant_part) {
1123 if (Discriminator) {
1135 if (DiscDIE ==
nullptr) {
1136 DiscDIE = &constructMemberDIE(Buffer, Discriminator);
1138 addDIEEntry(Buffer, dwarf::DW_AT_discr, *DiscDIE);
1143 if (
Tag == dwarf::DW_TAG_class_type ||
1144 Tag == dwarf::DW_TAG_structure_type ||
1145 Tag == dwarf::DW_TAG_union_type) {
1146 if (!(
DD->useSplitDwarf() && !
getCU().getSkeleton()) ||
1153 for (
const auto *Element : Elements) {
1159 if (DDTy->getTag() == dwarf::DW_TAG_friend) {
1161 addType(ElemDie, DDTy->getBaseType(), dwarf::DW_AT_friend);
1162 }
else if (DDTy->isStaticMember()) {
1164 }
else if (
Tag == dwarf::DW_TAG_variant_part) {
1168 if (
Constant *CI = DDTy->getDiscriminantValue()) {
1169 addDiscriminant(Variant, CI,
1170 DD->isUnsignedDIType(Discriminator->getBaseType()));
1175 if (
auto *Composite =
1177 Composite !=
nullptr &&
1178 Composite->getTag() == dwarf::DW_TAG_variant) {
1181 constructMemberDIE(Variant, DDTy);
1184 constructMemberDIE(Buffer, DDTy);
1188 StringRef PropertyName = Property->getName();
1189 addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
1190 if (Property->getType())
1191 addType(ElemDie, Property->getType());
1193 StringRef GetterName = Property->getGetterName();
1194 if (!GetterName.
empty())
1195 addString(ElemDie, dwarf::DW_AT_APPLE_property_getter, GetterName);
1196 StringRef SetterName = Property->getSetterName();
1197 if (!SetterName.
empty())
1198 addString(ElemDie, dwarf::DW_AT_APPLE_property_setter, SetterName);
1199 if (
unsigned PropertyAttributes = Property->getAttributes())
1200 addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, std::nullopt,
1201 PropertyAttributes);
1203 constructPropertyDIE(Buffer, Property);
1205 if (Composite->getTag() == dwarf::DW_TAG_variant_part) {
1209 }
else if (
Tag == dwarf::DW_TAG_namelist) {
1210 auto *VarDIE =
getDIE(Element);
1213 addDIEEntry(ItemDie, dwarf::DW_AT_namelist_item, *VarDIE);
1219 addFlag(Buffer, dwarf::DW_AT_APPLE_block);
1222 addFlag(Buffer, dwarf::DW_AT_export_symbols);
1233 addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
1237 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 5) {
1240 CC = dwarf::DW_CC_pass_by_value;
1242 CC = dwarf::DW_CC_pass_by_reference;
1244 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
1260 addString(Buffer, dwarf::DW_AT_name, Name);
1268 if (
Tag == dwarf::DW_TAG_enumeration_type ||
1269 Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
1270 Tag == dwarf::DW_TAG_union_type) {
1272 if (
auto *VarDIE =
getDIE(Var))
1273 addDIEEntry(Buffer, dwarf::DW_AT_bit_size, *VarDIE);
1274 }
else if (
auto *Exp =
1276 addBlock(Buffer, dwarf::DW_AT_bit_size, Exp);
1284 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
1287 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, 0);
1292 addFlag(Buffer, dwarf::DW_AT_declaration);
1304 addUInt(Buffer, dwarf::DW_AT_APPLE_runtime_class, dwarf::DW_FORM_data1,
1309 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1313 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
1314 NumExtraInhabitants);
1318void DwarfUnit::constructTemplateTypeParameterDIE(
1327 if (TP->
isDefault() && isCompatibleWithVersion(5))
1328 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1331void DwarfUnit::constructTemplateValueParameterDIE(
1337 if (VP->
getTag() == dwarf::DW_TAG_template_value_parameter)
1341 if (VP->
isDefault() && isCompatibleWithVersion(5))
1342 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1351 if (!GV->hasDLLImportStorageClass()) {
1358 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
1361 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1363 addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
1365 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1384 Name =
"(anonymous namespace)";
1385 DD->addAccelNamespace(*
this,
CUNode->getNameTableKind(), Name, NDie);
1388 addFlag(NDie, dwarf::DW_AT_export_symbols);
1401 if (!M->getName().empty()) {
1402 addString(MDie, dwarf::DW_AT_name, M->getName());
1405 if (!M->getConfigurationMacros().empty())
1406 addString(MDie, dwarf::DW_AT_LLVM_config_macros,
1407 M->getConfigurationMacros());
1408 if (!M->getIncludePath().empty())
1409 addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
1410 if (!M->getAPINotesFile().empty())
1411 addString(MDie, dwarf::DW_AT_LLVM_apinotes, M->getAPINotesFile());
1413 addUInt(MDie, dwarf::DW_AT_decl_file, std::nullopt,
1416 addUInt(MDie, dwarf::DW_AT_decl_line, std::nullopt, M->getLineNo());
1418 addFlag(MDie, dwarf::DW_AT_declaration);
1424 const Function *FnHint,
bool Minimal) {
1434 if (
auto *SPDecl = SP->getDeclaration()) {
1453 if (SP->isDefinition())
1457 ->applySubprogramAttributes(SP, SPDie);
1462 DIE &SPDie,
bool Minimal) {
1463 DIE *DeclDie =
nullptr;
1465 if (
auto *SPDecl = SP->getDeclaration()) {
1467 DITypeArray DeclArgs, DefinitionArgs;
1468 DeclArgs = SPDecl->getType()->getTypeArray();
1469 DefinitionArgs = SP->getType()->getTypeArray();
1471 if (DeclArgs.size() && DefinitionArgs.size())
1472 if (DefinitionArgs[0] !=
nullptr && DeclArgs[0] != DefinitionArgs[0])
1473 addType(SPDie, DefinitionArgs[0]);
1475 DeclDie =
getDIE(SPDecl);
1476 assert(DeclDie &&
"This DIE should've already been constructed when the "
1477 "definition DIE was created in "
1478 "getOrCreateSubprogramDIE");
1480 if (
DD->useAllLinkageNames())
1481 DeclLinkageName = SPDecl->getLinkageName();
1484 if (DeclID != DefID)
1485 addUInt(SPDie, dwarf::DW_AT_decl_file, std::nullopt, DefID);
1487 if (SP->getLine() != SPDecl->getLine())
1488 addUInt(SPDie, dwarf::DW_AT_decl_line, std::nullopt, SP->getLine());
1493 if (!Minimal || SP->isNameSimplified())
1500 (
DD->useAllLinkageNames() ||
DU->getAbstractScopeDIEs().lookup(SP)))
1508 addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
1513 bool SkipSPAttributes) {
1516 bool SkipSPSourceLocation = SkipSPAttributes &&
1517 !
CUNode->getDebugInfoForProfiling();
1518 if (!SkipSPSourceLocation)
1523 if (!SP->getName().empty())
1524 addString(SPDie, dwarf::DW_AT_name, SP->getName());
1528 if (!SkipSPSourceLocation)
1532 if (SkipSPAttributes)
1538 addFlag(SPDie, dwarf::DW_AT_prototyped);
1540 if (SP->isObjCDirect())
1541 addFlag(SPDie, dwarf::DW_AT_APPLE_objc_direct);
1546 Args = SPTy->getTypeArray();
1551 if (
CC &&
CC != dwarf::DW_CC_normal)
1552 addUInt(SPDie, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
CC);
1557 if (
auto Ty = Args[0])
1560 unsigned VK = SP->getVirtuality();
1562 addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
1563 if (SP->getVirtualIndex() != -1u) {
1565 addUInt(*
Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1566 addUInt(*
Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1572 if (!SP->isDefinition()) {
1573 addFlag(SPDie, dwarf::DW_AT_declaration);
1580 if (std::optional<unsigned> ObjectPointerIndex =
1586 assert(*ObjectPointerIndex > 0);
1587 addSInt(SPDie, dwarf::DW_AT_object_pointer,
1588 dwarf::DW_FORM_implicit_const, *ObjectPointerIndex - 1);
1595 if (SP->isArtificial())
1596 addFlag(SPDie, dwarf::DW_AT_artificial);
1598 if (!SP->isLocalToUnit())
1599 addFlag(SPDie, dwarf::DW_AT_external);
1601 if (SP->isOptimized())
1602 addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
1604 if (
DD->useAppleExtensionAttributes())
1605 if (
unsigned isa =
Asm->getISAEncoding())
1606 addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag,
isa);
1608 if (SP->isLValueReference())
1609 addFlag(SPDie, dwarf::DW_AT_reference);
1611 if (SP->isRValueReference())
1612 addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
1614 if (SP->isNoReturn())
1615 addFlag(SPDie, dwarf::DW_AT_noreturn);
1619 if (SP->isExplicit())
1620 addFlag(SPDie, dwarf::DW_AT_explicit);
1622 if (SP->isMainSubprogram())
1623 addFlag(SPDie, dwarf::DW_AT_main_subprogram);
1625 addFlag(SPDie, dwarf::DW_AT_pure);
1626 if (SP->isElemental())
1627 addFlag(SPDie, dwarf::DW_AT_elemental);
1628 if (SP->isRecursive())
1629 addFlag(SPDie, dwarf::DW_AT_recursive);
1631 if (!SP->getTargetFuncName().empty())
1632 addString(SPDie, dwarf::DW_AT_trampoline, SP->getTargetFuncName());
1634 if (
DD->getDwarfVersion() >= 5 && SP->isDeleted())
1635 addFlag(SPDie, dwarf::DW_AT_deleted);
1642 addString(DW_Subrange, dwarf::DW_AT_name, Name);
1644 bool IsUnsigned =
false;
1653 addUInt(DW_Subrange, dwarf::DW_AT_byte_size, std::nullopt,
Size >> 3);
1655 addUInt(DW_Subrange, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1659 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1662 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1663 dwarf::DW_END_little);
1667 int64_t DefaultLowerBound = getDefaultLowerBound();
1668 dwarf::Form Form = IsUnsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata;
1673 if (
auto *VarDIE =
getDIE(BV))
1676 if (
auto *DTDIE =
getDIE(DT))
1681 const APInt &
Value = BI->getValue();
1682 if (Attr == dwarf::DW_AT_GNU_bias) {
1684 addInt(DW_Subrange, Attr,
Value, IsUnsigned, Form);
1685 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1686 Value != DefaultLowerBound || !ForArray)
1687 addInt(DW_Subrange, Attr,
Value, IsUnsigned, Form);
1691 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1693 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1695 AddBoundTypeEntry(dwarf::DW_AT_bit_stride, SR->
getStride());
1697 AddBoundTypeEntry(dwarf::DW_AT_GNU_bias, SR->
getBias());
1700void DwarfUnit::constructSubrangeDIE(
DIE &Buffer,
const DISubrange *SR) {
1701 DIE &DW_Subrange =
createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
1703 DIE *IdxTy = getIndexTyDie();
1704 addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IdxTy);
1710 int64_t DefaultLowerBound = getDefaultLowerBound();
1713 DISubrange::BoundType Bound) ->
void {
1715 if (
auto *VarDIE =
getDIE(BV))
1720 if (Attr == dwarf::DW_AT_count) {
1721 if (BI->getSExtValue() != -1)
1722 addUInt(DW_Subrange, Attr, std::nullopt, BI->getSExtValue());
1723 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1724 BI->getSExtValue() != DefaultLowerBound)
1725 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1729 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1731 AddBoundTypeEntry(dwarf::DW_AT_count, SR->
getCount());
1733 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1735 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, SR->
getStride());
1738void DwarfUnit::constructGenericSubrangeDIE(
DIE &Buffer,
1740 DIE &DwGenericSubrange =
1745 DIE *IdxTy = getIndexTyDie();
1746 addDIEEntry(DwGenericSubrange, dwarf::DW_AT_type, *IdxTy);
1748 int64_t DefaultLowerBound = getDefaultLowerBound();
1753 if (
auto *VarDIE =
getDIE(BV))
1756 if (BE->isConstant() &&
1758 *BE->isConstant()) {
1759 if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1760 static_cast<int64_t
>(BE->getElement(1)) != DefaultLowerBound)
1761 addSInt(DwGenericSubrange, Attr, dwarf::DW_FORM_sdata,
1764 addBlock(DwGenericSubrange, Attr, BE);
1769 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, GSR->
getLowerBound());
1770 AddBoundTypeEntry(dwarf::DW_AT_count, GSR->
getCount());
1771 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, GSR->
getUpperBound());
1772 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, GSR->
getStride());
1775DIE *DwarfUnit::getIndexTyDie() {
1780 StringRef
Name =
"__ARRAY_SIZE_TYPE__";
1794 assert(CTy && CTy->
isVector() &&
"Composite type is not a vector");
1799 assert(BaseTy &&
"Unknown vector element type.");
1804 assert(Elements.size() == 1 &&
1805 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type &&
1806 "Invalid vector element array, expected one element of type subrange");
1808 const auto NumVecElements =
1809 Subrange->getCount()
1815 assert(ActualSize >= (NumVecElements * ElementSize) &&
"Invalid vector size");
1816 return ActualSize != (NumVecElements * ElementSize);
1821 addFlag(Buffer, dwarf::DW_AT_GNU_vector);
1823 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
1828 if (
auto *VarDIE =
getDIE(Var))
1829 addDIEEntry(Buffer, dwarf::DW_AT_data_location, *VarDIE);
1831 addBlock(Buffer, dwarf::DW_AT_data_location, Expr);
1835 if (
auto *VarDIE =
getDIE(Var))
1836 addDIEEntry(Buffer, dwarf::DW_AT_associated, *VarDIE);
1838 addBlock(Buffer, dwarf::DW_AT_associated, Expr);
1842 if (
auto *VarDIE =
getDIE(Var))
1843 addDIEEntry(Buffer, dwarf::DW_AT_allocated, *VarDIE);
1845 addBlock(Buffer, dwarf::DW_AT_allocated, Expr);
1849 addSInt(Buffer, dwarf::DW_AT_rank, dwarf::DW_FORM_sdata,
1850 RankConst->getSExtValue());
1851 }
else if (
auto *RankExpr = CTy->
getRankExp()) {
1852 addBlock(Buffer, dwarf::DW_AT_rank, RankExpr);
1856 addUInt(Buffer, dwarf::DW_AT_bit_stride, {}, BitStride->getZExtValue());
1864 for (DINode *
E : Elements) {
1867 constructSubrangeDIE(TyDIE, Element,
true);
1869 constructSubrangeDIE(Buffer, Element);
1871 constructGenericSubrangeDIE(Buffer, Element);
1877 bool IsUnsigned = DTy &&
DD->isUnsignedDIType(DTy);
1879 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 3)
1881 if (
DD->getDwarfVersion() >= 4 && (CTy->
getFlags() & DINode::FlagEnumClass))
1882 addFlag(Buffer, dwarf::DW_AT_enum_class);
1886 addUInt(Buffer, dwarf::DW_AT_APPLE_enum_kind, dwarf::DW_FORM_data1, *Kind);
1894 for (
const DINode *
E : Elements) {
1901 if (IndexEnumerators)
1909 DIE &SPDie = *
P.first;
1916 addDIEEntry(SPDie, dwarf::DW_AT_containing_type, *NDie);
1924 addString(MemberDie, dwarf::DW_AT_name, Name);
1928 if (
DIType *Resolved = DT->getBaseType())
1940 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
1941 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1942 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1944 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_minus);
1945 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1946 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
1948 addBlock(MemberDie, dwarf::DW_AT_data_member_location, VBaseLocationDie);
1959 if (
auto *VarDIE =
getDIE(Var))
1960 addDIEEntry(MemberDie, dwarf::DW_AT_bit_size, *VarDIE);
1962 addBlock(MemberDie, dwarf::DW_AT_bit_size, Exp);
1965 FieldSize =
DD->getBaseTypeSize(DT);
1968 if (
DD->useDWARF2Bitfields())
1969 addUInt(MemberDie, dwarf::DW_AT_byte_size, std::nullopt,
1971 addUInt(MemberDie, dwarf::DW_AT_bit_size, std::nullopt,
Size);
1979 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 6) {
1980 if (
auto *VarDIE =
getDIE(Var))
1981 addDIEEntry(MemberDie, dwarf::DW_AT_data_bit_offset, *VarDIE);
1983 }
else if (
auto *Expr =
1985 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 6) {
1986 addBlock(MemberDie, dwarf::DW_AT_data_bit_offset, Expr);
1994 (
uint64_t)std::numeric_limits<int64_t>::max());
1999 uint32_t AlignInBits = FieldSize;
2000 uint32_t AlignMask = ~(AlignInBits - 1);
2003 uint64_t StartBitOffset = Offset - (Offset & AlignMask);
2006 OffsetInBytes = (Offset - StartBitOffset) / 8;
2008 if (
DD->useDWARF2Bitfields()) {
2009 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
2010 uint64_t FieldOffset = (HiMark - FieldSize);
2011 Offset -= FieldOffset;
2014 if (
Asm->getDataLayout().isLittleEndian())
2015 Offset = FieldSize - (Offset +
Size);
2018 addSInt(MemberDie, dwarf::DW_AT_bit_offset, dwarf::DW_FORM_sdata,
2021 addUInt(MemberDie, dwarf::DW_AT_bit_offset, std::nullopt,
2023 OffsetInBytes = FieldOffset >> 3;
2025 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, std::nullopt,
2032 addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
2036 if (
DD->getDwarfVersion() <= 2) {
2038 addUInt(*MemLocationDie, dwarf::DW_FORM_data1,
2039 dwarf::DW_OP_plus_uconst);
2040 addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
2041 addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
2042 }
else if (!IsBitfield ||
DD->useDWARF2Bitfields()) {
2047 if (
DD->getDwarfVersion() == 3)
2048 addUInt(MemberDie, dwarf::DW_AT_data_member_location,
2049 dwarf::DW_FORM_udata, OffsetInBytes);
2051 addUInt(MemberDie, dwarf::DW_AT_data_member_location, std::nullopt,
2060 addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1,
2061 dwarf::DW_VIRTUALITY_virtual);
2065 if (DIE *PDie =
getDIE(PNode))
2067 dwarf::DW_FORM_ref4, DIEEntry(*PDie));
2070 addFlag(MemberDie, dwarf::DW_AT_artificial);
2075void DwarfUnit::constructPropertyDIE(
DIE &Buffer,
const DIProperty *
P) {
2077 addString(PropertyDie, dwarf::DW_AT_name,
P->getName());
2078 if (DIType *Ty =
P->getType())
2082 if (DINode *BackingStorage =
P->getBackingStorage()) {
2091 DIE &GetterDie = *
P.first;
2098 addDIEEntry(GetterDie, dwarf::DW_AT_property_forward, *TargetDie);
2110 "Static member should belong to a type.");
2113 return StaticMemberDIE;
2118 const DIType *Ty = DT->getBaseType();
2123 addFlag(StaticMemberDIE, dwarf::DW_AT_external);
2124 addFlag(StaticMemberDIE, dwarf::DW_AT_declaration);
2128 addFlag(StaticMemberDIE, dwarf::DW_AT_artificial);
2139 else if (
auto *CDS =
2141 assert(CDS->getElementType()->isIntegerTy() &&
2142 "Non-integer arrays not supported.");
2144 for (
unsigned I = 0;
I != CDS->getNumElements(); ++
I)
2145 addIntToBlock(*
Block, CDS->getElementAsAPInt(
I));
2146 Block->computeSize(
Asm->getDwarfFormParams());
2147 addBlock(StaticMemberDIE, dwarf::DW_AT_const_value,
Block->BestForm(),
2152 addUInt(StaticMemberDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
2155 return &StaticMemberDIE;
2160 if (!
DD->useSectionsAsReferences())
2162 isDwoUnit() ?
"debug_info_dwo" :
"debug_info",
"Length of Unit");
2167 Asm->OutStreamer->AddComment(
"DWARF version number");
2168 unsigned Version =
DD->getDwarfVersion();
2173 Asm->OutStreamer->AddComment(
"DWARF Unit Type");
2175 Asm->OutStreamer->AddComment(
"Address Size (in bytes)");
2176 Asm->emitInt8(
Asm->MAI.getCodePointerSize());
2182 Asm->OutStreamer->AddComment(
"Offset Into Abbrev. Section");
2185 Asm->emitDwarfLengthOrOffset(0);
2187 Asm->emitDwarfSymbolReference(
2191 Asm->OutStreamer->AddComment(
"Address Size (in bytes)");
2192 Asm->emitInt8(
Asm->MAI.getCodePointerSize());
2197 if (!
DD->useSplitDwarf()) {
2202 DD->useSplitDwarf() ? dwarf::DW_UT_split_type
2203 : dwarf::DW_UT_type);
2204 Asm->OutStreamer->AddComment(
"Type Signature");
2205 Asm->OutStreamer->emitIntValue(TypeSignature,
sizeof(TypeSignature));
2206 Asm->OutStreamer->AddComment(
"Type DIE Offset");
2208 Asm->emitDwarfLengthOrOffset(Ty ? Ty->getOffset() : 0);
2221 if (
Asm->doesDwarfUseRelocationsAcrossSections() && !isDwoUnit())
2224 addSectionDelta(Die,
Attribute, Label, Sec);
2227bool DwarfTypeUnit::isDwoUnit()
const {
2254 DU->getStringOffsetsStartSym(),
2259 assert(
DD->getDwarfVersion() >= 5 &&
2260 "DW_AT_rnglists_base requires DWARF version 5 or later");
2263 DU->getRnglistsTableBaseSym(),
2271bool DwarfUnit::isCompatibleWithVersion(
uint16_t Version)
const {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static unsigned getDwarfVersion(const MachineFunction &MF)
Resolve the DWARF version the way DwarfDebug does.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool hasVectorBeenPadded(const DICompositeType *CTy)
Returns true if the vector's size differs from the sum of sizes of elements the user specified.
Register const TargetRegisterInfo * TRI
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.
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
uint64_t getZExtValue() const
Get zero extended value.
unsigned getActiveBits() const
Compute the number of active bits in the value.
unsigned getBitWidth() const
Return the number of bits in the APInt.
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
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.
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.
MCSymbol * getSymbol(const GlobalValue *GV) const
TargetMachine & TM
Target machine description.
MCContext & OutContext
This is the context for the output file that we are streaming.
const DataLayout & getDataLayout() const
Return information about data layout.
bool doesDwarfUseRelocationsAcrossSections() const
Functions, function parameters, and return types can have attributes to indicate how they should be t...
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.
This is an important base class in LLVM.
Basic type, like 'int' or 'float'.
uint32_t getDataSizeInBits() const
unsigned getEncoding() const
DIExpression * getRankExp() const
DIExpression * getAssociatedExp() const
DIVariable * getAllocated() const
DIExpression * getDataLocationExp() const
DIVariable * getAssociated() const
DIDerivedType * getDiscriminator() const
DIVariable * getDataLocation() const
unsigned getRuntimeLang() const
DIType * getSpecification() const
StringRef getIdentifier() const
DINodeArray getElements() const
DITemplateParameterArray getTemplateParams() const
bool isNameSimplified() const
DIExpression * getAllocatedExp() const
ConstantInt * getBitStrideConst() const
std::optional< uint32_t > getEnumKind() const
DIType * getVTableHolder() const
DINodeArray getAnnotations() const
ConstantInt * getRankConst() const
MDString * getRawIdentifier() const
DIType * getBaseType() const
DINodeArray getAnnotations() const
Get annotations associated with this derived type.
DITemplateParameterArray getTemplateParams() const
Get the template parameters from a template alias.
DIObjCProperty * getObjCProperty() const
LLVM_ABI 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.
A container for string pool string values.
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
LLVM_ABI DIEUnit(dwarf::Tag UnitTag)
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
A structured debug information entry.
DIE & addChild(DIE *Child)
Add a child to the DIE.
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
LLVM_ABI DIEUnit * getUnit() const
Climb up the parent chain to get the unit that this DIE belongs to.
dwarf::Tag getTag() const
const APInt & getDenominator() const
LLVM_ABI bool isSigned() const
const APInt & getNumerator() const
LLVM_ABI BoundType getLowerBound() const
LLVM_ABI BoundType getCount() const
LLVM_ABI BoundType getUpperBound() const
PointerUnion< DIVariable *, DIExpression * > BoundType
LLVM_ABI 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.
LLVM_ABI dwarf::Tag getTag() const
A property of a class or structure.
Base class for scope-like contexts.
LLVM_ABI DIScope * getScope() const
String type, Fortran CHARACTER(n)
Subprogram description. Uses SubclassData1.
BoundType getLowerBound() const
BoundType getBias() const
PointerUnion< ConstantInt *, DIVariable *, DIExpression *, DIDerivedType * > BoundType
BoundType getUpperBound() const
DIType * getBaseType() const
Get the base type this is derived from.
BoundType getStride() const
LLVM_ABI BoundType getUpperBound() const
LLVM_ABI BoundType getStride() const
LLVM_ABI BoundType getLowerBound() const
LLVM_ABI BoundType getCount() const
Type array for a subprogram.
StringRef getName() const
Metadata * getValue() const
bool isLittleEndian() const
uint32_t getNumExtraInhabitants() const
bool isLValueReference() const
bool isObjcClassComplete() 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
Metadata * getRawSizeInBits() const
bool isRValueReference() const
bool isArtificial() const
bool getExportSymbols() const
DIScope * getScope() const
bool isTypePassByReference() const
Metadata * getRawOffsetInBits() const
bool isLittleEndian() const
Layout endianness...
static bool isUnsignedDIType(const DIType *Ty)
Return true if type encoding is unsigned.
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.
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
AddressPool & getAddressPool()
bool useSplitDwarf() const
Returns whether or not to change the current debug info for split DWARF.
virtual void disableTemporaryBuffer()=0
Disable emission to the temporary buffer.
virtual unsigned getTemporaryBufferSize()=0
Return the emitted size, in number of bytes, for the data stored in the temporary buffer.
void setMemoryLocationKind()
Lock this down to become a memory location description.
bool addExpression(DIExpressionCursor &&Expr)
Emit all remaining operations in the DIExpressionCursor.
virtual void commitTemporaryBuffer()=0
Commit the data stored in the temporary buffer to the main output.
DwarfExpression(unsigned DwarfVersion, DwarfCompileUnit &CU)
virtual void enableTemporaryBuffer()=0
Start emitting data to the temporary buffer.
DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID, MCDwarfDwoLineTable *SplitLineTable=nullptr)
void addGlobalTypeImpl(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.
virtual DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
DwarfDebug & getDwarfDebug() const
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.
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 updateAcceleratorTables(const DIScope *Context, const DIType *Ty, const DIE &TyDIE)
If this is a named finished type then include it in the list of types for the accelerator tables.
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 addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context)
DIE * createTypeDIE(const DIScope *Context, DIE &ContextDIE, const DIType *Ty)
Creates type DIE with specific context.
bool shouldPlaceInUnitDIE(const DISubprogram *SP, bool Minimal)
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.
virtual DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, const Function *FnHint, bool Minimal=false)
DIE * getOrCreateSubprogramContextDIE(const DISubprogram *SP, bool IgnoreScope)
virtual void addGlobalTypeImpl(const DIType *Ty, const DIE &Die, const DIScope *Context)=0
Add a new global type to the compile unit.
void addDIETypeSignature(DIE &Die, uint64_t Signature)
Add a type's DW_AT_signature and set the declaration flag.
virtual DwarfCompileUnit & getCU()=0
DIE * getDIE(const DINode *D) const
Returns the DIE map slot for the specified debug variable.
void constructPropertyForwardDIEs()
virtual unsigned getHeaderSize() const
Compute the size of a header for this unit, not including the initial length field.
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, unsigned Column, 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)
const DICompileUnit * getCUNode() const
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.
std::optional< unsigned > constructSubprogramArguments(DIE &Buffer, DITypeArray Args)
Construct function argument DIEs.
void addSectionOffset(DIE &Die, dwarf::Attribute Attribute, uint64_t Integer)
Add an offset into a section attribute data and value.
void addInt(DIE &Die, dwarf::Attribute Attribute, const APInt &Integer, bool Unsigned, std::optional< dwarf::Form > Form=std::nullopt)
Add an integer attribute data and value; value may be any width.
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.
unsigned UniqueID
A numeric ID unique among all CUs in the module.
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.
DenseMap< DIE *, const DINode * > PropertyForwardMap
llvm::dwarf::SourceLanguage getSourceLanguage() const
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',...
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
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.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
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...
Target - Wrapper for Target specific information.
LLVM Value Representation.
Calculates the starting offsets for various sections within the .debug_names section.
UnitType
Constants for unit types in DWARF v5.
std::optional< SourceLanguage > toDW_LANG(SourceLanguageName name, uint32_t version)
Convert a DWARF 6 pair of language name and version to a DWARF 5 DW_LANG.
bool isCPlusPlus(SourceLanguage S)
TypeKind getArrayIndexTypeEncoding(SourceLanguage S)
@ DW_FLAG_type_implementation
bool isC(SourceLanguage S)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto dyn_cast_if_present(const Y &Val)
dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case ...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
auto dyn_cast_or_null(const Y &Val)
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...
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
static LLVM_ABI bool mayHaveLocationExpr(dwarf::Attribute Attr)
Identifies DWARF attributes that may contain a reference to a DWARF expression.