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);
52void DIEDwarfExpression::emitUnsigned(uint64_t
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);
65 assert(!IsBuffering &&
"Already buffering?");
72 return TmpDIE.computeSize(AP.getDwarfFormParams());
79 return MachineReg ==
TRI.getFrameRegister(*AP.MF);
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:
188 if (isDwoUnit() && !
DD->shareAcrossDWOCUs())
192 !
DD->generateTypeUnits();
197 return DU->getDIE(
D);
214 if (
DD->getDwarfVersion() >= 4)
224 assert(Form != dwarf::DW_FORM_implicit_const &&
225 "DW_FORM_implicit_const is used only for signed integers");
244 for (
int i = 0; i < NumBytes; i++) {
247 c = Ptr64[i / 8] >> (8 * (i & 7));
249 c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
259 if (CIBitWidth <= 64) {
271 std::optional<dwarf::Form> Form, int64_t
Integer) {
284 if (
CUNode->isDebugDirectivesOnly())
287 if (
DD->useInlineStrings()) {
294 isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp;
296 auto StringPoolEntry =
298 ?
DU->getStringPool().getIndexedEntry(*
Asm,
String)
303 IxForm = dwarf::DW_FORM_strx1;
304 unsigned Index = StringPoolEntry.getIndex();
305 if (Index > 0xffffff)
306 IxForm = dwarf::DW_FORM_strx4;
307 else if (Index > 0xffff)
308 IxForm = dwarf::DW_FORM_strx3;
309 else if (Index > 0xff)
310 IxForm = dwarf::DW_FORM_strx2;
329unsigned DwarfTypeUnit::getOrCreateSourceID(
const DIFile *File) {
332 if (!UsedLineTable) {
333 UsedLineTable =
true;
337 return SplitLineTable->
getFile(
343 bool UseAddrOffsetFormOrExpressions =
344 DD->useAddrOffsetForm() ||
DD->useAddrOffsetExpressions();
347 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
348 Base =
DD->getSectionLabel(&Label->getSection());
352 if (
DD->getDwarfVersion() >= 5) {
353 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx);
354 addUInt(Die, dwarf::DW_FORM_addrx, Index);
356 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
357 addUInt(Die, dwarf::DW_FORM_GNU_addr_index, Index);
361 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_const4u);
363 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
368 if (
DD->getDwarfVersion() >= 5) {
373 if (
DD->useSplitDwarf()) {
378 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
379 addLabel(Die, dwarf::DW_FORM_addr, Sym);
397 addFlag(Die, dwarf::DW_AT_declaration);
399 addAttribute(Die, dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
406 const DIEUnit *EntryCU = Entry.getEntry().getUnit();
412 assert(EntryCU ==
CU || !
DD->useSplitDwarf() ||
DD->shareAcrossDWOCUs() ||
415 EntryCU ==
CU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
427 Loc->computeSize(
Asm->getDwarfFormParams());
434 Block->computeSize(
Asm->getDwarfFormParams());
450 addUInt(Die, dwarf::DW_AT_decl_file, std::nullopt, FileID);
451 addUInt(Die, dwarf::DW_AT_decl_line, std::nullopt, Line);
454 addUInt(Die, dwarf::DW_AT_decl_column, std::nullopt, Column);
478 addSourceLine(Die, L->getLine(), L->getColumn(), L->getFile());
510 addUInt(Die, dwarf::DW_AT_const_value,
511 Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
520 if (CIBitWidth <= 64) {
526 addIntAsBlock(Die, dwarf::DW_AT_const_value, Val);
532 DD->getDwarfVersion() >= 4 ? dwarf::DW_AT_linkage_name
533 : dwarf::DW_AT_MIPS_linkage_name,
539 for (
const auto *Element : TParams) {
541 constructTemplateTypeParameterDIE(Buffer, TTP);
543 constructTemplateValueParameterDIE(Buffer, TVP);
549 for (
const auto *Ty : ThrownTypes) {
557 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
560 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
563 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
582 auto *Context = Ty->getScope();
602 auto construct = [&](
const auto *Ty) {
608 if (
DD->generateTypeUnits() && !Ty->isForwardDecl() &&
609 (Ty->getRawName() || CTy->getRawIdentifier())) {
611 if (
MDString *TypeId = CTy->getRawIdentifier()) {
613 DD->addDwarfTypeUnitType(
getCU(), TypeId->getString(), TyDIE, CTy);
616 finishNonUnitTypeDIE(TyDIE, CTy);
630 constructSubrangeDIE(TyDIE, SRTy);
644 if (Ty->getTag() == dwarf::DW_TAG_restrict_type &&
DD->getDwarfVersion() <= 2)
648 if (Ty->getTag() == dwarf::DW_TAG_atomic_type &&
DD->getDwarfVersion() < 5)
653 auto *Context = Ty->getScope();
661 ->createTypeDIE(Context, *ContextDIE, Ty);
666 if (Ty->getName().empty())
668 if (Ty->isForwardDecl())
677 if (CT->getRuntimeLang() == 0 || CT->isObjcClassComplete())
681 DD->addAccelType(*
this,
CUNode->getNameTableKind(), Ty->getName(), TyDIE,
685 if (Ty->getName() != CT->getIdentifier() &&
686 CT->getRuntimeLang() == dwarf::DW_LANG_Swift)
687 DD->addAccelType(*
this,
CUNode->getNameTableKind(), CT->getIdentifier(),
702 assert(Ty &&
"Trying to add a type that doesn't exist?");
708 const auto &Lang = getLanguage();
710 if (!Lang.hasVersionedName())
730 Parents.push_back(Context);
744 Name =
"(anonymous namespace)";
758 addString(Buffer, dwarf::DW_AT_name, Name);
761 if (BTy->
getTag() == dwarf::DW_TAG_unspecified_type)
764 if (BTy->
getTag() != dwarf::DW_TAG_string_type)
765 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
769 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, SizeInBytes);
770 if (BTy->
getTag() == dwarf::Tag::DW_TAG_base_type) {
778 DataSizeInBits && DataSizeInBits != SizeInBytes * 8)
779 addUInt(Buffer, dwarf::DW_AT_bit_size, std::nullopt, DataSizeInBits);
783 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_big);
785 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_little);
788 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
789 NumExtraInhabitants);
797 addSInt(Buffer, dwarf::DW_AT_binary_scale, dwarf::DW_FORM_sdata,
800 addSInt(Buffer, dwarf::DW_AT_decimal_scale, dwarf::DW_FORM_sdata,
821 addString(Buffer, dwarf::DW_AT_name, Name);
824 if (
auto *VarDIE =
getDIE(Var))
825 addDIEEntry(Buffer, dwarf::DW_AT_string_length, *VarDIE);
828 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
832 DwarfExpr.setMemoryLocationKind();
833 DwarfExpr.addExpression(Expr);
834 addBlock(Buffer, dwarf::DW_AT_string_length, DwarfExpr.finalize());
837 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
842 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
845 DwarfExpr.setMemoryLocationKind();
846 DwarfExpr.addExpression(Expr);
847 addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
852 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
864 const DIType *FromTy = DTy->getBaseType();
870 addString(Buffer, dwarf::DW_AT_name, Name);
876 if (
Tag == dwarf::DW_TAG_typedef &&
DD->getDwarfVersion() >= 5) {
878 if (AlignInBytes > 0)
879 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
884 if (
Size &&
Tag != dwarf::DW_TAG_pointer_type
885 &&
Tag != dwarf::DW_TAG_ptr_to_member_type
886 &&
Tag != dwarf::DW_TAG_reference_type
887 &&
Tag != dwarf::DW_TAG_rvalue_reference_type)
888 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
890 if (
Tag == dwarf::DW_TAG_ptr_to_member_type)
903 if (DTy->getDWARFAddressSpace())
904 addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,
905 *DTy->getDWARFAddressSpace());
908 if (
Tag == dwarf::DW_TAG_template_alias)
911 if (
auto PtrAuthData = DTy->getPtrAuthData()) {
912 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_key, dwarf::DW_FORM_data1,
914 if (PtrAuthData->isAddressDiscriminated())
915 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_address_discriminated);
916 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_extra_discriminator,
917 dwarf::DW_FORM_data2, PtrAuthData->extraDiscriminator());
918 if (PtrAuthData->isaPointer())
919 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_isa_pointer);
920 if (PtrAuthData->authenticatesNullValues())
921 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_authenticates_null_values);
925std::optional<unsigned>
928 std::optional<unsigned> ObjectPointerIndex;
929 for (
unsigned i = 1,
N = Args.size(); i <
N; ++i) {
930 const DIType *Ty = Args[i];
932 assert(i ==
N-1 &&
"Unspecified parameter must be the last argument");
937 if (Ty->isArtificial())
938 addFlag(Arg, dwarf::DW_AT_artificial);
940 if (Ty->isObjectPointer()) {
941 assert(!ObjectPointerIndex &&
942 "Can't have more than one object pointer");
943 ObjectPointerIndex = i;
948 return ObjectPointerIndex;
955 if (
auto RTy = Elements[0])
958 bool isPrototyped =
true;
959 if (Elements.size() == 2 && !Elements[1])
960 isPrototyped =
false;
967 addFlag(Buffer, dwarf::DW_AT_prototyped);
970 if (CTy->
getCC() && CTy->
getCC() != dwarf::DW_CC_normal)
971 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
975 addFlag(Buffer, dwarf::DW_AT_reference);
978 addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
991 addString(AnnotationDie, dwarf::DW_AT_name, Name->getString());
993 addString(AnnotationDie, dwarf::DW_AT_const_value,
Data->getString());
998 assert(
false &&
"Unsupported annotation value type");
1002void DwarfUnit::addDiscriminant(
DIE &Variant,
Constant *Discriminant,
1005 addInt(Variant, dwarf::DW_AT_discr_value, CI->getValue(), IsUnsigned);
1006 }
else if (
const auto *CA =
1009 unsigned NElems = CA->getNumElements();
1010 if (NElems % 2 != 0) {
1016 auto AddInt = [&](
const APInt &Val) {
1023 for (
unsigned I = 0;
I < NElems;
I += 2) {
1024 APInt LV = CA->getElementAsAPInt(
I);
1025 APInt HV = CA->getElementAsAPInt(
I + 1);
1046 case dwarf::DW_TAG_array_type:
1047 constructArrayTypeDIE(Buffer, CTy);
1049 case dwarf::DW_TAG_enumeration_type:
1050 constructEnumTypeDIE(Buffer, CTy);
1052 case dwarf::DW_TAG_variant_part:
1053 case dwarf::DW_TAG_variant:
1054 case dwarf::DW_TAG_structure_type:
1055 case dwarf::DW_TAG_union_type:
1056 case dwarf::DW_TAG_class_type:
1057 case dwarf::DW_TAG_namelist: {
1060 if (
Tag == dwarf::DW_TAG_variant_part) {
1062 if (Discriminator) {
1074 if (DiscDIE ==
nullptr) {
1075 DiscDIE = &constructMemberDIE(Buffer, Discriminator);
1077 addDIEEntry(Buffer, dwarf::DW_AT_discr, *DiscDIE);
1082 if (
Tag == dwarf::DW_TAG_class_type ||
1083 Tag == dwarf::DW_TAG_structure_type ||
Tag == dwarf::DW_TAG_union_type)
1088 for (
const auto *Element : Elements) {
1094 if (DDTy->getTag() == dwarf::DW_TAG_friend) {
1096 addType(ElemDie, DDTy->getBaseType(), dwarf::DW_AT_friend);
1097 }
else if (DDTy->isStaticMember()) {
1099 }
else if (
Tag == dwarf::DW_TAG_variant_part) {
1103 if (
Constant *CI = DDTy->getDiscriminantValue()) {
1104 addDiscriminant(Variant, CI,
1105 DD->isUnsignedDIType(Discriminator->getBaseType()));
1110 if (
auto *Composite =
1112 Composite !=
nullptr &&
1113 Composite->getTag() == dwarf::DW_TAG_variant) {
1116 constructMemberDIE(Variant, DDTy);
1119 constructMemberDIE(Buffer, DDTy);
1123 StringRef PropertyName = Property->getName();
1124 addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
1125 if (Property->getType())
1126 addType(ElemDie, Property->getType());
1128 StringRef GetterName = Property->getGetterName();
1129 if (!GetterName.
empty())
1130 addString(ElemDie, dwarf::DW_AT_APPLE_property_getter, GetterName);
1131 StringRef SetterName = Property->getSetterName();
1132 if (!SetterName.
empty())
1133 addString(ElemDie, dwarf::DW_AT_APPLE_property_setter, SetterName);
1134 if (
unsigned PropertyAttributes = Property->getAttributes())
1135 addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, std::nullopt,
1136 PropertyAttributes);
1138 if (Composite->getTag() == dwarf::DW_TAG_variant_part) {
1142 }
else if (
Tag == dwarf::DW_TAG_namelist) {
1144 auto *VarDIE =
getDIE(Var);
1147 addDIEEntry(ItemDie, dwarf::DW_AT_namelist_item, *VarDIE);
1153 addFlag(Buffer, dwarf::DW_AT_APPLE_block);
1156 addFlag(Buffer, dwarf::DW_AT_export_symbols);
1167 addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
1171 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 5) {
1174 CC = dwarf::DW_CC_pass_by_value;
1176 CC = dwarf::DW_CC_pass_by_reference;
1178 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
1194 addString(Buffer, dwarf::DW_AT_name, Name);
1202 if (
Tag == dwarf::DW_TAG_enumeration_type ||
1203 Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
1204 Tag == dwarf::DW_TAG_union_type) {
1206 if (
auto *VarDIE =
getDIE(Var))
1207 addDIEEntry(Buffer, dwarf::DW_AT_bit_size, *VarDIE);
1208 }
else if (
auto *Exp =
1222 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
1225 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, 0);
1230 addFlag(Buffer, dwarf::DW_AT_declaration);
1242 addUInt(Buffer, dwarf::DW_AT_APPLE_runtime_class, dwarf::DW_FORM_data1,
1247 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1251 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
1252 NumExtraInhabitants);
1256void DwarfUnit::constructTemplateTypeParameterDIE(
1265 if (TP->
isDefault() && isCompatibleWithVersion(5))
1266 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1269void DwarfUnit::constructTemplateValueParameterDIE(
1275 if (VP->
getTag() == dwarf::DW_TAG_template_value_parameter)
1279 if (VP->
isDefault() && isCompatibleWithVersion(5))
1280 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1289 if (!GV->hasDLLImportStorageClass()) {
1296 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
1299 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1301 addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
1303 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1322 Name =
"(anonymous namespace)";
1323 DD->addAccelNamespace(*
this,
CUNode->getNameTableKind(), Name, NDie);
1326 addFlag(NDie, dwarf::DW_AT_export_symbols);
1339 if (!M->getName().empty()) {
1340 addString(MDie, dwarf::DW_AT_name, M->getName());
1343 if (!M->getConfigurationMacros().empty())
1344 addString(MDie, dwarf::DW_AT_LLVM_config_macros,
1345 M->getConfigurationMacros());
1346 if (!M->getIncludePath().empty())
1347 addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
1348 if (!M->getAPINotesFile().empty())
1349 addString(MDie, dwarf::DW_AT_LLVM_apinotes, M->getAPINotesFile());
1351 addUInt(MDie, dwarf::DW_AT_decl_file, std::nullopt,
1354 addUInt(MDie, dwarf::DW_AT_decl_line, std::nullopt, M->getLineNo());
1356 addFlag(MDie, dwarf::DW_AT_declaration);
1362 const Function *FnHint,
bool Minimal) {
1372 if (
auto *SPDecl = SP->getDeclaration()) {
1391 if (SP->isDefinition())
1395 ->applySubprogramAttributes(SP, SPDie);
1400 DIE &SPDie,
bool Minimal) {
1401 DIE *DeclDie =
nullptr;
1403 if (
auto *SPDecl = SP->getDeclaration()) {
1406 DeclArgs = SPDecl->getType()->getTypeArray();
1407 DefinitionArgs = SP->getType()->getTypeArray();
1409 if (DeclArgs.
size() && DefinitionArgs.
size())
1410 if (DefinitionArgs[0] !=
nullptr && DeclArgs[0] != DefinitionArgs[0])
1411 addType(SPDie, DefinitionArgs[0]);
1413 DeclDie =
getDIE(SPDecl);
1414 assert(DeclDie &&
"This DIE should've already been constructed when the "
1415 "definition DIE was created in "
1416 "getOrCreateSubprogramDIE");
1418 if (
DD->useAllLinkageNames())
1419 DeclLinkageName = SPDecl->getLinkageName();
1422 if (DeclID != DefID)
1423 addUInt(SPDie, dwarf::DW_AT_decl_file, std::nullopt, DefID);
1425 if (SP->getLine() != SPDecl->getLine())
1426 addUInt(SPDie, dwarf::DW_AT_decl_line, std::nullopt, SP->getLine());
1437 (
DD->useAllLinkageNames() ||
DU->getAbstractScopeDIEs().lookup(SP)))
1445 addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
1450 bool SkipSPAttributes) {
1453 bool SkipSPSourceLocation = SkipSPAttributes &&
1454 !
CUNode->getDebugInfoForProfiling();
1455 if (!SkipSPSourceLocation)
1460 if (!SP->getName().empty())
1461 addString(SPDie, dwarf::DW_AT_name, SP->getName());
1465 if (!SkipSPSourceLocation)
1469 if (SkipSPAttributes)
1475 addFlag(SPDie, dwarf::DW_AT_prototyped);
1477 if (SP->isObjCDirect())
1478 addFlag(SPDie, dwarf::DW_AT_APPLE_objc_direct);
1483 Args = SPTy->getTypeArray();
1488 if (CC && CC != dwarf::DW_CC_normal)
1489 addUInt(SPDie, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1, CC);
1494 if (
auto Ty = Args[0])
1497 unsigned VK = SP->getVirtuality();
1499 addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
1500 if (SP->getVirtualIndex() != -1u) {
1502 addUInt(*
Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1503 addUInt(*
Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1509 if (!SP->isDefinition()) {
1510 addFlag(SPDie, dwarf::DW_AT_declaration);
1517 if (std::optional<unsigned> ObjectPointerIndex =
1523 assert(*ObjectPointerIndex > 0);
1524 addSInt(SPDie, dwarf::DW_AT_object_pointer,
1525 dwarf::DW_FORM_implicit_const, *ObjectPointerIndex - 1);
1532 if (SP->isArtificial())
1533 addFlag(SPDie, dwarf::DW_AT_artificial);
1535 if (!SP->isLocalToUnit())
1536 addFlag(SPDie, dwarf::DW_AT_external);
1538 if (
DD->useAppleExtensionAttributes()) {
1539 if (SP->isOptimized())
1540 addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
1542 if (
unsigned isa =
Asm->getISAEncoding())
1543 addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag,
isa);
1546 if (SP->isLValueReference())
1547 addFlag(SPDie, dwarf::DW_AT_reference);
1549 if (SP->isRValueReference())
1550 addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
1552 if (SP->isNoReturn())
1553 addFlag(SPDie, dwarf::DW_AT_noreturn);
1557 if (SP->isExplicit())
1558 addFlag(SPDie, dwarf::DW_AT_explicit);
1560 if (SP->isMainSubprogram())
1561 addFlag(SPDie, dwarf::DW_AT_main_subprogram);
1563 addFlag(SPDie, dwarf::DW_AT_pure);
1564 if (SP->isElemental())
1565 addFlag(SPDie, dwarf::DW_AT_elemental);
1566 if (SP->isRecursive())
1567 addFlag(SPDie, dwarf::DW_AT_recursive);
1569 if (!SP->getTargetFuncName().empty())
1570 addString(SPDie, dwarf::DW_AT_trampoline, SP->getTargetFuncName());
1572 if (
DD->getDwarfVersion() >= 5 && SP->isDeleted())
1573 addFlag(SPDie, dwarf::DW_AT_deleted);
1580 addString(DW_Subrange, dwarf::DW_AT_name, Name);
1588 addUInt(DW_Subrange, dwarf::DW_AT_byte_size, std::nullopt,
Size >> 3);
1590 addUInt(DW_Subrange, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1594 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1597 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1598 dwarf::DW_END_little);
1602 int64_t DefaultLowerBound = getDefaultLowerBound();
1607 if (
auto *VarDIE =
getDIE(BV))
1612 DwarfExpr.setMemoryLocationKind();
1613 DwarfExpr.addExpression(BE);
1614 addBlock(DW_Subrange, Attr, DwarfExpr.finalize());
1616 if (Attr == dwarf::DW_AT_GNU_bias) {
1617 if (BI->getSExtValue() != 0)
1618 addUInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1619 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1620 BI->getSExtValue() != DefaultLowerBound || !ForArray)
1621 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1625 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1627 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1629 AddBoundTypeEntry(dwarf::DW_AT_bit_stride, SR->
getStride());
1631 AddBoundTypeEntry(dwarf::DW_AT_GNU_bias, SR->
getBias());
1634void DwarfUnit::constructSubrangeDIE(
DIE &Buffer,
const DISubrange *SR) {
1635 DIE &DW_Subrange =
createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
1637 DIE *IdxTy = getIndexTyDie();
1638 addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IdxTy);
1644 int64_t DefaultLowerBound = getDefaultLowerBound();
1647 DISubrange::BoundType Bound) ->
void {
1649 if (
auto *VarDIE =
getDIE(BV))
1653 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1654 DwarfExpr.setMemoryLocationKind();
1655 DwarfExpr.addExpression(BE);
1656 addBlock(DW_Subrange, Attr, DwarfExpr.finalize());
1658 if (Attr == dwarf::DW_AT_count) {
1659 if (BI->getSExtValue() != -1)
1660 addUInt(DW_Subrange, Attr, std::nullopt, BI->getSExtValue());
1661 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1662 BI->getSExtValue() != DefaultLowerBound)
1663 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1667 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1669 AddBoundTypeEntry(dwarf::DW_AT_count, SR->
getCount());
1671 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1673 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, SR->
getStride());
1676void DwarfUnit::constructGenericSubrangeDIE(
DIE &Buffer,
1678 DIE &DwGenericSubrange =
1683 DIE *IdxTy = getIndexTyDie();
1684 addDIEEntry(DwGenericSubrange, dwarf::DW_AT_type, *IdxTy);
1686 int64_t DefaultLowerBound = getDefaultLowerBound();
1691 if (
auto *VarDIE =
getDIE(BV))
1694 if (BE->isConstant() &&
1696 *BE->isConstant()) {
1697 if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1698 static_cast<int64_t
>(BE->getElement(1)) != DefaultLowerBound)
1699 addSInt(DwGenericSubrange, Attr, dwarf::DW_FORM_sdata,
1703 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1704 DwarfExpr.setMemoryLocationKind();
1705 DwarfExpr.addExpression(BE);
1706 addBlock(DwGenericSubrange, Attr, DwarfExpr.finalize());
1711 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, GSR->
getLowerBound());
1712 AddBoundTypeEntry(dwarf::DW_AT_count, GSR->
getCount());
1713 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, GSR->
getUpperBound());
1714 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, GSR->
getStride());
1717DIE *DwarfUnit::getIndexTyDie() {
1722 StringRef
Name =
"__ARRAY_SIZE_TYPE__";
1736 assert(CTy && CTy->
isVector() &&
"Composite type is not a vector");
1741 assert(BaseTy &&
"Unknown vector element type.");
1746 assert(Elements.size() == 1 &&
1747 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type &&
1748 "Invalid vector element array, expected one element of type subrange");
1750 const auto NumVecElements =
1751 Subrange->getCount()
1757 assert(ActualSize >= (NumVecElements * ElementSize) &&
"Invalid vector size");
1758 return ActualSize != (NumVecElements * ElementSize);
1763 addFlag(Buffer, dwarf::DW_AT_GNU_vector);
1765 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
1770 if (
auto *VarDIE =
getDIE(Var))
1771 addDIEEntry(Buffer, dwarf::DW_AT_data_location, *VarDIE);
1774 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1775 DwarfExpr.setMemoryLocationKind();
1776 DwarfExpr.addExpression(Expr);
1777 addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
1781 if (
auto *VarDIE =
getDIE(Var))
1782 addDIEEntry(Buffer, dwarf::DW_AT_associated, *VarDIE);
1785 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1786 DwarfExpr.setMemoryLocationKind();
1787 DwarfExpr.addExpression(Expr);
1788 addBlock(Buffer, dwarf::DW_AT_associated, DwarfExpr.finalize());
1792 if (
auto *VarDIE =
getDIE(Var))
1793 addDIEEntry(Buffer, dwarf::DW_AT_allocated, *VarDIE);
1796 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1797 DwarfExpr.setMemoryLocationKind();
1798 DwarfExpr.addExpression(Expr);
1799 addBlock(Buffer, dwarf::DW_AT_allocated, DwarfExpr.finalize());
1803 addSInt(Buffer, dwarf::DW_AT_rank, dwarf::DW_FORM_sdata,
1804 RankConst->getSExtValue());
1805 }
else if (
auto *RankExpr = CTy->
getRankExp()) {
1807 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1808 DwarfExpr.setMemoryLocationKind();
1809 DwarfExpr.addExpression(RankExpr);
1810 addBlock(Buffer, dwarf::DW_AT_rank, DwarfExpr.finalize());
1814 addUInt(Buffer, dwarf::DW_AT_bit_stride, {}, BitStride->getZExtValue());
1822 for (DINode *
E : Elements) {
1825 constructSubrangeDIE(TyDIE, Element,
true);
1827 constructSubrangeDIE(Buffer, Element);
1829 constructGenericSubrangeDIE(Buffer, Element);
1835 bool IsUnsigned = DTy &&
DD->isUnsignedDIType(DTy);
1837 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 3)
1839 if (
DD->getDwarfVersion() >= 4 && (CTy->
getFlags() & DINode::FlagEnumClass))
1840 addFlag(Buffer, dwarf::DW_AT_enum_class);
1844 addUInt(Buffer, dwarf::DW_AT_APPLE_enum_kind, dwarf::DW_FORM_data1, *Kind);
1852 for (
const DINode *
E : Elements) {
1859 if (IndexEnumerators)
1867 DIE &SPDie = *
P.first;
1874 addDIEEntry(SPDie, dwarf::DW_AT_containing_type, *NDie);
1882 addString(MemberDie, dwarf::DW_AT_name, Name);
1886 if (
DIType *Resolved = DT->getBaseType())
1898 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
1899 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1900 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1902 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_minus);
1903 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1904 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
1906 addBlock(MemberDie, dwarf::DW_AT_data_member_location, VBaseLocationDie);
1917 if (
auto *VarDIE =
getDIE(Var))
1918 addDIEEntry(MemberDie, dwarf::DW_AT_bit_size, *VarDIE);
1921 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1922 DwarfExpr.setMemoryLocationKind();
1923 DwarfExpr.addExpression(Exp);
1924 addBlock(MemberDie, dwarf::DW_AT_bit_size, DwarfExpr.finalize());
1927 FieldSize =
DD->getBaseTypeSize(DT);
1930 if (
DD->useDWARF2Bitfields())
1931 addUInt(MemberDie, dwarf::DW_AT_byte_size, std::nullopt,
1933 addUInt(MemberDie, dwarf::DW_AT_bit_size, std::nullopt,
Size);
1941 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 6) {
1942 if (
auto *VarDIE =
getDIE(Var))
1943 addDIEEntry(MemberDie, dwarf::DW_AT_data_bit_offset, *VarDIE);
1945 }
else if (
auto *Expr =
1947 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 6) {
1949 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1950 DwarfExpr.setMemoryLocationKind();
1951 DwarfExpr.addExpression(Expr);
1952 addBlock(MemberDie, dwarf::DW_AT_data_bit_offset, DwarfExpr.finalize());
1956 uint64_t OffsetInBytes;
1960 (uint64_t)std::numeric_limits<int64_t>::max());
1965 uint32_t AlignInBits = FieldSize;
1966 uint32_t AlignMask = ~(AlignInBits - 1);
1969 uint64_t StartBitOffset = Offset - (Offset & AlignMask);
1972 OffsetInBytes = (Offset - StartBitOffset) / 8;
1974 if (
DD->useDWARF2Bitfields()) {
1975 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
1976 uint64_t FieldOffset = (HiMark - FieldSize);
1977 Offset -= FieldOffset;
1980 if (
Asm->getDataLayout().isLittleEndian())
1981 Offset = FieldSize - (Offset +
Size);
1984 addSInt(MemberDie, dwarf::DW_AT_bit_offset, dwarf::DW_FORM_sdata,
1987 addUInt(MemberDie, dwarf::DW_AT_bit_offset, std::nullopt,
1989 OffsetInBytes = FieldOffset >> 3;
1991 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, std::nullopt,
1998 addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
2002 if (
DD->getDwarfVersion() <= 2) {
2004 addUInt(*MemLocationDie, dwarf::DW_FORM_data1,
2005 dwarf::DW_OP_plus_uconst);
2006 addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
2007 addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
2008 }
else if (!IsBitfield ||
DD->useDWARF2Bitfields()) {
2013 if (
DD->getDwarfVersion() == 3)
2014 addUInt(MemberDie, dwarf::DW_AT_data_member_location,
2015 dwarf::DW_FORM_udata, OffsetInBytes);
2017 addUInt(MemberDie, dwarf::DW_AT_data_member_location, std::nullopt,
2026 addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1,
2027 dwarf::DW_VIRTUALITY_virtual);
2031 if (DIE *PDie =
getDIE(PNode))
2033 dwarf::DW_FORM_ref4, DIEEntry(*PDie));
2036 addFlag(MemberDie, dwarf::DW_AT_artificial);
2049 "Static member should belong to a type.");
2052 return StaticMemberDIE;
2057 const DIType *Ty = DT->getBaseType();
2062 addFlag(StaticMemberDIE, dwarf::DW_AT_external);
2063 addFlag(StaticMemberDIE, dwarf::DW_AT_declaration);
2067 addFlag(StaticMemberDIE, dwarf::DW_AT_artificial);
2079 addUInt(StaticMemberDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
2082 return &StaticMemberDIE;
2087 if (!
DD->useSectionsAsReferences())
2089 isDwoUnit() ?
"debug_info_dwo" :
"debug_info",
"Length of Unit");
2094 Asm->OutStreamer->AddComment(
"DWARF version number");
2095 unsigned Version =
DD->getDwarfVersion();
2100 Asm->OutStreamer->AddComment(
"DWARF Unit Type");
2102 Asm->OutStreamer->AddComment(
"Address Size (in bytes)");
2103 Asm->emitInt8(
Asm->MAI->getCodePointerSize());
2109 Asm->OutStreamer->AddComment(
"Offset Into Abbrev. Section");
2112 Asm->emitDwarfLengthOrOffset(0);
2114 Asm->emitDwarfSymbolReference(
2118 Asm->OutStreamer->AddComment(
"Address Size (in bytes)");
2119 Asm->emitInt8(
Asm->MAI->getCodePointerSize());
2124 if (!
DD->useSplitDwarf()) {
2129 DD->useSplitDwarf() ? dwarf::DW_UT_split_type
2130 : dwarf::DW_UT_type);
2131 Asm->OutStreamer->AddComment(
"Type Signature");
2132 Asm->OutStreamer->emitIntValue(TypeSignature,
sizeof(TypeSignature));
2133 Asm->OutStreamer->AddComment(
"Type DIE Offset");
2135 Asm->emitDwarfLengthOrOffset(Ty ? Ty->getOffset() : 0);
2146 if (
Asm->doesDwarfUseRelocationsAcrossSections())
2152bool DwarfTypeUnit::isDwoUnit()
const {
2179 DU->getStringOffsetsStartSym(),
2184 assert(
DD->getDwarfVersion() >= 5 &&
2185 "DW_AT_rnglists_base requires DWARF version 5 or later");
2188 DU->getRnglistsTableBaseSym(),
2196bool 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")
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.
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.
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
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 compile unit or type 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
Base class for scope-like contexts.
LLVM_ABI DIScope * getScope() const
String type, Fortran CHARACTER(n)
unsigned getEncoding() const
DIExpression * getStringLengthExp() const
DIVariable * getStringLength() const
DIExpression * getStringLocationExp() const
Subprogram description. Uses SubclassData1.
BoundType getLowerBound() const
PointerUnion< ConstantInt *, DIVariable *, DIExpression * > BoundType
BoundType getBias() const
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...
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.
AddressPool & getAddressPool()
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support.
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.
void 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.
void addInt(DIE &Die, dwarf::Attribute Attribute, const APInt &Integer, bool Unsigned)
Add an integer attribute data and value; value may be any width.
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 addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
addSectionDelta - Add a label delta attribute data and value.
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.
std::optional< unsigned > constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args)
Construct function argument DIEs.
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.
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.
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.
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.
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.
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.
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.
FunctionAddr VTableAddr Value
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 ...
auto dyn_cast_or_null(const Y &Val)
FunctionAddr VTableAddr uintptr_t uintptr_t Version
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).
FunctionAddr VTableAddr uintptr_t uintptr_t Data
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.