39#define DEBUG_TYPE "dwarfdebug"
45void DIEDwarfExpression::emitOp(
uint8_t Op,
const char* Comment) {
46 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Op);
49void DIEDwarfExpression::emitSigned(int64_t
Value) {
50 CU.addSInt(getActiveDIE(), dwarf::DW_FORM_sdata,
Value);
54 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_udata,
Value);
58 CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,
Value);
61void DIEDwarfExpression::emitBaseTypeRef(
uint64_t Idx) {
62 CU.addBaseTypeRef(getActiveDIE(),
Idx);
65void DIEDwarfExpression::enableTemporaryBuffer() {
66 assert(!IsBuffering &&
"Already buffering?");
70void DIEDwarfExpression::disableTemporaryBuffer() { IsBuffering =
false; }
72unsigned DIEDwarfExpression::getTemporaryBufferSize() {
76void DIEDwarfExpression::commitTemporaryBuffer() { OutDIE.
takeValues(TmpDIE); }
80 return MachineReg ==
TRI.getFrameRegister(*AP.
MF);
86 :
DIEUnit(UnitTag), UniqueID(UniqueID), CUNode(Node), Asm(
A), DD(DW),
92 :
DwarfUnit(dwarf::DW_TAG_type_unit,
CU.getCUNode(),
A, DW, DWU, UniqueID),
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:
191 return (isa<DIType>(
D) ||
192 (isa<DISubprogram>(
D) && !cast<DISubprogram>(
D)->isDefinition())) &&
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) {
295 isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp;
297 auto StringPoolEntry =
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 =
348 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
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);
379 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
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();
416 EntryCU ==
CU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
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);
534 : dwarf::DW_AT_MIPS_linkage_name,
540 for (
const auto *Element : TParams) {
541 if (
auto *TTP = dyn_cast<DITemplateTypeParameter>(Element))
542 constructTemplateTypeParameterDIE(Buffer, TTP);
543 else if (
auto *TVP = dyn_cast<DITemplateValueParameter>(Element))
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,
571 if (
auto *
T = dyn_cast<DIType>(
Context))
573 if (
auto *NS = dyn_cast<DINamespace>(
Context))
575 if (
auto *SP = dyn_cast<DISubprogram>(
Context))
577 if (
auto *M = dyn_cast<DIModule>(
Context))
603 auto construct = [&](
const auto *Ty) {
608 if (
auto *CTy = dyn_cast<DICompositeType>(Ty)) {
610 (Ty->
getRawName() || CTy->getRawIdentifier())) {
612 if (
MDString *TypeId = CTy->getRawIdentifier()) {
617 finishNonUnitTypeDIE(TyDIE, CTy);
622 }
else if (
auto *FPT = dyn_cast<DIFixedPointType>(Ty))
624 else if (
auto *
BT = dyn_cast<DIBasicType>(Ty))
626 else if (
auto *ST = dyn_cast<DIStringType>(Ty))
628 else if (
auto *STy = dyn_cast<DISubroutineType>(Ty))
630 else if (
auto *SRTy = dyn_cast<DISubrangeType>(Ty))
631 constructSubrangeDIE(TyDIE, SRTy);
633 construct(cast<DIDerivedType>(Ty));
642 auto *Ty = cast<DIType>(TyNode);
654 auto *
Context = Ty->getScope();
675 if (
auto *CT = dyn_cast<DICompositeType>(Ty)) {
678 if (CT->getRuntimeLang() == 0 || CT->isObjcClassComplete())
685 if (
auto *CT = dyn_cast<DICompositeType>(Ty))
686 if (Ty->
getName() != CT->getIdentifier() &&
687 CT->getRuntimeLang() == dwarf::DW_LANG_Swift)
703 assert(Ty &&
"Trying to add a type that doesn't exist?");
717 while (!isa<DICompileUnit>(
Context)) {
731 if (
Name.empty() && isa<DINamespace>(Ctx))
732 Name =
"(anonymous namespace)";
749 if (BTy->
getTag() == dwarf::DW_TAG_unspecified_type)
752 if (BTy->
getTag() != dwarf::DW_TAG_string_type)
753 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
757 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
760 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_big);
762 addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_little);
765 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
766 NumExtraInhabitants);
774 addSInt(Buffer, dwarf::DW_AT_binary_scale, dwarf::DW_FORM_sdata,
777 addSInt(Buffer, dwarf::DW_AT_decimal_scale, dwarf::DW_FORM_sdata,
801 if (
auto *VarDIE =
getDIE(Var))
802 addDIEEntry(Buffer, dwarf::DW_AT_string_length, *VarDIE);
809 DwarfExpr.setMemoryLocationKind();
810 DwarfExpr.addExpression(Expr);
811 addBlock(Buffer, dwarf::DW_AT_string_length, DwarfExpr.finalize());
814 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
822 DwarfExpr.setMemoryLocationKind();
823 DwarfExpr.addExpression(Expr);
824 addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
829 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
841 const DIType *FromTy = DTy->getBaseType();
855 if (AlignInBytes > 0)
856 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
861 if (
Size &&
Tag != dwarf::DW_TAG_pointer_type
862 &&
Tag != dwarf::DW_TAG_ptr_to_member_type
863 &&
Tag != dwarf::DW_TAG_reference_type
864 &&
Tag != dwarf::DW_TAG_rvalue_reference_type)
865 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
867 if (
Tag == dwarf::DW_TAG_ptr_to_member_type)
880 if (DTy->getDWARFAddressSpace())
881 addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,
882 *DTy->getDWARFAddressSpace());
885 if (
Tag == dwarf::DW_TAG_template_alias)
888 if (
auto PtrAuthData = DTy->getPtrAuthData()) {
889 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_key, dwarf::DW_FORM_data1,
891 if (PtrAuthData->isAddressDiscriminated())
892 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_address_discriminated);
893 addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_extra_discriminator,
894 dwarf::DW_FORM_data2, PtrAuthData->extraDiscriminator());
895 if (PtrAuthData->isaPointer())
896 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_isa_pointer);
897 if (PtrAuthData->authenticatesNullValues())
898 addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_authenticates_null_values);
902std::optional<unsigned>
905 std::optional<unsigned> ObjectPointerIndex;
906 for (
unsigned i = 1,
N = Args.size(); i <
N; ++i) {
907 const DIType *Ty = Args[i];
909 assert(i ==
N-1 &&
"Unspecified parameter must be the last argument");
915 addFlag(Arg, dwarf::DW_AT_artificial);
918 assert(!ObjectPointerIndex &&
919 "Can't have more than one object pointer");
920 ObjectPointerIndex = i;
925 return ObjectPointerIndex;
930 auto Elements = cast<DISubroutineType>(CTy)->getTypeArray();
932 if (
auto RTy = Elements[0])
935 bool isPrototyped =
true;
936 if (Elements.size() == 2 && !Elements[1])
937 isPrototyped =
false;
944 addFlag(Buffer, dwarf::DW_AT_prototyped);
947 if (CTy->
getCC() && CTy->
getCC() != dwarf::DW_CC_normal)
948 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
952 addFlag(Buffer, dwarf::DW_AT_reference);
955 addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
963 const MDNode *MD = cast<MDNode>(Annotation);
968 addString(AnnotationDie, dwarf::DW_AT_name,
Name->getString());
969 if (
const auto *
Data = dyn_cast<MDString>(
Value))
970 addString(AnnotationDie, dwarf::DW_AT_const_value,
Data->getString());
971 else if (
const auto *
Data = dyn_cast<ConstantAsMetadata>(
Value))
975 assert(
false &&
"Unsupported annotation value type");
979void DwarfUnit::addDiscriminant(
DIE &Variant,
Constant *Discriminant,
981 if (
const auto *CI = dyn_cast_or_null<ConstantInt>(Discriminant)) {
982 addInt(Variant, dwarf::DW_AT_discr_value, CI->getValue(), IsUnsigned);
983 }
else if (
const auto *CA =
984 dyn_cast_or_null<ConstantDataArray>(Discriminant)) {
986 unsigned NElems = CA->getNumElements();
987 if (NElems % 2 != 0) {
993 auto AddInt = [&](
const APInt &Val) {
1000 for (
unsigned I = 0;
I < NElems;
I += 2) {
1001 APInt LV = CA->getElementAsAPInt(
I);
1002 APInt HV = CA->getElementAsAPInt(
I + 1);
1023 case dwarf::DW_TAG_array_type:
1024 constructArrayTypeDIE(Buffer, CTy);
1026 case dwarf::DW_TAG_enumeration_type:
1027 constructEnumTypeDIE(Buffer, CTy);
1029 case dwarf::DW_TAG_variant_part:
1030 case dwarf::DW_TAG_variant:
1031 case dwarf::DW_TAG_structure_type:
1032 case dwarf::DW_TAG_union_type:
1033 case dwarf::DW_TAG_class_type:
1034 case dwarf::DW_TAG_namelist: {
1037 if (
Tag == dwarf::DW_TAG_variant_part) {
1039 if (Discriminator) {
1051 if (DiscDIE ==
nullptr) {
1052 DiscDIE = &constructMemberDIE(Buffer, Discriminator);
1054 addDIEEntry(Buffer, dwarf::DW_AT_discr, *DiscDIE);
1059 if (
Tag == dwarf::DW_TAG_class_type ||
1060 Tag == dwarf::DW_TAG_structure_type ||
Tag == dwarf::DW_TAG_union_type)
1065 for (
const auto *Element : Elements) {
1068 if (
auto *SP = dyn_cast<DISubprogram>(Element))
1070 else if (
auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
1071 if (DDTy->getTag() == dwarf::DW_TAG_friend) {
1073 addType(ElemDie, DDTy->getBaseType(), dwarf::DW_AT_friend);
1074 }
else if (DDTy->isStaticMember()) {
1076 }
else if (
Tag == dwarf::DW_TAG_variant_part) {
1080 if (
Constant *CI = DDTy->getDiscriminantValue()) {
1081 addDiscriminant(Variant, CI,
1087 if (
auto *Composite =
1088 dyn_cast_or_null<DICompositeType>(DDTy->getBaseType());
1089 Composite !=
nullptr &&
1090 Composite->getTag() == dwarf::DW_TAG_variant) {
1093 constructMemberDIE(Variant, DDTy);
1096 constructMemberDIE(Buffer, DDTy);
1098 }
else if (
auto *Property = dyn_cast<DIObjCProperty>(Element)) {
1100 StringRef PropertyName = Property->getName();
1101 addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
1102 if (Property->getType())
1103 addType(ElemDie, Property->getType());
1105 StringRef GetterName = Property->getGetterName();
1106 if (!GetterName.
empty())
1107 addString(ElemDie, dwarf::DW_AT_APPLE_property_getter, GetterName);
1108 StringRef SetterName = Property->getSetterName();
1109 if (!SetterName.
empty())
1110 addString(ElemDie, dwarf::DW_AT_APPLE_property_setter, SetterName);
1111 if (
unsigned PropertyAttributes = Property->getAttributes())
1112 addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, std::nullopt,
1113 PropertyAttributes);
1114 }
else if (
auto *Composite = dyn_cast<DICompositeType>(Element)) {
1115 if (Composite->getTag() == dwarf::DW_TAG_variant_part) {
1119 }
else if (
Tag == dwarf::DW_TAG_namelist) {
1120 auto *Var = dyn_cast<DINode>(Element);
1121 auto *VarDIE =
getDIE(Var);
1124 addDIEEntry(ItemDie, dwarf::DW_AT_namelist_item, *VarDIE);
1130 addFlag(Buffer, dwarf::DW_AT_APPLE_block);
1133 addFlag(Buffer, dwarf::DW_AT_export_symbols);
1144 addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
1151 CC = dwarf::DW_CC_pass_by_value;
1153 CC = dwarf::DW_CC_pass_by_reference;
1155 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
1179 if (
Tag == dwarf::DW_TAG_enumeration_type ||
1180 Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
1181 Tag == dwarf::DW_TAG_union_type) {
1183 if (
auto *VarDIE =
getDIE(Var))
1184 addDIEEntry(Buffer, dwarf::DW_AT_bit_size, *VarDIE);
1185 }
else if (
auto *Exp =
1199 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
Size);
1202 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, 0);
1207 addFlag(Buffer, dwarf::DW_AT_declaration);
1219 addUInt(Buffer, dwarf::DW_AT_APPLE_runtime_class, dwarf::DW_FORM_data1,
1224 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1228 addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
1229 NumExtraInhabitants);
1233void DwarfUnit::constructTemplateTypeParameterDIE(
1242 if (TP->
isDefault() && isCompatibleWithVersion(5))
1243 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1246void DwarfUnit::constructTemplateValueParameterDIE(
1252 if (VP->
getTag() == dwarf::DW_TAG_template_value_parameter)
1256 if (VP->
isDefault() && isCompatibleWithVersion(5))
1257 addFlag(ParamDIE, dwarf::DW_AT_default_value);
1259 if (
ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Val))
1261 else if (
ConstantFP *CF = mdconst::dyn_extract<ConstantFP>(Val))
1263 else if (
GlobalValue *GV = mdconst::dyn_extract<GlobalValue>(Val)) {
1266 if (!GV->hasDLLImportStorageClass()) {
1273 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
1274 addBlock(ParamDIE, dwarf::DW_AT_location, Loc);
1276 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1277 assert(isa<MDString>(Val));
1278 addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
1279 cast<MDString>(Val)->getString());
1280 }
else if (VP->
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1299 Name =
"(anonymous namespace)";
1303 addFlag(NDie, dwarf::DW_AT_export_symbols);
1316 if (!M->getName().empty()) {
1317 addString(MDie, dwarf::DW_AT_name, M->getName());
1320 if (!M->getConfigurationMacros().empty())
1321 addString(MDie, dwarf::DW_AT_LLVM_config_macros,
1322 M->getConfigurationMacros());
1323 if (!M->getIncludePath().empty())
1324 addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
1325 if (!M->getAPINotesFile().empty())
1326 addString(MDie, dwarf::DW_AT_LLVM_apinotes, M->getAPINotesFile());
1328 addUInt(MDie, dwarf::DW_AT_decl_file, std::nullopt,
1331 addUInt(MDie, dwarf::DW_AT_decl_line, std::nullopt, M->getLineNo());
1333 addFlag(MDie, dwarf::DW_AT_declaration);
1348 if (
auto *SPDecl = SP->getDeclaration()) {
1369 if (SP->isDefinition())
1378 DIE &SPDie,
bool Minimal) {
1379 DIE *DeclDie =
nullptr;
1381 if (
auto *SPDecl = SP->getDeclaration()) {
1384 DeclArgs = SPDecl->getType()->getTypeArray();
1385 DefinitionArgs = SP->getType()->getTypeArray();
1387 if (DeclArgs.
size() && DefinitionArgs.
size())
1388 if (DefinitionArgs[0] !=
nullptr && DeclArgs[0] != DefinitionArgs[0])
1389 addType(SPDie, DefinitionArgs[0]);
1391 DeclDie =
getDIE(SPDecl);
1392 assert(DeclDie &&
"This DIE should've already been constructed when the "
1393 "definition DIE was created in "
1394 "getOrCreateSubprogramDIE");
1397 DeclLinkageName = SPDecl->getLinkageName();
1400 if (DeclID != DefID)
1401 addUInt(SPDie, dwarf::DW_AT_decl_file, std::nullopt, DefID);
1403 if (SP->getLine() != SPDecl->getLine())
1404 addUInt(SPDie, dwarf::DW_AT_decl_line, std::nullopt, SP->getLine());
1415 "decl has a linkage name and it is different");
1416 if (DeclLinkageName.
empty() &&
1426 addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
1431 bool SkipSPAttributes) {
1434 bool SkipSPSourceLocation = SkipSPAttributes &&
1436 if (!SkipSPSourceLocation)
1441 if (!SP->getName().empty())
1442 addString(SPDie, dwarf::DW_AT_name, SP->getName());
1446 if (!SkipSPSourceLocation)
1450 if (SkipSPAttributes)
1456 addFlag(SPDie, dwarf::DW_AT_prototyped);
1458 if (SP->isObjCDirect())
1459 addFlag(SPDie, dwarf::DW_AT_APPLE_objc_direct);
1464 Args = SPTy->getTypeArray();
1469 if (CC && CC != dwarf::DW_CC_normal)
1470 addUInt(SPDie, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1, CC);
1475 if (
auto Ty = Args[0])
1478 unsigned VK = SP->getVirtuality();
1480 addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
1481 if (SP->getVirtualIndex() != -1u) {
1483 addUInt(*
Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1484 addUInt(*
Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1490 if (!SP->isDefinition()) {
1491 addFlag(SPDie, dwarf::DW_AT_declaration);
1498 if (std::optional<unsigned> ObjectPointerIndex =
1504 assert(*ObjectPointerIndex > 0);
1505 addSInt(SPDie, dwarf::DW_AT_object_pointer,
1506 dwarf::DW_FORM_implicit_const, *ObjectPointerIndex - 1);
1513 if (SP->isArtificial())
1514 addFlag(SPDie, dwarf::DW_AT_artificial);
1516 if (!SP->isLocalToUnit())
1517 addFlag(SPDie, dwarf::DW_AT_external);
1520 if (SP->isOptimized())
1521 addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
1524 addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag,
isa);
1527 if (SP->isLValueReference())
1528 addFlag(SPDie, dwarf::DW_AT_reference);
1530 if (SP->isRValueReference())
1531 addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
1533 if (SP->isNoReturn())
1534 addFlag(SPDie, dwarf::DW_AT_noreturn);
1538 if (SP->isExplicit())
1539 addFlag(SPDie, dwarf::DW_AT_explicit);
1541 if (SP->isMainSubprogram())
1542 addFlag(SPDie, dwarf::DW_AT_main_subprogram);
1544 addFlag(SPDie, dwarf::DW_AT_pure);
1545 if (SP->isElemental())
1546 addFlag(SPDie, dwarf::DW_AT_elemental);
1547 if (SP->isRecursive())
1548 addFlag(SPDie, dwarf::DW_AT_recursive);
1550 if (!SP->getTargetFuncName().empty())
1551 addString(SPDie, dwarf::DW_AT_trampoline, SP->getTargetFuncName());
1554 addFlag(SPDie, dwarf::DW_AT_deleted);
1569 addUInt(DW_Subrange, dwarf::DW_AT_byte_size, std::nullopt,
Size >> 3);
1571 addUInt(DW_Subrange, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1575 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1578 addUInt(DW_Subrange, dwarf::DW_AT_endianity, std::nullopt,
1579 dwarf::DW_END_little);
1583 int64_t DefaultLowerBound = getDefaultLowerBound();
1587 if (
auto *BV = dyn_cast_if_present<DIVariable *>(Bound)) {
1588 if (
auto *VarDIE =
getDIE(BV))
1590 }
else if (
auto *BE = dyn_cast_if_present<DIExpression *>(Bound)) {
1593 DwarfExpr.setMemoryLocationKind();
1594 DwarfExpr.addExpression(BE);
1595 addBlock(DW_Subrange, Attr, DwarfExpr.finalize());
1596 }
else if (
auto *BI = dyn_cast_if_present<ConstantInt *>(Bound)) {
1597 if (Attr == dwarf::DW_AT_GNU_bias) {
1598 if (BI->getSExtValue() != 0)
1599 addUInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1600 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1601 BI->getSExtValue() != DefaultLowerBound || !ForArray)
1602 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1606 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1608 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1610 AddBoundTypeEntry(dwarf::DW_AT_bit_stride, SR->
getStride());
1612 AddBoundTypeEntry(dwarf::DW_AT_GNU_bias, SR->
getBias());
1615void DwarfUnit::constructSubrangeDIE(
DIE &Buffer,
const DISubrange *SR) {
1618 DIE *IdxTy = getIndexTyDie();
1619 addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IdxTy);
1625 int64_t DefaultLowerBound = getDefaultLowerBound();
1628 DISubrange::BoundType Bound) ->
void {
1629 if (
auto *BV = dyn_cast_if_present<DIVariable *>(Bound)) {
1630 if (
auto *VarDIE =
getDIE(BV))
1632 }
else if (
auto *BE = dyn_cast_if_present<DIExpression *>(Bound)) {
1635 DwarfExpr.setMemoryLocationKind();
1636 DwarfExpr.addExpression(BE);
1637 addBlock(DW_Subrange, Attr, DwarfExpr.finalize());
1638 }
else if (
auto *BI = dyn_cast_if_present<ConstantInt *>(Bound)) {
1639 if (Attr == dwarf::DW_AT_count) {
1640 if (BI->getSExtValue() != -1)
1641 addUInt(DW_Subrange, Attr, std::nullopt, BI->getSExtValue());
1642 }
else if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1643 BI->getSExtValue() != DefaultLowerBound)
1644 addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1648 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->
getLowerBound());
1650 AddBoundTypeEntry(dwarf::DW_AT_count, SR->
getCount());
1652 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->
getUpperBound());
1654 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, SR->
getStride());
1657void DwarfUnit::constructGenericSubrangeDIE(
DIE &Buffer,
1659 DIE &DwGenericSubrange =
1664 DIE *IdxTy = getIndexTyDie();
1665 addDIEEntry(DwGenericSubrange, dwarf::DW_AT_type, *IdxTy);
1667 int64_t DefaultLowerBound = getDefaultLowerBound();
1671 if (
auto *BV = dyn_cast_if_present<DIVariable *>(Bound)) {
1672 if (
auto *VarDIE =
getDIE(BV))
1674 }
else if (
auto *BE = dyn_cast_if_present<DIExpression *>(Bound)) {
1675 if (BE->isConstant() &&
1677 *BE->isConstant()) {
1678 if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1679 static_cast<int64_t
>(BE->getElement(1)) != DefaultLowerBound)
1680 addSInt(DwGenericSubrange, Attr, dwarf::DW_FORM_sdata,
1685 DwarfExpr.setMemoryLocationKind();
1686 DwarfExpr.addExpression(BE);
1687 addBlock(DwGenericSubrange, Attr, DwarfExpr.finalize());
1692 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, GSR->
getLowerBound());
1693 AddBoundTypeEntry(dwarf::DW_AT_count, GSR->
getCount());
1694 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, GSR->
getUpperBound());
1695 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, GSR->
getStride());
1698DIE *DwarfUnit::getIndexTyDie() {
1718 assert(CTy && CTy->
isVector() &&
"Composite type is not a vector");
1728 assert(Elements.size() == 1 &&
1729 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type &&
1730 "Invalid vector element array, expected one element of type subrange");
1731 const auto Subrange = cast<DISubrange>(Elements[0]);
1732 const auto NumVecElements =
1733 Subrange->getCount()
1734 ? cast<ConstantInt *>(Subrange->getCount())->getSExtValue()
1739 assert(ActualSize >= (NumVecElements * ElementSize) &&
"Invalid vector size");
1740 return ActualSize != (NumVecElements * ElementSize);
1745 addFlag(Buffer, dwarf::DW_AT_GNU_vector);
1747 addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
1752 if (
auto *VarDIE =
getDIE(Var))
1753 addDIEEntry(Buffer, dwarf::DW_AT_data_location, *VarDIE);
1757 DwarfExpr.setMemoryLocationKind();
1758 DwarfExpr.addExpression(Expr);
1759 addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
1763 if (
auto *VarDIE =
getDIE(Var))
1764 addDIEEntry(Buffer, dwarf::DW_AT_associated, *VarDIE);
1768 DwarfExpr.setMemoryLocationKind();
1769 DwarfExpr.addExpression(Expr);
1770 addBlock(Buffer, dwarf::DW_AT_associated, DwarfExpr.finalize());
1774 if (
auto *VarDIE =
getDIE(Var))
1775 addDIEEntry(Buffer, dwarf::DW_AT_allocated, *VarDIE);
1779 DwarfExpr.setMemoryLocationKind();
1780 DwarfExpr.addExpression(Expr);
1781 addBlock(Buffer, dwarf::DW_AT_allocated, DwarfExpr.finalize());
1785 addSInt(Buffer, dwarf::DW_AT_rank, dwarf::DW_FORM_sdata,
1786 RankConst->getSExtValue());
1787 }
else if (
auto *RankExpr = CTy->
getRankExp()) {
1790 DwarfExpr.setMemoryLocationKind();
1791 DwarfExpr.addExpression(RankExpr);
1792 addBlock(Buffer, dwarf::DW_AT_rank, DwarfExpr.finalize());
1796 addUInt(Buffer, dwarf::DW_AT_bit_stride, {}, BitStride->getZExtValue());
1804 for (
DINode *E : Elements) {
1805 if (
auto *Element = dyn_cast_or_null<DISubrangeType>(E)) {
1807 constructSubrangeDIE(TyDIE, Element,
true);
1808 }
else if (
auto *Element = dyn_cast_or_null<DISubrange>(E))
1809 constructSubrangeDIE(Buffer, Element);
1810 else if (
auto *Element = dyn_cast_or_null<DIGenericSubrange>(E))
1811 constructGenericSubrangeDIE(Buffer, Element);
1822 addFlag(Buffer, dwarf::DW_AT_enum_class);
1826 addUInt(Buffer, dwarf::DW_AT_APPLE_enum_kind, dwarf::DW_FORM_data1, *Kind);
1829 bool IndexEnumerators = !
Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) ||
1830 isa<DINamespace>(Context) || isa<DICommonBlock>(Context);
1834 for (
const DINode *E : Elements) {
1835 auto *
Enum = dyn_cast_or_null<DIEnumerator>(E);
1841 if (IndexEnumerators)
1849 DIE &SPDie = *
P.first;
1856 addDIEEntry(SPDie, dwarf::DW_AT_containing_type, *NDie);
1868 if (
DIType *Resolved = DT->getBaseType())
1873 if (DT->getTag() == dwarf::DW_TAG_inheritance && DT->isVirtual()) {
1880 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
1881 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1882 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1883 addUInt(*VBaseLocationDie, dwarf::DW_FORM_udata, DT->getOffsetInBits());
1884 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_minus);
1885 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1886 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
1888 addBlock(MemberDie, dwarf::DW_AT_data_member_location, VBaseLocationDie);
1893 bool IsBitfield = DT->isBitField();
1896 if (
auto *Var = dyn_cast_or_null<DIVariable>(DT->getRawSizeInBits())) {
1897 if (
auto *VarDIE =
getDIE(Var))
1898 addDIEEntry(MemberDie, dwarf::DW_AT_bit_size, *VarDIE);
1899 }
else if (
auto *Exp =
1900 dyn_cast_or_null<DIExpression>(DT->getRawSizeInBits())) {
1903 DwarfExpr.setMemoryLocationKind();
1904 DwarfExpr.addExpression(Exp);
1905 addBlock(MemberDie, dwarf::DW_AT_bit_size, DwarfExpr.finalize());
1907 Size = DT->getSizeInBits();
1912 addUInt(MemberDie, dwarf::DW_AT_byte_size, std::nullopt,
1914 addUInt(MemberDie, dwarf::DW_AT_bit_size, std::nullopt,
Size);
1921 if (
auto *Var = dyn_cast_or_null<DIVariable>(DT->getRawOffsetInBits())) {
1923 if (
auto *VarDIE =
getDIE(Var))
1924 addDIEEntry(MemberDie, dwarf::DW_AT_data_bit_offset, *VarDIE);
1926 }
else if (
auto *Expr =
1927 dyn_cast_or_null<DIExpression>(DT->getRawOffsetInBits())) {
1931 DwarfExpr.setMemoryLocationKind();
1932 DwarfExpr.addExpression(Expr);
1933 addBlock(MemberDie, dwarf::DW_AT_data_bit_offset, DwarfExpr.finalize());
1936 uint32_t AlignInBytes = DT->getAlignInBytes();
1940 assert(DT->getOffsetInBits() <=
1941 (
uint64_t)std::numeric_limits<int64_t>::max());
1942 int64_t
Offset = DT->getOffsetInBits();
1947 uint32_t AlignMask = ~(AlignInBits - 1);
1953 OffsetInBytes = (
Offset - StartBitOffset) / 8;
1957 uint64_t FieldOffset = (HiMark - FieldSize);
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,
1977 OffsetInBytes = DT->getOffsetInBits() / 8;
1979 addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
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);
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,
2006 if (DT->isVirtual())
2007 addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1,
2008 dwarf::DW_VIRTUALITY_virtual);
2011 if (
DINode *PNode = DT->getObjCProperty())
2014 dwarf::DW_FORM_ref4,
DIEEntry(*PDie));
2016 if (DT->isArtificial())
2017 addFlag(MemberDie, dwarf::DW_AT_artificial);
2030 "Static member should belong to a type.");
2033 return StaticMemberDIE;
2038 const DIType *Ty = DT->getBaseType();
2040 addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName());
2043 addFlag(StaticMemberDIE, dwarf::DW_AT_external);
2044 addFlag(StaticMemberDIE, dwarf::DW_AT_declaration);
2047 if (DT->isArtificial())
2048 addFlag(StaticMemberDIE, dwarf::DW_AT_artificial);
2052 addAccess(StaticMemberDIE, DT->getFlags());
2054 if (
const ConstantInt *CI = dyn_cast_or_null<ConstantInt>(DT->getConstant()))
2056 if (
const ConstantFP *CFP = dyn_cast_or_null<ConstantFP>(DT->getConstant()))
2059 if (
uint32_t AlignInBytes = DT->getAlignInBytes())
2060 addUInt(StaticMemberDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
2063 return &StaticMemberDIE;
2070 isDwoUnit() ?
"debug_info_dwo" :
"debug_info",
"Length of Unit");
2111 : dwarf::DW_UT_type);
2113 Asm->
OutStreamer->emitIntValue(TypeSignature,
sizeof(TypeSignature));
2133bool DwarfTypeUnit::isDwoUnit()
const {
2149const MCSymbol *DwarfUnit::getCrossSectionRelativeBaseAddress()
const {
2166 "DW_AT_rnglists_base requires DWARF version 5 or later");
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< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static bool hasVectorBeenPadded(const DICompositeType *CTy)
Returns true if the vector's size differs from the sum of sizes of elements the user specified.
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.
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
void resetUsedFlag(bool HasBeenUsed=false)
Annotations lets you mark points and ranges inside source code, for tests:
This class is intended to be used as a driving class for all asm writers.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
MCSymbol * getSymbol(const GlobalValue *GV) const
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
void emitDwarfLengthOrOffset(uint64_t Value) const
Emit 32- or 64-bit value depending on the DWARF format.
TargetMachine & TM
Target machine description.
const MCAsmInfo * MAI
Target Asm Printer information.
MachineFunction * MF
The current machine function.
void emitInt8(int Value) const
Emit a byte directive and value.
void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const
Emit a unit length field.
MCContext & OutContext
This is the context for the output file that we are streaming.
MCSymbol * createTempSymbol(const Twine &Name) const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
void emitInt16(int Value) const
Emit a short directive and value.
const DataLayout & getDataLayout() const
Return information about data layout.
dwarf::FormParams getDwarfFormParams() const
Returns information about the byte size of DW_FORM values.
bool doesDwarfUseRelocationsAcrossSections() const
ConstantFP - Floating Point Values [float, double].
const APFloat & getValueAPF() const
This is the shared class of boolean and integer constants.
const APInt & getValue() const
Return the constant as an APInt value reference.
This is an important base class in LLVM.
Basic type, like 'int' or 'float'.
unsigned getEncoding() const
bool getDebugInfoForProfiling() const
bool isDebugDirectivesOnly() const
static LLVM_ABI std::optional< DebugNameTableKind > getNameTableKind(StringRef Str)
DIExpression * getRankExp() const
DIExpression * getAssociatedExp() const
DIVariable * getAllocated() const
DIExpression * getDataLocationExp() const
DIVariable * getAssociated() const
DIDerivedType * getDiscriminator() const
DIVariable * getDataLocation() const
unsigned getRuntimeLang() const
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.
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.
LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
A container for string pool string values.
Represents a compile or type unit.
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
void takeValues(DIEValueList &Other)
Take ownership of the nodes in Other, and append them to the back of the list.
A structured debug information entry.
DIE & addChild(DIE *Child)
Add a child to the DIE.
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
LLVM_ABI DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to.
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
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
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.
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
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
MDString * getRawName() const
bool isAppleBlockExtension() const
bool isObjectPointer() 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
Base class for variables.
This class represents an Operation in the Expression.
bool isLittleEndian() const
Layout endianness...
static bool isUnsignedDIType(const DIType *Ty)
Return true if type encoding is unsigned.
static uint64_t getBaseTypeSize(const DIType *Ty)
If this type is derived from a base type then return base type size.
void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context)
Add a new global name present in a type unit to this compile unit.
unsigned getOrCreateSourceID(const DIFile *File) override
Look up the source ID for the given file.
void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context)
Add a new global type present in a type unit to this compile unit.
Collects and handles dwarf debug information.
std::optional< MD5::MD5Result > getMD5AsBytes(const DIFile *File) const
If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
bool useAddrOffsetForm() const
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
void addAccelNamespace(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
bool useAppleExtensionAttributes() const
bool useInlineStrings() const
Returns whether to use inline strings.
bool generateTypeUnits() const
Returns whether to generate DWARF v4 type units.
AddressPool & getAddressPool()
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
bool shareAcrossDWOCUs() const
const MCSymbol * getSectionLabel(const MCSection *S)
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support.
bool useDWARF2Bitfields() const
Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format.
bool useAddrOffsetExpressions() const
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &Die, const DICompositeType *CTy)
Add a DIE to the set of types that we're going to pull into type units.
void addAccelType(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die, char Flags)
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
void setMemoryLocationKind()
Lock this down to become a memory location description.
void addExpression(DIExpressionCursor &&Expr)
Emit all remaining operations in the DIExpressionCursor.
MCSymbol * getStringOffsetsStartSym() const
MCSymbol * getRnglistsTableBaseSym() const
DwarfStringPool & getStringPool()
Returns the string pool.
DenseMap< const DILocalScope *, DIE * > & getAbstractScopeDIEs()
void insertDIE(const MDNode *TypeMD, DIE *Die)
DIE * getDIE(const MDNode *TypeMD)
LLVM_ABI_FOR_TEST EntryRef getEntry(AsmPrinter &Asm, StringRef Str)
Get a reference to an entry in the string pool.
LLVM_ABI_FOR_TEST EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str)
Same as getEntry, except that you can use EntryRef::getIndex to obtain a unique ID of this entry (e....
DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID, MCDwarfDwoLineTable *SplitLineTable=nullptr)
void 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.
This dwarf writer support class manages information associated with a source file.
virtual DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
void 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.
uint16_t getLanguage() const
void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc)
Add block data.
void addTemplateParams(DIE &Buffer, DINodeArray TParams)
Add template parameters in buffer.
virtual DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
bool useSegmentedStringOffsetsTable() const
bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal)
DIELoc * getDIELoc()
Returns a fresh newly allocated DIELoc.
void 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.
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 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)
DIE & createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N=nullptr)
Create a DIE with the given Tag, add the DIE to its parent, and call insertDIE if MD is not null.
void addSectionOffset(DIE &Die, dwarf::Attribute Attribute, uint64_t Integer)
Add an offset into a section attribute data and value.
DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)
Create new static data member DIE.
void addLabel(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
Add a Dwarf label attribute data and value.
void addConstantFPValue(DIE &Die, const ConstantFP *CFP)
Add constant value entry in variable DIE.
void constructContainingTypeDIEs()
Construct DIEs for types that contain vtables.
DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal=false)
void addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
Add a Dwarf section label attribute data and value.
bool isShareableAcrossCUs(const DINode *D) const
Check whether the DIE for this MDNode can be shared across CUs.
void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label)
DenseMap< const MDNode *, DIE * > MDNodeToDieMap
Tracks the mapping of unit level debug information variables to debug information entries.
void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy)
virtual void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context)=0
Add a new global name to the compile unit.
MCSymbol * EndLabel
Emitted at the end of the CU and used to compute the CU Length field.
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
AsmPrinter * Asm
Target of Dwarf emission.
void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)
Add a new type attribute to the specified entity.
void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool SkipSPAttributes=false)
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)
Add a DIE attribute data and value.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
uint16_t getDwarfVersion() const
unsigned getFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, uint16_t DwarfVersion, std::optional< StringRef > Source)
MCSection * getDwarfStrOffSection() const
MCSection * getDwarfRnglistsSection() const
MCSection * getDwarfAbbrevSection() const
MCSymbol * getBeginSymbol()
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MDOperand & getOperand(unsigned I) const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Wrapper class representing virtual and physical registers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
unsigned DebugStrictDwarf
When set to true, don't use DWARF extensions in later DWARF versions.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVM Value Representation.
UnitType
Constants for unit types in DWARF v5.
bool isCPlusPlus(SourceLanguage S)
TypeKind getArrayIndexTypeEncoding(SourceLanguage S)
@ DW_FLAG_type_implementation
bool isC(SourceLanguage S)
This is an optimization pass for GlobalISel generic memory operations.
auto reverse(ContainerTy &&C)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Description of the encoding of one expression Op.