38#define DEBUG_TYPE "dwarfdebug"
44void DIEDwarfExpression::emitOp(
uint8_t Op,
const char* Comment) {
45 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Op);
48void DIEDwarfExpression::emitSigned(int64_t
Value) {
49 CU.addSInt(getActiveDIE(), dwarf::DW_FORM_sdata,
Value);
53 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_udata,
Value);
56void DIEDwarfExpression::emitData1(uint8_t
Value) {
57 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Value);
60void DIEDwarfExpression::emitBaseTypeRef(
uint64_t Idx) {
61 CU.addBaseTypeRef(getActiveDIE(), Idx);
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:
193 if (
DD->getDwarfVersion() == 2)
195 if (isDwoUnit() && !
DD->shareAcrossDWOCUs())
199 !
DD->generateTypeUnits();
204 return DU->getDIE(
D);
221 if (
DD->getDwarfVersion() >= 4)
228 std::optional<dwarf::Form> Form, uint64_t
Integer) {
231 assert(Form != dwarf::DW_FORM_implicit_const &&
232 "DW_FORM_implicit_const is used only for signed integers");
249 for (
int i = 0; i < NumBytes; i++) {
252 c = Ptr64[i / 8] >> (8 * (i & 7));
254 c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
262 addIntToBlock(*
Block, Val);
263 Block->computeSize(
Asm->getDwarfFormParams());
270 if (CIBitWidth <= 64) {
282 std::optional<dwarf::Form> Form, int64_t
Integer) {
295 if (
CUNode->isDebugDirectivesOnly())
298 if (
DD->useInlineStrings()) {
305 isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp;
307 auto StringPoolEntry =
309 ?
DU->getStringPool().getIndexedEntry(*
Asm,
String)
314 IxForm = dwarf::DW_FORM_strx1;
315 unsigned Index = StringPoolEntry.getIndex();
316 if (Index > 0xffffff)
317 IxForm = dwarf::DW_FORM_strx4;
318 else if (Index > 0xffff)
319 IxForm = dwarf::DW_FORM_strx3;
320 else if (Index > 0xff)
321 IxForm = dwarf::DW_FORM_strx2;
340unsigned DwarfTypeUnit::getOrCreateSourceID(
const DIFile *File) {
343 if (!UsedLineTable) {
344 UsedLineTable =
true;
348 return SplitLineTable->
getFile(
354 bool UseAddrOffsetFormOrExpressions =
355 DD->useAddrOffsetForm() ||
DD->useAddrOffsetExpressions();
358 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
359 Base =
DD->getSectionLabel(&Label->getSection());
363 if (
DD->getDwarfVersion() >= 5) {
364 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx);
365 addUInt(Die, dwarf::DW_FORM_addrx, Index);
367 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
368 addUInt(Die, dwarf::DW_FORM_GNU_addr_index, Index);
372 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_const4u);
374 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
379 if (
DD->getDwarfVersion() >= 5) {
384 if (
DD->useSplitDwarf()) {
389 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
390 addLabel(Die, dwarf::DW_FORM_addr, Sym);
408 addFlag(Die, dwarf::DW_AT_declaration);
410 addAttribute(Die, dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
417 const DIEUnit *EntryCU = Entry.getEntry().getUnit();
423 assert(EntryCU ==
CU || !
DD->useSplitDwarf() ||
DD->shareAcrossDWOCUs() ||
426 EntryCU ==
CU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
438 Loc->computeSize(
Asm->getDwarfFormParams());
445 Block->computeSize(
Asm->getDwarfFormParams());
470 addUInt(Die, dwarf::DW_AT_decl_file, std::nullopt, FileID);
471 addUInt(Die, dwarf::DW_AT_decl_line, std::nullopt, Line);
474 addUInt(Die, dwarf::DW_AT_decl_column, std::nullopt, Column);
498 addSourceLine(Die, L->getLine(), L->getColumn(), L->getFile());
536 addUInt(Die, dwarf::DW_AT_const_value,
537 Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
546 if (CIBitWidth <= 64) {
552 addIntAsBlock(Die, dwarf::DW_AT_const_value, Val);
558 DD->getDwarfVersion() >= 4 ? dwarf::DW_AT_linkage_name
559 : dwarf::DW_AT_MIPS_linkage_name,
565 for (
const auto *Element : TParams) {
567 constructTemplateTypeParameterDIE(Buffer, TTP);
569 constructTemplateValueParameterDIE(Buffer, TVP);
575 for (
const auto *Ty : ThrownTypes) {
583 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
586 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
589 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
608 auto *Context = Ty->getScope();
628 auto construct = [&](
const auto *Ty) {
634 if (
DD->generateTypeUnits() && !Ty->isForwardDecl() &&
635 (Ty->getRawName() || CTy->getRawIdentifier())) {
637 if (
MDString *TypeId = CTy->getRawIdentifier()) {
639 DD->addDwarfTypeUnitType(
getCU(), TypeId->getString(), TyDIE, CTy);
642 finishNonUnitTypeDIE(TyDIE, CTy);
656 constructSubrangeDIE(TyDIE, SRTy);
670 if (Ty->getTag() == dwarf::DW_TAG_restrict_type &&
DD->getDwarfVersion() <= 2)
674 if (Ty->getTag() == dwarf::DW_TAG_atomic_type &&
DD->getDwarfVersion() < 5)
679 auto *Context = Ty->getScope();
687 ->createTypeDIE(Context, *ContextDIE, Ty);
692 if (Ty->getName().empty())
694 if (Ty->isForwardDecl())
703 if (CT->getRuntimeLang() == 0 || CT->isObjcClassComplete())
707 DD->addAccelType(*
this,
CUNode->getNameTableKind(), Ty->getName(), TyDIE,
711 if (Ty->getName() != CT->getIdentifier() &&
712 CT->getRuntimeLang() == dwarf::DW_LANG_Swift)
713 DD->addAccelType(*
this,
CUNode->getNameTableKind(), CT->getIdentifier(),
728 assert(Ty &&
"Trying to add a type that doesn't exist?");
734 const auto &Lang = getLanguage();
736 if (!Lang.hasVersionedName())
756 Parents.push_back(Context);
770 Name =
"(anonymous namespace)";
784 addString(Buffer, dwarf::DW_AT_name, Name);
787 if (BTy->
getTag() == dwarf::DW_TAG_unspecified_type)
790 if (BTy->
getTag() != dwarf::DW_TAG_string_type)
791 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
795 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, SizeInBytes);
796 if (BTy->
getTag() == dwarf::Tag::DW_TAG_base_type) {
804 DataSizeInBits && DataSizeInBits != SizeInBytes * 8)
805 addUInt(Buffer, dwarf::DW_AT_bit_size, std::nullopt, DataSizeInBits);
809 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_big);
811 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_little);
814 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
815 NumExtraInhabitants);
823 addSInt(Buffer, dwarf::DW_AT_binary_scale, dwarf::DW_FORM_sdata,
826 addSInt(Buffer, dwarf::DW_AT_decimal_scale, dwarf::DW_FORM_sdata,
847 addString(Buffer, dwarf::DW_AT_name, Name);
850 if (
auto *VarDIE =
getDIE(Var))
851 addDIEEntry(Buffer, dwarf::DW_AT_string_length, *VarDIE);
853 addBlock(Buffer, dwarf::DW_AT_string_length, Expr);
856 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
860 addBlock(Buffer, dwarf::DW_AT_data_location, Expr);
865 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
877 const DIType *FromTy = DTy->getBaseType();
883 addString(Buffer, dwarf::DW_AT_name, Name);
889 if (
Tag == dwarf::DW_TAG_typedef &&
DD->getDwarfVersion() >= 5) {
891 if (AlignInBytes > 0)
892 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
897 if (
Size &&
Tag != dwarf::DW_TAG_pointer_type
898 &&
Tag != dwarf::DW_TAG_ptr_to_member_type
899 &&
Tag != dwarf::DW_TAG_reference_type
900 &&
Tag != dwarf::DW_TAG_rvalue_reference_type)
901 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
903 if (
Tag == dwarf::DW_TAG_ptr_to_member_type)
916 if (DTy->getDWARFAddressSpace())
917 addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,
918 *DTy->getDWARFAddressSpace());
921 if (
Tag == dwarf::DW_TAG_template_alias)
924 if (
auto PtrAuthData = DTy->getPtrAuthData()) {
925 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_key, dwarf::DW_FORM_data1,
927 if (PtrAuthData->isAddressDiscriminated())
928 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_address_discriminated);
929 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_extra_discriminator,
930 dwarf::DW_FORM_data2, PtrAuthData->extraDiscriminator());
931 if (PtrAuthData->isaPointer())
932 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_isa_pointer);
933 if (PtrAuthData->authenticatesNullValues())
934 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_authenticates_null_values);
938std::optional<unsigned>
941 std::optional<unsigned> ObjectPointerIndex;
942 for (
unsigned i = 1,
N = Args.size(); i <
N; ++i) {
943 const DIType *Ty = Args[i];
945 assert(i ==
N-1 &&
"Unspecified parameter must be the last argument");
950 if (Ty->isArtificial())
951 addFlag(Arg, dwarf::DW_AT_artificial);
953 if (Ty->isObjectPointer()) {
954 assert(!ObjectPointerIndex &&
955 "Can't have more than one object pointer");
956 ObjectPointerIndex = i;
961 return ObjectPointerIndex;
968 if (
auto RTy = Elements[0])
971 bool isPrototyped =
true;
972 if (Elements.size() == 2 && !Elements[1])
973 isPrototyped =
false;
980 addFlag(Buffer, dwarf::DW_AT_prototyped);
983 if (CTy->
getCC() && CTy->
getCC() != dwarf::DW_CC_normal)
984 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
988 addFlag(Buffer, dwarf::DW_AT_reference);
991 addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
1004 addString(AnnotationDie, dwarf::DW_AT_name, Name->getString());
1006 addString(AnnotationDie, dwarf::DW_AT_const_value,
Data->getString());
1011 assert(
false &&
"Unsupported annotation value type");
1015void DwarfUnit::addDiscriminant(
DIE &Variant,
Constant *Discriminant,
1018 addInt(Variant, dwarf::DW_AT_discr_value, CI->getValue(), IsUnsigned);
1019 }
else if (
const auto *CA =
1022 unsigned NElems = CA->getNumElements();
1023 if (NElems % 2 != 0) {
1029 auto AddInt = [&](
const APInt &Val) {
1036 for (
unsigned I = 0;
I < NElems;
I += 2) {
1037 APInt LV = CA->getElementAsAPInt(
I);
1038 APInt HV = CA->getElementAsAPInt(
I + 1);
1059 case dwarf::DW_TAG_array_type:
1060 constructArrayTypeDIE(Buffer, CTy);
1062 case dwarf::DW_TAG_enumeration_type:
1063 constructEnumTypeDIE(Buffer, CTy);
1065 case dwarf::DW_TAG_variant_part:
1066 case dwarf::DW_TAG_variant:
1067 case dwarf::DW_TAG_structure_type:
1068 case dwarf::DW_TAG_union_type:
1069 case dwarf::DW_TAG_class_type:
1070 case dwarf::DW_TAG_namelist: {
1073 if (
Tag == dwarf::DW_TAG_variant_part) {
1075 if (Discriminator) {
1087 if (DiscDIE ==
nullptr) {
1088 DiscDIE = &constructMemberDIE(Buffer, Discriminator);
1090 addDIEEntry(Buffer, dwarf::DW_AT_discr, *DiscDIE);
1095 if (
Tag == dwarf::DW_TAG_class_type ||
1096 Tag == dwarf::DW_TAG_structure_type ||
1097 Tag == dwarf::DW_TAG_union_type) {
1098 if (!(
DD->useSplitDwarf() && !
getCU().getSkeleton()) ||
1105 for (
const auto *Element : Elements) {
1111 if (DDTy->getTag() == dwarf::DW_TAG_friend) {
1113 addType(ElemDie, DDTy->getBaseType(), dwarf::DW_AT_friend);
1114 }
else if (DDTy->isStaticMember()) {
1116 }
else if (
Tag == dwarf::DW_TAG_variant_part) {
1120 if (
Constant *CI = DDTy->getDiscriminantValue()) {
1121 addDiscriminant(Variant, CI,
1122 DD->isUnsignedDIType(Discriminator->getBaseType()));
1127 if (
auto *Composite =
1129 Composite !=
nullptr &&
1130 Composite->getTag() == dwarf::DW_TAG_variant) {
1133 constructMemberDIE(Variant, DDTy);
1136 constructMemberDIE(Buffer, DDTy);
1140 StringRef PropertyName = Property->getName();
1141 addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
1142 if (Property->getType())
1143 addType(ElemDie, Property->getType());
1145 StringRef GetterName = Property->getGetterName();
1146 if (!GetterName.
empty())
1147 addString(ElemDie, dwarf::DW_AT_APPLE_property_getter, GetterName);
1148 StringRef SetterName = Property->getSetterName();
1149 if (!SetterName.
empty())
1150 addString(ElemDie, dwarf::DW_AT_APPLE_property_setter, SetterName);
1151 if (
unsigned PropertyAttributes = Property->getAttributes())
1152 addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, std::nullopt,
1153 PropertyAttributes);
1155 constructPropertyDIE(Buffer, Property);
1157 if (Composite->getTag() == dwarf::DW_TAG_variant_part) {
1161 }
else if (
Tag == dwarf::DW_TAG_namelist) {
1162 auto *VarDIE =
getDIE(Element);
1165 addDIEEntry(ItemDie, dwarf::DW_AT_namelist_item, *VarDIE);
1171 addFlag(Buffer, dwarf::DW_AT_APPLE_block);
1174 addFlag(Buffer, dwarf::DW_AT_export_symbols);
1185 addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
1189 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 5) {
1192 CC = dwarf::DW_CC_pass_by_value;
1194 CC = dwarf::DW_CC_pass_by_reference;
1196 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
1212 addString(Buffer, dwarf::DW_AT_name, Name);
1220 if (
Tag == dwarf::DW_TAG_enumeration_type ||
1221 Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
1222 Tag == dwarf::DW_TAG_union_type) {
1224 if (
auto *VarDIE =
getDIE(Var))
1225 addDIEEntry(Buffer, dwarf::DW_AT_bit_size, *VarDIE);
1226 }
else if (
auto *Exp =
1228 addBlock(Buffer, dwarf::DW_AT_bit_size, Exp);
1236 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
1239 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, 0);
1244 addFlag(Buffer, dwarf::DW_AT_declaration);
1256 addUInt(Buffer, dwarf::DW_AT_APPLE_runtime_class, dwarf::DW_FORM_data1,
1261 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1265 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
1266 NumExtraInhabitants);
1270void DwarfUnit::constructTemplateTypeParameterDIE(
1279 if (TP->
isDefault() && isCompatibleWithVersion(5))
1280 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1283void DwarfUnit::constructTemplateValueParameterDIE(
1289 if (VP->
getTag() == dwarf::DW_TAG_template_value_parameter)
1293 if (VP->
isDefault() && isCompatibleWithVersion(5))
1294 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1303 if (!GV->hasDLLImportStorageClass()) {
1310 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
1313 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1315 addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
1317 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1336 Name =
"(anonymous namespace)";
1337 DD->addAccelNamespace(*
this,
CUNode->getNameTableKind(), Name, NDie);
1340 addFlag(NDie, dwarf::DW_AT_export_symbols);
1353 if (!M->getName().empty()) {
1354 addString(MDie, dwarf::DW_AT_name, M->getName());
1357 if (!M->getConfigurationMacros().empty())
1358 addString(MDie, dwarf::DW_AT_LLVM_config_macros,
1359 M->getConfigurationMacros());
1360 if (!M->getIncludePath().empty())
1361 addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
1362 if (!M->getAPINotesFile().empty())
1363 addString(MDie, dwarf::DW_AT_LLVM_apinotes, M->getAPINotesFile());
1365 addUInt(MDie, dwarf::DW_AT_decl_file, std::nullopt,
1368 addUInt(MDie, dwarf::DW_AT_decl_line, std::nullopt, M->getLineNo());
1370 addFlag(MDie, dwarf::DW_AT_declaration);
1376 const Function *FnHint,
bool Minimal) {
1386 if (
auto *SPDecl = SP->getDeclaration()) {
1405 if (SP->isDefinition())
1409 ->applySubprogramAttributes(SP, SPDie);
1414 DIE &SPDie,
bool Minimal) {
1415 DIE *DeclDie =
nullptr;
1417 if (
auto *SPDecl = SP->getDeclaration()) {
1419 DITypeArray DeclArgs, DefinitionArgs;
1420 DeclArgs = SPDecl->getType()->getTypeArray();
1421 DefinitionArgs = SP->getType()->getTypeArray();
1423 if (DeclArgs.size() && DefinitionArgs.size())
1424 if (DefinitionArgs[0] !=
nullptr && DeclArgs[0] != DefinitionArgs[0])
1425 addType(SPDie, DefinitionArgs[0]);
1427 DeclDie =
getDIE(SPDecl);
1428 assert(DeclDie &&
"This DIE should've already been constructed when the "
1429 "definition DIE was created in "
1430 "getOrCreateSubprogramDIE");
1432 if (
DD->useAllLinkageNames())
1433 DeclLinkageName = SPDecl->getLinkageName();
1436 if (DeclID != DefID)
1437 addUInt(SPDie, dwarf::DW_AT_decl_file, std::nullopt, DefID);
1439 if (SP->getLine() != SPDecl->getLine())
1440 addUInt(SPDie, dwarf::DW_AT_decl_line, std::nullopt, SP->getLine());
1445 if (!Minimal || SP->isNameSimplified())
1452 (
DD->useAllLinkageNames() ||
DU->getAbstractScopeDIEs().lookup(SP)))
1460 addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
1465 bool SkipSPAttributes) {
1468 bool SkipSPSourceLocation = SkipSPAttributes &&
1469 !
CUNode->getDebugInfoForProfiling();
1470 if (!SkipSPSourceLocation)
1475 if (!SP->getName().empty())
1476 addString(SPDie, dwarf::DW_AT_name, SP->getName());
1480 if (!SkipSPSourceLocation)
1484 if (SkipSPAttributes)
1490 addFlag(SPDie, dwarf::DW_AT_prototyped);
1492 if (SP->isObjCDirect())
1493 addFlag(SPDie, dwarf::DW_AT_APPLE_objc_direct);
1498 Args = SPTy->getTypeArray();
1503 if (CC && CC != dwarf::DW_CC_normal)
1504 addUInt(SPDie, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1, CC);
1509 if (
auto Ty = Args[0])
1512 unsigned VK = SP->getVirtuality();
1514 addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
1515 if (SP->getVirtualIndex() != -1u) {
1517 addUInt(*
Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1518 addUInt(*
Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1524 if (!SP->isDefinition()) {
1525 addFlag(SPDie, dwarf::DW_AT_declaration);
1532 if (std::optional<unsigned> ObjectPointerIndex =
1538 assert(*ObjectPointerIndex > 0);
1539 addSInt(SPDie, dwarf::DW_AT_object_pointer,
1540 dwarf::DW_FORM_implicit_const, *ObjectPointerIndex - 1);
1547 if (SP->isArtificial())
1548 addFlag(SPDie, dwarf::DW_AT_artificial);
1550 if (!SP->isLocalToUnit())
1551 addFlag(SPDie, dwarf::DW_AT_external);
1553 if (SP->isOptimized())
1554 addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
1556 if (
DD->useAppleExtensionAttributes())
1557 if (
unsigned isa =
Asm->getISAEncoding())
1558 addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag,
isa);
1560 if (SP->isLValueReference())
1561 addFlag(SPDie, dwarf::DW_AT_reference);
1563 if (SP->isRValueReference())
1564 addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
1566 if (SP->isNoReturn())
1567 addFlag(SPDie, dwarf::DW_AT_noreturn);
1571 if (SP->isExplicit())
1572 addFlag(SPDie, dwarf::DW_AT_explicit);
1574 if (SP->isMainSubprogram())
1575 addFlag(SPDie, dwarf::DW_AT_main_subprogram);
1577 addFlag(SPDie, dwarf::DW_AT_pure);
1578 if (SP->isElemental())
1579 addFlag(SPDie, dwarf::DW_AT_elemental);
1580 if (SP->isRecursive())
1581 addFlag(SPDie, dwarf::DW_AT_recursive);
1583 if (!SP->getTargetFuncName().empty())
1584 addString(SPDie, dwarf::DW_AT_trampoline, SP->getTargetFuncName());
1586 if (
DD->getDwarfVersion() >= 5 && SP->isDeleted())
1587 addFlag(SPDie, dwarf::DW_AT_deleted);
1594 addString(DW_Subrange, dwarf::DW_AT_name, Name);
1602 addUInt(DW_Subrange, dwarf::DW_AT_byte_size, std::nullopt,
Size >> 3);
1604 addUInt(DW_Subrange, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1608 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1611 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1612 dwarf::DW_END_little);
1616 int64_t DefaultLowerBound = getDefaultLowerBound();
1621 if (
auto *VarDIE =
getDIE(BV))
1624 if (
auto *DTDIE =
getDIE(DT))
1629 if (Attr == dwarf::DW_AT_GNU_bias) {
1630 if (BI->getSExtValue() != 0)
1631 addUInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1632 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1633 BI->getSExtValue() != DefaultLowerBound || !ForArray)
1634 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1638 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1640 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1642 AddBoundTypeEntry(dwarf::DW_AT_bit_stride, SR->
getStride());
1644 AddBoundTypeEntry(dwarf::DW_AT_GNU_bias, SR->
getBias());
1647void DwarfUnit::constructSubrangeDIE(
DIE &Buffer,
const DISubrange *SR) {
1648 DIE &DW_Subrange =
createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
1650 DIE *IdxTy = getIndexTyDie();
1651 addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IdxTy);
1657 int64_t DefaultLowerBound = getDefaultLowerBound();
1660 DISubrange::BoundType Bound) ->
void {
1662 if (
auto *VarDIE =
getDIE(BV))
1667 if (Attr == dwarf::DW_AT_count) {
1668 if (BI->getSExtValue() != -1)
1669 addUInt(DW_Subrange, Attr, std::nullopt, BI->getSExtValue());
1670 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1671 BI->getSExtValue() != DefaultLowerBound)
1672 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1676 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1678 AddBoundTypeEntry(dwarf::DW_AT_count, SR->
getCount());
1680 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1682 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, SR->
getStride());
1685void DwarfUnit::constructGenericSubrangeDIE(
DIE &Buffer,
1687 DIE &DwGenericSubrange =
1692 DIE *IdxTy = getIndexTyDie();
1693 addDIEEntry(DwGenericSubrange, dwarf::DW_AT_type, *IdxTy);
1695 int64_t DefaultLowerBound = getDefaultLowerBound();
1700 if (
auto *VarDIE =
getDIE(BV))
1703 if (BE->isConstant() &&
1705 *BE->isConstant()) {
1706 if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1707 static_cast<int64_t
>(BE->getElement(1)) != DefaultLowerBound)
1708 addSInt(DwGenericSubrange, Attr, dwarf::DW_FORM_sdata,
1711 addBlock(DwGenericSubrange, Attr, BE);
1716 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, GSR->
getLowerBound());
1717 AddBoundTypeEntry(dwarf::DW_AT_count, GSR->
getCount());
1718 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, GSR->
getUpperBound());
1719 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, GSR->
getStride());
1722DIE *DwarfUnit::getIndexTyDie() {
1727 StringRef
Name =
"__ARRAY_SIZE_TYPE__";
1741 assert(CTy && CTy->
isVector() &&
"Composite type is not a vector");
1746 assert(BaseTy &&
"Unknown vector element type.");
1751 assert(Elements.size() == 1 &&
1752 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type &&
1753 "Invalid vector element array, expected one element of type subrange");
1755 const auto NumVecElements =
1756 Subrange->getCount()
1762 assert(ActualSize >= (NumVecElements * ElementSize) &&
"Invalid vector size");
1763 return ActualSize != (NumVecElements * ElementSize);
1768 addFlag(Buffer, dwarf::DW_AT_GNU_vector);
1770 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
1775 if (
auto *VarDIE =
getDIE(Var))
1776 addDIEEntry(Buffer, dwarf::DW_AT_data_location, *VarDIE);
1778 addBlock(Buffer, dwarf::DW_AT_data_location, Expr);
1782 if (
auto *VarDIE =
getDIE(Var))
1783 addDIEEntry(Buffer, dwarf::DW_AT_associated, *VarDIE);
1785 addBlock(Buffer, dwarf::DW_AT_associated, Expr);
1789 if (
auto *VarDIE =
getDIE(Var))
1790 addDIEEntry(Buffer, dwarf::DW_AT_allocated, *VarDIE);
1792 addBlock(Buffer, dwarf::DW_AT_allocated, Expr);
1796 addSInt(Buffer, dwarf::DW_AT_rank, dwarf::DW_FORM_sdata,
1797 RankConst->getSExtValue());
1798 }
else if (
auto *RankExpr = CTy->
getRankExp()) {
1799 addBlock(Buffer, dwarf::DW_AT_rank, RankExpr);
1803 addUInt(Buffer, dwarf::DW_AT_bit_stride, {}, BitStride->getZExtValue());
1811 for (DINode *
E : Elements) {
1814 constructSubrangeDIE(TyDIE, Element,
true);
1816 constructSubrangeDIE(Buffer, Element);
1818 constructGenericSubrangeDIE(Buffer, Element);
1824 bool IsUnsigned = DTy &&
DD->isUnsignedDIType(DTy);
1826 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 3)
1828 if (
DD->getDwarfVersion() >= 4 && (CTy->
getFlags() & DINode::FlagEnumClass))
1829 addFlag(Buffer, dwarf::DW_AT_enum_class);
1833 addUInt(Buffer, dwarf::DW_AT_APPLE_enum_kind, dwarf::DW_FORM_data1, *Kind);
1841 for (
const DINode *
E : Elements) {
1848 if (IndexEnumerators)
1856 DIE &SPDie = *
P.first;
1863 addDIEEntry(SPDie, dwarf::DW_AT_containing_type, *NDie);
1871 addString(MemberDie, dwarf::DW_AT_name, Name);
1875 if (
DIType *Resolved = DT->getBaseType())
1887 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
1888 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1889 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1891 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_minus);
1892 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1893 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
1895 addBlock(MemberDie, dwarf::DW_AT_data_member_location, VBaseLocationDie);
1906 if (
auto *VarDIE =
getDIE(Var))
1907 addDIEEntry(MemberDie, dwarf::DW_AT_bit_size, *VarDIE);
1909 addBlock(MemberDie, dwarf::DW_AT_bit_size, Exp);
1912 FieldSize =
DD->getBaseTypeSize(DT);
1915 if (
DD->useDWARF2Bitfields())
1916 addUInt(MemberDie, dwarf::DW_AT_byte_size, std::nullopt,
1918 addUInt(MemberDie, dwarf::DW_AT_bit_size, std::nullopt,
Size);
1926 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 6) {
1927 if (
auto *VarDIE =
getDIE(Var))
1928 addDIEEntry(MemberDie, dwarf::DW_AT_data_bit_offset, *VarDIE);
1930 }
else if (
auto *Expr =
1932 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 6) {
1933 addBlock(MemberDie, dwarf::DW_AT_data_bit_offset, Expr);
1941 (
uint64_t)std::numeric_limits<int64_t>::max());
1946 uint32_t AlignInBits = FieldSize;
1947 uint32_t AlignMask = ~(AlignInBits - 1);
1950 uint64_t StartBitOffset = Offset - (Offset & AlignMask);
1953 OffsetInBytes = (Offset - StartBitOffset) / 8;
1955 if (
DD->useDWARF2Bitfields()) {
1956 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
1957 uint64_t FieldOffset = (HiMark - FieldSize);
1958 Offset -= FieldOffset;
1961 if (
Asm->getDataLayout().isLittleEndian())
1962 Offset = FieldSize - (Offset +
Size);
1965 addSInt(MemberDie, dwarf::DW_AT_bit_offset, dwarf::DW_FORM_sdata,
1968 addUInt(MemberDie, dwarf::DW_AT_bit_offset, std::nullopt,
1970 OffsetInBytes = FieldOffset >> 3;
1972 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, std::nullopt,
1979 addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1983 if (
DD->getDwarfVersion() <= 2) {
1985 addUInt(*MemLocationDie, dwarf::DW_FORM_data1,
1986 dwarf::DW_OP_plus_uconst);
1987 addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
1988 addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
1989 }
else if (!IsBitfield ||
DD->useDWARF2Bitfields()) {
1994 if (
DD->getDwarfVersion() == 3)
1995 addUInt(MemberDie, dwarf::DW_AT_data_member_location,
1996 dwarf::DW_FORM_udata, OffsetInBytes);
1998 addUInt(MemberDie, dwarf::DW_AT_data_member_location, std::nullopt,
2007 addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1,
2008 dwarf::DW_VIRTUALITY_virtual);
2012 if (DIE *PDie =
getDIE(PNode))
2014 dwarf::DW_FORM_ref4, DIEEntry(*PDie));
2017 addFlag(MemberDie, dwarf::DW_AT_artificial);
2022void DwarfUnit::constructPropertyDIE(
DIE &Buffer,
const DIProperty *
P) {
2024 addString(PropertyDie, dwarf::DW_AT_name,
P->getName());
2025 if (DIType *Ty =
P->getType())
2029 if (DINode *BackingStorage =
P->getBackingStorage()) {
2038 DIE &GetterDie = *
P.first;
2045 addDIEEntry(GetterDie, dwarf::DW_AT_property_forward, *TargetDie);
2057 "Static member should belong to a type.");
2060 return StaticMemberDIE;
2065 const DIType *Ty = DT->getBaseType();
2070 addFlag(StaticMemberDIE, dwarf::DW_AT_external);
2071 addFlag(StaticMemberDIE, dwarf::DW_AT_declaration);
2075 addFlag(StaticMemberDIE, dwarf::DW_AT_artificial);
2086 else if (
auto *CDS =
2088 assert(CDS->getElementType()->isIntegerTy() &&
2089 "Non-integer arrays not supported.");
2091 for (
unsigned I = 0;
I != CDS->getNumElements(); ++
I)
2092 addIntToBlock(*
Block, CDS->getElementAsAPInt(
I));
2093 Block->computeSize(
Asm->getDwarfFormParams());
2094 addBlock(StaticMemberDIE, dwarf::DW_AT_const_value,
Block->BestForm(),
2099 addUInt(StaticMemberDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
2102 return &StaticMemberDIE;
2107 if (!
DD->useSectionsAsReferences())
2109 isDwoUnit() ?
"debug_info_dwo" :
"debug_info",
"Length of Unit");
2114 Asm->OutStreamer->AddComment(
"DWARF version number");
2115 unsigned Version =
DD->getDwarfVersion();
2120 Asm->OutStreamer->AddComment(
"DWARF Unit Type");
2122 Asm->OutStreamer->AddComment(
"Address Size (in bytes)");
2123 Asm->emitInt8(
Asm->MAI.getCodePointerSize());
2129 Asm->OutStreamer->AddComment(
"Offset Into Abbrev. Section");
2132 Asm->emitDwarfLengthOrOffset(0);
2134 Asm->emitDwarfSymbolReference(
2138 Asm->OutStreamer->AddComment(
"Address Size (in bytes)");
2139 Asm->emitInt8(
Asm->MAI.getCodePointerSize());
2144 if (!
DD->useSplitDwarf()) {
2149 DD->useSplitDwarf() ? dwarf::DW_UT_split_type
2150 : dwarf::DW_UT_type);
2151 Asm->OutStreamer->AddComment(
"Type Signature");
2152 Asm->OutStreamer->emitIntValue(TypeSignature,
sizeof(TypeSignature));
2153 Asm->OutStreamer->AddComment(
"Type DIE Offset");
2155 Asm->emitDwarfLengthOrOffset(Ty ? Ty->getOffset() : 0);
2168 if (
Asm->doesDwarfUseRelocationsAcrossSections() && !isDwoUnit())
2171 addSectionDelta(Die,
Attribute, Label, Sec);
2174bool DwarfTypeUnit::isDwoUnit()
const {
2201 DU->getStringOffsetsStartSym(),
2206 assert(
DD->getDwarfVersion() >= 5 &&
2207 "DW_AT_rnglists_base requires DWARF version 5 or later");
2210 DU->getRnglistsTableBaseSym(),
2218bool 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
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 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
A property of a class or structure.
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
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...
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.
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 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.
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.