39#define DEBUG_TYPE "dwarfdebug"
45void DIEDwarfExpression::emitOp(
uint8_t Op,
const char* Comment) {
46 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Op);
49void DIEDwarfExpression::emitSigned(int64_t
Value) {
50 CU.addSInt(getActiveDIE(), dwarf::DW_FORM_sdata,
Value);
53void DIEDwarfExpression::emitUnsigned(uint64_t
Value) {
54 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_udata,
Value);
57void DIEDwarfExpression::emitData1(uint8_t
Value) {
58 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Value);
61void DIEDwarfExpression::emitBaseTypeRef(uint64_t Idx) {
62 CU.addBaseTypeRef(getActiveDIE(), Idx);
66 assert(!IsBuffering &&
"Already buffering?");
73 return TmpDIE.computeSize(AP.getDwarfFormParams());
80 return MachineReg ==
TRI.getFrameRegister(*AP.MF);
93 CU(
CU), SplitLineTable(SplitLineTable) {}
102int64_t DwarfUnit::getDefaultLowerBound()
const {
108 case dwarf::DW_LANG_C:
109 case dwarf::DW_LANG_C89:
110 case dwarf::DW_LANG_C_plus_plus:
113 case dwarf::DW_LANG_Fortran77:
114 case dwarf::DW_LANG_Fortran90:
118 case dwarf::DW_LANG_C99:
119 case dwarf::DW_LANG_ObjC:
120 case dwarf::DW_LANG_ObjC_plus_plus:
125 case dwarf::DW_LANG_Fortran95:
131 case dwarf::DW_LANG_D:
132 case dwarf::DW_LANG_Java:
133 case dwarf::DW_LANG_Python:
134 case dwarf::DW_LANG_UPC:
139 case dwarf::DW_LANG_Ada83:
140 case dwarf::DW_LANG_Ada95:
141 case dwarf::DW_LANG_Cobol74:
142 case dwarf::DW_LANG_Cobol85:
143 case dwarf::DW_LANG_Modula2:
144 case dwarf::DW_LANG_Pascal83:
145 case dwarf::DW_LANG_PLI:
151 case dwarf::DW_LANG_BLISS:
152 case dwarf::DW_LANG_C11:
153 case dwarf::DW_LANG_C_plus_plus_03:
154 case dwarf::DW_LANG_C_plus_plus_11:
155 case dwarf::DW_LANG_C_plus_plus_14:
156 case dwarf::DW_LANG_Dylan:
157 case dwarf::DW_LANG_Go:
158 case dwarf::DW_LANG_Haskell:
159 case dwarf::DW_LANG_OCaml:
160 case dwarf::DW_LANG_OpenCL:
161 case dwarf::DW_LANG_RenderScript:
162 case dwarf::DW_LANG_Rust:
163 case dwarf::DW_LANG_Swift:
168 case dwarf::DW_LANG_Fortran03:
169 case dwarf::DW_LANG_Fortran08:
170 case dwarf::DW_LANG_Julia:
171 case dwarf::DW_LANG_Modula3:
189 if (isDwoUnit() && !
DD->shareAcrossDWOCUs())
193 !
DD->generateTypeUnits();
198 return DU->getDIE(
D);
215 if (
DD->getDwarfVersion() >= 4)
225 assert(Form != dwarf::DW_FORM_implicit_const &&
226 "DW_FORM_implicit_const is used only for signed integers");
245 for (
int i = 0; i < NumBytes; i++) {
248 c = Ptr64[i / 8] >> (8 * (i & 7));
250 c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
260 if (CIBitWidth <= 64) {
272 std::optional<dwarf::Form> Form, int64_t
Integer) {
285 if (
CUNode->isDebugDirectivesOnly())
288 if (
DD->useInlineStrings()) {
295 isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp;
297 auto StringPoolEntry =
299 ?
DU->getStringPool().getIndexedEntry(*
Asm,
String)
304 IxForm = dwarf::DW_FORM_strx1;
305 unsigned Index = StringPoolEntry.getIndex();
306 if (Index > 0xffffff)
307 IxForm = dwarf::DW_FORM_strx4;
308 else if (Index > 0xffff)
309 IxForm = dwarf::DW_FORM_strx3;
310 else if (Index > 0xff)
311 IxForm = dwarf::DW_FORM_strx2;
330unsigned DwarfTypeUnit::getOrCreateSourceID(
const DIFile *File) {
333 if (!UsedLineTable) {
334 UsedLineTable =
true;
338 return SplitLineTable->
getFile(
344 bool UseAddrOffsetFormOrExpressions =
345 DD->useAddrOffsetForm() ||
DD->useAddrOffsetExpressions();
348 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
349 Base =
DD->getSectionLabel(&Label->getSection());
353 if (
DD->getDwarfVersion() >= 5) {
354 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx);
355 addUInt(Die, dwarf::DW_FORM_addrx, Index);
357 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
358 addUInt(Die, dwarf::DW_FORM_GNU_addr_index, Index);
362 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_const4u);
364 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
369 if (
DD->getDwarfVersion() >= 5) {
374 if (
DD->useSplitDwarf()) {
379 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
380 addLabel(Die, dwarf::DW_FORM_addr, Sym);
398 addFlag(Die, dwarf::DW_AT_declaration);
400 addAttribute(Die, dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
407 const DIEUnit *EntryCU = Entry.getEntry().getUnit();
413 assert(EntryCU ==
CU || !
DD->useSplitDwarf() ||
DD->shareAcrossDWOCUs() ||
416 EntryCU ==
CU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
428 Loc->computeSize(
Asm->getDwarfFormParams());
435 Block->computeSize(
Asm->getDwarfFormParams());
451 addUInt(Die, dwarf::DW_AT_decl_file, std::nullopt, FileID);
452 addUInt(Die, dwarf::DW_AT_decl_line, std::nullopt, Line);
455 addUInt(Die, dwarf::DW_AT_decl_column, std::nullopt, Column);
479 addSourceLine(Die, L->getLine(), L->getColumn(), L->getFile());
511 addUInt(Die, dwarf::DW_AT_const_value,
512 Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
521 if (CIBitWidth <= 64) {
527 addIntAsBlock(Die, dwarf::DW_AT_const_value, Val);
533 DD->getDwarfVersion() >= 4 ? dwarf::DW_AT_linkage_name
534 : dwarf::DW_AT_MIPS_linkage_name,
540 for (
const auto *Element : TParams) {
542 constructTemplateTypeParameterDIE(Buffer, TTP);
544 constructTemplateValueParameterDIE(Buffer, TVP);
550 for (
const auto *Ty : ThrownTypes) {
558 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
561 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
564 addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
583 auto *Context = Ty->getScope();
603 auto construct = [&](
const auto *Ty) {
609 if (
DD->generateTypeUnits() && !Ty->isForwardDecl() &&
610 (Ty->getRawName() || CTy->getRawIdentifier())) {
612 if (
MDString *TypeId = CTy->getRawIdentifier()) {
614 DD->addDwarfTypeUnitType(
getCU(), TypeId->getString(), TyDIE, CTy);
617 finishNonUnitTypeDIE(TyDIE, CTy);
631 constructSubrangeDIE(TyDIE, SRTy);
645 if (Ty->getTag() == dwarf::DW_TAG_restrict_type &&
DD->getDwarfVersion() <= 2)
649 if (Ty->getTag() == dwarf::DW_TAG_atomic_type &&
DD->getDwarfVersion() < 5)
654 auto *Context = Ty->getScope();
662 ->createTypeDIE(Context, *ContextDIE, Ty);
667 if (Ty->getName().empty())
669 if (Ty->isForwardDecl())
678 if (CT->getRuntimeLang() == 0 || CT->isObjcClassComplete())
682 DD->addAccelType(*
this,
CUNode->getNameTableKind(), Ty->getName(), TyDIE,
686 if (Ty->getName() != CT->getIdentifier() &&
687 CT->getRuntimeLang() == dwarf::DW_LANG_Swift)
688 DD->addAccelType(*
this,
CUNode->getNameTableKind(), CT->getIdentifier(),
703 assert(Ty &&
"Trying to add a type that doesn't exist?");
709 const auto &Lang = getLanguage();
711 if (!Lang.hasVersionedName())
731 Parents.push_back(Context);
745 Name =
"(anonymous namespace)";
759 addString(Buffer, dwarf::DW_AT_name, Name);
762 if (BTy->
getTag() == dwarf::DW_TAG_unspecified_type)
765 if (BTy->
getTag() != dwarf::DW_TAG_string_type)
766 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
770 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, SizeInBytes);
771 if (BTy->
getTag() == dwarf::Tag::DW_TAG_base_type) {
779 DataSizeInBits && DataSizeInBits != SizeInBytes * 8)
780 addUInt(Buffer, dwarf::DW_AT_bit_size, std::nullopt, DataSizeInBits);
784 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_big);
786 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_little);
789 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
790 NumExtraInhabitants);
798 addSInt(Buffer, dwarf::DW_AT_binary_scale, dwarf::DW_FORM_sdata,
801 addSInt(Buffer, dwarf::DW_AT_decimal_scale, dwarf::DW_FORM_sdata,
822 addString(Buffer, dwarf::DW_AT_name, Name);
825 if (
auto *VarDIE =
getDIE(Var))
826 addDIEEntry(Buffer, dwarf::DW_AT_string_length, *VarDIE);
829 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
833 DwarfExpr.setMemoryLocationKind();
834 DwarfExpr.addExpression(Expr);
835 addBlock(Buffer, dwarf::DW_AT_string_length, DwarfExpr.finalize());
838 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
843 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
846 DwarfExpr.setMemoryLocationKind();
847 DwarfExpr.addExpression(Expr);
848 addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
853 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
865 const DIType *FromTy = DTy->getBaseType();
871 addString(Buffer, dwarf::DW_AT_name, Name);
877 if (
Tag == dwarf::DW_TAG_typedef &&
DD->getDwarfVersion() >= 5) {
879 if (AlignInBytes > 0)
880 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
885 if (
Size &&
Tag != dwarf::DW_TAG_pointer_type
886 &&
Tag != dwarf::DW_TAG_ptr_to_member_type
887 &&
Tag != dwarf::DW_TAG_reference_type
888 &&
Tag != dwarf::DW_TAG_rvalue_reference_type)
889 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
891 if (
Tag == dwarf::DW_TAG_ptr_to_member_type)
904 if (DTy->getDWARFAddressSpace())
905 addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,
906 *DTy->getDWARFAddressSpace());
909 if (
Tag == dwarf::DW_TAG_template_alias)
912 if (
auto PtrAuthData = DTy->getPtrAuthData()) {
913 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_key, dwarf::DW_FORM_data1,
915 if (PtrAuthData->isAddressDiscriminated())
916 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_address_discriminated);
917 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_extra_discriminator,
918 dwarf::DW_FORM_data2, PtrAuthData->extraDiscriminator());
919 if (PtrAuthData->isaPointer())
920 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_isa_pointer);
921 if (PtrAuthData->authenticatesNullValues())
922 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_authenticates_null_values);
926std::optional<unsigned>
929 std::optional<unsigned> ObjectPointerIndex;
930 for (
unsigned i = 1,
N = Args.size(); i <
N; ++i) {
931 const DIType *Ty = Args[i];
933 assert(i ==
N-1 &&
"Unspecified parameter must be the last argument");
938 if (Ty->isArtificial())
939 addFlag(Arg, dwarf::DW_AT_artificial);
941 if (Ty->isObjectPointer()) {
942 assert(!ObjectPointerIndex &&
943 "Can't have more than one object pointer");
944 ObjectPointerIndex = i;
949 return ObjectPointerIndex;
956 if (
auto RTy = Elements[0])
959 bool isPrototyped =
true;
960 if (Elements.size() == 2 && !Elements[1])
961 isPrototyped =
false;
968 addFlag(Buffer, dwarf::DW_AT_prototyped);
971 if (CTy->
getCC() && CTy->
getCC() != dwarf::DW_CC_normal)
972 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
976 addFlag(Buffer, dwarf::DW_AT_reference);
979 addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
992 addString(AnnotationDie, dwarf::DW_AT_name, Name->getString());
994 addString(AnnotationDie, dwarf::DW_AT_const_value,
Data->getString());
999 assert(
false &&
"Unsupported annotation value type");
1003void DwarfUnit::addDiscriminant(
DIE &Variant,
Constant *Discriminant,
1006 addInt(Variant, dwarf::DW_AT_discr_value, CI->getValue(), IsUnsigned);
1007 }
else if (
const auto *CA =
1010 unsigned NElems = CA->getNumElements();
1011 if (NElems % 2 != 0) {
1017 auto AddInt = [&](
const APInt &Val) {
1024 for (
unsigned I = 0;
I < NElems;
I += 2) {
1025 APInt LV = CA->getElementAsAPInt(
I);
1026 APInt HV = CA->getElementAsAPInt(
I + 1);
1047 case dwarf::DW_TAG_array_type:
1048 constructArrayTypeDIE(Buffer, CTy);
1050 case dwarf::DW_TAG_enumeration_type:
1051 constructEnumTypeDIE(Buffer, CTy);
1053 case dwarf::DW_TAG_variant_part:
1054 case dwarf::DW_TAG_variant:
1055 case dwarf::DW_TAG_structure_type:
1056 case dwarf::DW_TAG_union_type:
1057 case dwarf::DW_TAG_class_type:
1058 case dwarf::DW_TAG_namelist: {
1061 if (
Tag == dwarf::DW_TAG_variant_part) {
1063 if (Discriminator) {
1075 if (DiscDIE ==
nullptr) {
1076 DiscDIE = &constructMemberDIE(Buffer, Discriminator);
1078 addDIEEntry(Buffer, dwarf::DW_AT_discr, *DiscDIE);
1083 if (
Tag == dwarf::DW_TAG_class_type ||
1084 Tag == dwarf::DW_TAG_structure_type ||
Tag == dwarf::DW_TAG_union_type)
1089 for (
const auto *Element : Elements) {
1095 if (DDTy->getTag() == dwarf::DW_TAG_friend) {
1097 addType(ElemDie, DDTy->getBaseType(), dwarf::DW_AT_friend);
1098 }
else if (DDTy->isStaticMember()) {
1100 }
else if (
Tag == dwarf::DW_TAG_variant_part) {
1104 if (
Constant *CI = DDTy->getDiscriminantValue()) {
1105 addDiscriminant(Variant, CI,
1106 DD->isUnsignedDIType(Discriminator->getBaseType()));
1111 if (
auto *Composite =
1113 Composite !=
nullptr &&
1114 Composite->getTag() == dwarf::DW_TAG_variant) {
1117 constructMemberDIE(Variant, DDTy);
1120 constructMemberDIE(Buffer, DDTy);
1124 StringRef PropertyName = Property->getName();
1125 addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
1126 if (Property->getType())
1127 addType(ElemDie, Property->getType());
1129 StringRef GetterName = Property->getGetterName();
1130 if (!GetterName.
empty())
1131 addString(ElemDie, dwarf::DW_AT_APPLE_property_getter, GetterName);
1132 StringRef SetterName = Property->getSetterName();
1133 if (!SetterName.
empty())
1134 addString(ElemDie, dwarf::DW_AT_APPLE_property_setter, SetterName);
1135 if (
unsigned PropertyAttributes = Property->getAttributes())
1136 addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, std::nullopt,
1137 PropertyAttributes);
1139 if (Composite->getTag() == dwarf::DW_TAG_variant_part) {
1143 }
else if (
Tag == dwarf::DW_TAG_namelist) {
1145 auto *VarDIE =
getDIE(Var);
1148 addDIEEntry(ItemDie, dwarf::DW_AT_namelist_item, *VarDIE);
1154 addFlag(Buffer, dwarf::DW_AT_APPLE_block);
1157 addFlag(Buffer, dwarf::DW_AT_export_symbols);
1168 addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
1172 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 5) {
1175 CC = dwarf::DW_CC_pass_by_value;
1177 CC = dwarf::DW_CC_pass_by_reference;
1179 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
1195 addString(Buffer, dwarf::DW_AT_name, Name);
1203 if (
Tag == dwarf::DW_TAG_enumeration_type ||
1204 Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
1205 Tag == dwarf::DW_TAG_union_type) {
1207 if (
auto *VarDIE =
getDIE(Var))
1208 addDIEEntry(Buffer, dwarf::DW_AT_bit_size, *VarDIE);
1209 }
else if (
auto *Exp =
1223 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
1226 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, 0);
1231 addFlag(Buffer, dwarf::DW_AT_declaration);
1243 addUInt(Buffer, dwarf::DW_AT_APPLE_runtime_class, dwarf::DW_FORM_data1,
1248 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1252 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
1253 NumExtraInhabitants);
1257void DwarfUnit::constructTemplateTypeParameterDIE(
1266 if (TP->
isDefault() && isCompatibleWithVersion(5))
1267 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1270void DwarfUnit::constructTemplateValueParameterDIE(
1276 if (VP->
getTag() == dwarf::DW_TAG_template_value_parameter)
1280 if (VP->
isDefault() && isCompatibleWithVersion(5))
1281 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1290 if (!GV->hasDLLImportStorageClass()) {
1297 addUInt(*
Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
1300 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1302 addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
1304 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1323 Name =
"(anonymous namespace)";
1324 DD->addAccelNamespace(*
this,
CUNode->getNameTableKind(), Name, NDie);
1327 addFlag(NDie, dwarf::DW_AT_export_symbols);
1340 if (!M->getName().empty()) {
1341 addString(MDie, dwarf::DW_AT_name, M->getName());
1344 if (!M->getConfigurationMacros().empty())
1345 addString(MDie, dwarf::DW_AT_LLVM_config_macros,
1346 M->getConfigurationMacros());
1347 if (!M->getIncludePath().empty())
1348 addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
1349 if (!M->getAPINotesFile().empty())
1350 addString(MDie, dwarf::DW_AT_LLVM_apinotes, M->getAPINotesFile());
1352 addUInt(MDie, dwarf::DW_AT_decl_file, std::nullopt,
1355 addUInt(MDie, dwarf::DW_AT_decl_line, std::nullopt, M->getLineNo());
1357 addFlag(MDie, dwarf::DW_AT_declaration);
1363 const Function *FnHint,
bool Minimal) {
1373 if (
auto *SPDecl = SP->getDeclaration()) {
1392 if (SP->isDefinition())
1396 ->applySubprogramAttributes(SP, SPDie);
1401 DIE &SPDie,
bool Minimal) {
1402 DIE *DeclDie =
nullptr;
1404 if (
auto *SPDecl = SP->getDeclaration()) {
1407 DeclArgs = SPDecl->getType()->getTypeArray();
1408 DefinitionArgs = SP->getType()->getTypeArray();
1410 if (DeclArgs.
size() && DefinitionArgs.
size())
1411 if (DefinitionArgs[0] !=
nullptr && DeclArgs[0] != DefinitionArgs[0])
1412 addType(SPDie, DefinitionArgs[0]);
1414 DeclDie =
getDIE(SPDecl);
1415 assert(DeclDie &&
"This DIE should've already been constructed when the "
1416 "definition DIE was created in "
1417 "getOrCreateSubprogramDIE");
1419 if (
DD->useAllLinkageNames())
1420 DeclLinkageName = SPDecl->getLinkageName();
1423 if (DeclID != DefID)
1424 addUInt(SPDie, dwarf::DW_AT_decl_file, std::nullopt, DefID);
1426 if (SP->getLine() != SPDecl->getLine())
1427 addUInt(SPDie, dwarf::DW_AT_decl_line, std::nullopt, SP->getLine());
1438 (
DD->useAllLinkageNames() ||
DU->getAbstractScopeDIEs().lookup(SP)))
1446 addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
1451 bool SkipSPAttributes) {
1454 bool SkipSPSourceLocation = SkipSPAttributes &&
1455 !
CUNode->getDebugInfoForProfiling();
1456 if (!SkipSPSourceLocation)
1461 if (!SP->getName().empty())
1462 addString(SPDie, dwarf::DW_AT_name, SP->getName());
1466 if (!SkipSPSourceLocation)
1470 if (SkipSPAttributes)
1476 addFlag(SPDie, dwarf::DW_AT_prototyped);
1478 if (SP->isObjCDirect())
1479 addFlag(SPDie, dwarf::DW_AT_APPLE_objc_direct);
1484 Args = SPTy->getTypeArray();
1489 if (CC && CC != dwarf::DW_CC_normal)
1490 addUInt(SPDie, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1, CC);
1495 if (
auto Ty = Args[0])
1498 unsigned VK = SP->getVirtuality();
1500 addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
1501 if (SP->getVirtualIndex() != -1u) {
1503 addUInt(*
Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1504 addUInt(*
Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1510 if (!SP->isDefinition()) {
1511 addFlag(SPDie, dwarf::DW_AT_declaration);
1518 if (std::optional<unsigned> ObjectPointerIndex =
1524 assert(*ObjectPointerIndex > 0);
1525 addSInt(SPDie, dwarf::DW_AT_object_pointer,
1526 dwarf::DW_FORM_implicit_const, *ObjectPointerIndex - 1);
1533 if (SP->isArtificial())
1534 addFlag(SPDie, dwarf::DW_AT_artificial);
1536 if (!SP->isLocalToUnit())
1537 addFlag(SPDie, dwarf::DW_AT_external);
1539 if (
DD->useAppleExtensionAttributes()) {
1540 if (SP->isOptimized())
1541 addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
1543 if (
unsigned isa =
Asm->getISAEncoding())
1544 addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag,
isa);
1547 if (SP->isLValueReference())
1548 addFlag(SPDie, dwarf::DW_AT_reference);
1550 if (SP->isRValueReference())
1551 addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
1553 if (SP->isNoReturn())
1554 addFlag(SPDie, dwarf::DW_AT_noreturn);
1558 if (SP->isExplicit())
1559 addFlag(SPDie, dwarf::DW_AT_explicit);
1561 if (SP->isMainSubprogram())
1562 addFlag(SPDie, dwarf::DW_AT_main_subprogram);
1564 addFlag(SPDie, dwarf::DW_AT_pure);
1565 if (SP->isElemental())
1566 addFlag(SPDie, dwarf::DW_AT_elemental);
1567 if (SP->isRecursive())
1568 addFlag(SPDie, dwarf::DW_AT_recursive);
1570 if (!SP->getTargetFuncName().empty())
1571 addString(SPDie, dwarf::DW_AT_trampoline, SP->getTargetFuncName());
1573 if (
DD->getDwarfVersion() >= 5 && SP->isDeleted())
1574 addFlag(SPDie, dwarf::DW_AT_deleted);
1581 addString(DW_Subrange, dwarf::DW_AT_name, Name);
1589 addUInt(DW_Subrange, dwarf::DW_AT_byte_size, std::nullopt,
Size >> 3);
1591 addUInt(DW_Subrange, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1595 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1598 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1599 dwarf::DW_END_little);
1603 int64_t DefaultLowerBound = getDefaultLowerBound();
1608 if (
auto *VarDIE =
getDIE(BV))
1613 DwarfExpr.setMemoryLocationKind();
1614 DwarfExpr.addExpression(BE);
1615 addBlock(DW_Subrange, Attr, DwarfExpr.finalize());
1617 if (Attr == dwarf::DW_AT_GNU_bias) {
1618 if (BI->getSExtValue() != 0)
1619 addUInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1620 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1621 BI->getSExtValue() != DefaultLowerBound || !ForArray)
1622 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1626 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1628 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1630 AddBoundTypeEntry(dwarf::DW_AT_bit_stride, SR->
getStride());
1632 AddBoundTypeEntry(dwarf::DW_AT_GNU_bias, SR->
getBias());
1635void DwarfUnit::constructSubrangeDIE(
DIE &Buffer,
const DISubrange *SR) {
1636 DIE &DW_Subrange =
createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
1638 DIE *IdxTy = getIndexTyDie();
1639 addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IdxTy);
1645 int64_t DefaultLowerBound = getDefaultLowerBound();
1648 DISubrange::BoundType Bound) ->
void {
1650 if (
auto *VarDIE =
getDIE(BV))
1654 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1655 DwarfExpr.setMemoryLocationKind();
1656 DwarfExpr.addExpression(BE);
1657 addBlock(DW_Subrange, Attr, DwarfExpr.finalize());
1659 if (Attr == dwarf::DW_AT_count) {
1660 if (BI->getSExtValue() != -1)
1661 addUInt(DW_Subrange, Attr, std::nullopt, BI->getSExtValue());
1662 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1663 BI->getSExtValue() != DefaultLowerBound)
1664 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1668 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1670 AddBoundTypeEntry(dwarf::DW_AT_count, SR->
getCount());
1672 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1674 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, SR->
getStride());
1677void DwarfUnit::constructGenericSubrangeDIE(
DIE &Buffer,
1679 DIE &DwGenericSubrange =
1684 DIE *IdxTy = getIndexTyDie();
1685 addDIEEntry(DwGenericSubrange, dwarf::DW_AT_type, *IdxTy);
1687 int64_t DefaultLowerBound = getDefaultLowerBound();
1692 if (
auto *VarDIE =
getDIE(BV))
1695 if (BE->isConstant() &&
1697 *BE->isConstant()) {
1698 if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1699 static_cast<int64_t
>(BE->getElement(1)) != DefaultLowerBound)
1700 addSInt(DwGenericSubrange, Attr, dwarf::DW_FORM_sdata,
1704 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1705 DwarfExpr.setMemoryLocationKind();
1706 DwarfExpr.addExpression(BE);
1707 addBlock(DwGenericSubrange, Attr, DwarfExpr.finalize());
1712 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, GSR->
getLowerBound());
1713 AddBoundTypeEntry(dwarf::DW_AT_count, GSR->
getCount());
1714 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, GSR->
getUpperBound());
1715 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, GSR->
getStride());
1718DIE *DwarfUnit::getIndexTyDie() {
1723 StringRef
Name =
"__ARRAY_SIZE_TYPE__";
1737 assert(CTy && CTy->
isVector() &&
"Composite type is not a vector");
1742 assert(BaseTy &&
"Unknown vector element type.");
1747 assert(Elements.size() == 1 &&
1748 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type &&
1749 "Invalid vector element array, expected one element of type subrange");
1751 const auto NumVecElements =
1752 Subrange->getCount()
1758 assert(ActualSize >= (NumVecElements * ElementSize) &&
"Invalid vector size");
1759 return ActualSize != (NumVecElements * ElementSize);
1764 addFlag(Buffer, dwarf::DW_AT_GNU_vector);
1766 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
1771 if (
auto *VarDIE =
getDIE(Var))
1772 addDIEEntry(Buffer, dwarf::DW_AT_data_location, *VarDIE);
1775 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1776 DwarfExpr.setMemoryLocationKind();
1777 DwarfExpr.addExpression(Expr);
1778 addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
1782 if (
auto *VarDIE =
getDIE(Var))
1783 addDIEEntry(Buffer, dwarf::DW_AT_associated, *VarDIE);
1786 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1787 DwarfExpr.setMemoryLocationKind();
1788 DwarfExpr.addExpression(Expr);
1789 addBlock(Buffer, dwarf::DW_AT_associated, DwarfExpr.finalize());
1793 if (
auto *VarDIE =
getDIE(Var))
1794 addDIEEntry(Buffer, dwarf::DW_AT_allocated, *VarDIE);
1797 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1798 DwarfExpr.setMemoryLocationKind();
1799 DwarfExpr.addExpression(Expr);
1800 addBlock(Buffer, dwarf::DW_AT_allocated, DwarfExpr.finalize());
1804 addSInt(Buffer, dwarf::DW_AT_rank, dwarf::DW_FORM_sdata,
1805 RankConst->getSExtValue());
1806 }
else if (
auto *RankExpr = CTy->
getRankExp()) {
1808 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1809 DwarfExpr.setMemoryLocationKind();
1810 DwarfExpr.addExpression(RankExpr);
1811 addBlock(Buffer, dwarf::DW_AT_rank, DwarfExpr.finalize());
1815 addUInt(Buffer, dwarf::DW_AT_bit_stride, {}, BitStride->getZExtValue());
1823 for (DINode *
E : Elements) {
1826 constructSubrangeDIE(TyDIE, Element,
true);
1828 constructSubrangeDIE(Buffer, Element);
1830 constructGenericSubrangeDIE(Buffer, Element);
1836 bool IsUnsigned = DTy &&
DD->isUnsignedDIType(DTy);
1838 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 3)
1840 if (
DD->getDwarfVersion() >= 4 && (CTy->
getFlags() & DINode::FlagEnumClass))
1841 addFlag(Buffer, dwarf::DW_AT_enum_class);
1845 addUInt(Buffer, dwarf::DW_AT_APPLE_enum_kind, dwarf::DW_FORM_data1, *Kind);
1853 for (
const DINode *
E : Elements) {
1860 if (IndexEnumerators)
1868 DIE &SPDie = *
P.first;
1875 addDIEEntry(SPDie, dwarf::DW_AT_containing_type, *NDie);
1883 addString(MemberDie, dwarf::DW_AT_name, Name);
1887 if (
DIType *Resolved = DT->getBaseType())
1899 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
1900 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1901 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1903 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_minus);
1904 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1905 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
1907 addBlock(MemberDie, dwarf::DW_AT_data_member_location, VBaseLocationDie);
1918 if (
auto *VarDIE =
getDIE(Var))
1919 addDIEEntry(MemberDie, dwarf::DW_AT_bit_size, *VarDIE);
1922 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1923 DwarfExpr.setMemoryLocationKind();
1924 DwarfExpr.addExpression(Exp);
1925 addBlock(MemberDie, dwarf::DW_AT_bit_size, DwarfExpr.finalize());
1928 FieldSize =
DD->getBaseTypeSize(DT);
1931 if (
DD->useDWARF2Bitfields())
1932 addUInt(MemberDie, dwarf::DW_AT_byte_size, std::nullopt,
1934 addUInt(MemberDie, dwarf::DW_AT_bit_size, std::nullopt,
Size);
1942 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 6) {
1943 if (
auto *VarDIE =
getDIE(Var))
1944 addDIEEntry(MemberDie, dwarf::DW_AT_data_bit_offset, *VarDIE);
1946 }
else if (
auto *Expr =
1948 if (!
Asm->TM.Options.DebugStrictDwarf ||
DD->getDwarfVersion() >= 6) {
1950 DIEDwarfExpression DwarfExpr(*
Asm,
getCU(), *Loc);
1951 DwarfExpr.setMemoryLocationKind();
1952 DwarfExpr.addExpression(Expr);
1953 addBlock(MemberDie, dwarf::DW_AT_data_bit_offset, DwarfExpr.finalize());
1957 uint64_t OffsetInBytes;
1961 (uint64_t)std::numeric_limits<int64_t>::max());
1966 uint32_t AlignInBits = FieldSize;
1967 uint32_t AlignMask = ~(AlignInBits - 1);
1970 uint64_t StartBitOffset = Offset - (Offset & AlignMask);
1973 OffsetInBytes = (Offset - StartBitOffset) / 8;
1975 if (
DD->useDWARF2Bitfields()) {
1976 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
1977 uint64_t FieldOffset = (HiMark - FieldSize);
1978 Offset -= FieldOffset;
1981 if (
Asm->getDataLayout().isLittleEndian())
1982 Offset = FieldSize - (Offset +
Size);
1985 addSInt(MemberDie, dwarf::DW_AT_bit_offset, dwarf::DW_FORM_sdata,
1988 addUInt(MemberDie, dwarf::DW_AT_bit_offset, std::nullopt,
1990 OffsetInBytes = FieldOffset >> 3;
1992 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, std::nullopt,
1999 addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
2003 if (
DD->getDwarfVersion() <= 2) {
2005 addUInt(*MemLocationDie, dwarf::DW_FORM_data1,
2006 dwarf::DW_OP_plus_uconst);
2007 addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
2008 addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
2009 }
else if (!IsBitfield ||
DD->useDWARF2Bitfields()) {
2014 if (
DD->getDwarfVersion() == 3)
2015 addUInt(MemberDie, dwarf::DW_AT_data_member_location,
2016 dwarf::DW_FORM_udata, OffsetInBytes);
2018 addUInt(MemberDie, dwarf::DW_AT_data_member_location, std::nullopt,
2027 addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1,
2028 dwarf::DW_VIRTUALITY_virtual);
2032 if (DIE *PDie =
getDIE(PNode))
2034 dwarf::DW_FORM_ref4, DIEEntry(*PDie));
2037 addFlag(MemberDie, dwarf::DW_AT_artificial);
2050 "Static member should belong to a type.");
2053 return StaticMemberDIE;
2058 const DIType *Ty = DT->getBaseType();
2063 addFlag(StaticMemberDIE, dwarf::DW_AT_external);
2064 addFlag(StaticMemberDIE, dwarf::DW_AT_declaration);
2068 addFlag(StaticMemberDIE, dwarf::DW_AT_artificial);
2080 addUInt(StaticMemberDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
2083 return &StaticMemberDIE;
2088 if (!
DD->useSectionsAsReferences())
2090 isDwoUnit() ?
"debug_info_dwo" :
"debug_info",
"Length of Unit");
2095 Asm->OutStreamer->AddComment(
"DWARF version number");
2096 unsigned Version =
DD->getDwarfVersion();
2101 Asm->OutStreamer->AddComment(
"DWARF Unit Type");
2103 Asm->OutStreamer->AddComment(
"Address Size (in bytes)");
2104 Asm->emitInt8(
Asm->MAI->getCodePointerSize());
2110 Asm->OutStreamer->AddComment(
"Offset Into Abbrev. Section");
2113 Asm->emitDwarfLengthOrOffset(0);
2115 Asm->emitDwarfSymbolReference(
2119 Asm->OutStreamer->AddComment(
"Address Size (in bytes)");
2120 Asm->emitInt8(
Asm->MAI->getCodePointerSize());
2125 if (!
DD->useSplitDwarf()) {
2130 DD->useSplitDwarf() ? dwarf::DW_UT_split_type
2131 : dwarf::DW_UT_type);
2132 Asm->OutStreamer->AddComment(
"Type Signature");
2133 Asm->OutStreamer->emitIntValue(TypeSignature,
sizeof(TypeSignature));
2134 Asm->OutStreamer->AddComment(
"Type DIE Offset");
2136 Asm->emitDwarfLengthOrOffset(Ty ? Ty->getOffset() : 0);
2147 if (
Asm->doesDwarfUseRelocationsAcrossSections())
2153bool DwarfTypeUnit::isDwoUnit()
const {
2180 DU->getStringOffsetsStartSym(),
2185 assert(
DD->getDwarfVersion() >= 5 &&
2186 "DW_AT_rnglists_base requires DWARF version 5 or later");
2189 DU->getRnglistsTableBaseSym(),
2197bool 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.