36#define DEBUG_TYPE "IRReader"
43using LVScopeEntry = std::pair<const DILocalScope *, const DILocation *>;
44using LVInlinedScopes =
45 std::unordered_map<LVScopeEntry,
LVScope *,
47LVInlinedScopes InlinedScopes;
51 auto Entry = LVScopeEntry(OriginContext, InlinedAt);
52 InlinedScopes.try_emplace(Entry, InlinedScope);
56 auto Entry = LVScopeEntry(OriginContext, InlinedAt);
57 LVInlinedScopes::const_iterator Iter = InlinedScopes.find(Entry);
58 return Iter != InlinedScopes.end() ? Iter->second :
nullptr;
64using LVInlinedToOrigin = std::unordered_map<LVScope *, LVScope *>;
65LVInlinedToOrigin InlinedToOrigin;
70using LVInlinedList = std::unordered_map<LVScope *, LVList>;
71LVInlinedList InlinedList;
75 InlinedToOrigin.try_emplace(
Inlined, Origin);
78 auto [It,
_] = InlinedList.try_emplace(Origin, LVList{});
79 LVList &List = It->second;
83LVList &getInlinedList(
LVScope *Origin) {
84 static LVList EmptyList;
85 auto It = InlinedList.find(Origin);
86 return (It == InlinedList.end()) ? EmptyList : It->second;
89#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
90void dumpInlinedInfo(
const char *
Text,
bool Full =
false) {
92 constexpr unsigned LEN = 17;
98 << std::setw(LEN) << std::left <<
formattedKind(Scope->kind());
107 dbgs() <<
"\nOrigin -> Inlined list: " <<
Text <<
"\n\n";
108 for (
auto &Entry : InlinedList) {
109 LVScope *OriginScope = Entry.first;
110 LVList &List = Entry.second;
111 PrintEntry(
"", OriginScope);
114 for (
auto &Scope : List) {
116 PrintEntry(
" ", Scope);
121 dbgs() <<
"\nOrigin -> Inlined: " <<
Text <<
"\n\n";
122 for (
auto &Entry : InlinedToOrigin) {
123 LVScope *InlinedScope = Entry.first;
124 LVScope *OriginScope = Entry.second;
125 PrintEntry(
"", InlinedScope);
127 PrintEntry(
"", OriginScope);
133 for (
auto &Entry : InlinedToOrigin) {
134 LVScope *InlinedScope = Entry.first;
135 LVScope *OriginScope = Entry.second;
137 PrintExtra(
"Origin: ", OriginScope);
139 PrintExtra(
"Inlined: ", InlinedScope);
169 if (StringRef
Name = getMDName(DN); !
Name.empty())
173 if (
const DIFile *File = getMDFile(DN))
174 getOrCreateSourceID(File);
180 assert(SL &&
"Invalid language ID.");
181 StringRef LanguageName = SL->
getName();
184 DefaultLowerBound = LanguageName.
contains(
"fortran") ? 1 : 0;
186 LLVM_DEBUG({
dbgs() <<
"Language Name: " << LanguageName <<
"\n"; });
189bool LVIRReader::includeMinimalInlineScopes()
const {
193size_t LVIRReader::getOrCreateSourceID(
const DIFile *File) {
198 dbgs() <<
"\n[getOrCreateSourceID]\n";
200 File->dump(TheModule);
205 dbgs() <<
"Directory: '" <<
File->getDirectory() <<
"'\n";
206 dbgs() <<
"Filename: '" <<
File->getFilename() <<
"'\n";
210 auto [Iter,
Inserted] = CompileUnitFiles.try_emplace(File, ++FileIndex);
212 std::string Directory(
File->getDirectory());
213 if (Directory.empty())
214 Directory = std::string(
CompileUnit->getCompilationDirectory());
216 std::string FullName;
217 raw_string_ostream Out(FullName);
222 FileIndex = Iter->second;
229void LVIRReader::addSourceLine(
LVElement *Element,
unsigned Line,
230 const DIFile *File) {
240 size_t FileID = getOrCreateSourceID(File);
241 if (Element->getIsLine())
248 dbgs() <<
"\n[addSourceLine]\n";
249 File->dump(TheModule);
251 dbgs() <<
"ID: " << Element->
getID() <<
", ";
252 dbgs() <<
"Kind: " << Element->
kind() <<
", ";
258void LVIRReader::addSourceLine(
LVElement *Element,
const DIGlobalVariable *
G) {
260 addSourceLine(Element,
G->getLine(),
G->getFile());
263void LVIRReader::addSourceLine(
LVElement *Element,
const DIImportedEntity *IE) {
265 addSourceLine(Element,
IE->getLine(),
IE->getFile());
268void LVIRReader::addSourceLine(
LVElement *Element,
const DILabel *L) {
270 addSourceLine(Element,
L->getLine(),
L->getFile());
273void LVIRReader::addSourceLine(
LVElement *Element,
const DILocalVariable *V) {
275 addSourceLine(Element,
V->getLine(),
V->getFile());
278void LVIRReader::addSourceLine(
LVElement *Element,
const DILocation *
DL) {
280 addSourceLine(Element,
DL->getLine(),
DL->getFile());
283void LVIRReader::addSourceLine(
LVElement *Element,
const DIObjCProperty *
OP) {
285 addSourceLine(Element,
OP->getLine(),
OP->getFile());
288void LVIRReader::addSourceLine(
LVElement *Element,
const DISubprogram *SP) {
290 addSourceLine(Element,
SP->getLine(),
SP->getFile());
293void LVIRReader::addSourceLine(
LVElement *Element,
const DIType *Ty) {
298void LVIRReader::addConstantValue(
LVElement *Element,
299 const DIExpression *DIExpr) {
300 std::optional<DIExpression::SignedOrUnsignedConstant>
Constant =
302 if (Constant == std::nullopt)
304 std::stringstream Stream;
307 if (int64_t SignedValue =
static_cast<int64_t
>(
Value); SignedValue < 0) {
309 Value =
static_cast<uint64_t
>(-SignedValue);
316void LVIRReader::addConstantValue(
LVElement *Element,
const ConstantFP *CFP) {
320void LVIRReader::addConstantValue(
LVElement *Element,
const ConstantInt *CI,
322 addConstantValue(Element, CI->
getValue(), Ty);
325void LVIRReader::addConstantValue(
LVElement *Element, uint64_t Val,
330void LVIRReader::addConstantValue(
LVElement *Element, uint64_t Val,
335void LVIRReader::addConstantValue(
LVElement *Element,
const APInt &Val,
340void LVIRReader::addConstantValue(
LVElement *Element,
const APInt &
Value,
342 SmallString<128> StringValue;
349void LVIRReader::processLocationGaps() {
350 if (
options().getAttributeAnyLocation())
351 for (LVSymbol *Symbol : SymbolsWithLocations)
352 Symbol->fillLocationGaps();
355void LVIRReader::processScopes() {
364 auto SetOffset = [&](LVElement *Element) {
366 Offset += OFFSET_INCREASE;
369 std::function<void(LVScope *)> TraverseScope = [&](LVScope *Current) {
372 constructRange(Current);
374 if (
const LVScopes *Scopes = Current->getScopes())
375 for (LVScope *Scope : *Scopes)
376 TraverseScope(Scope);
379 if (
const LVSymbols *Symbols = Current->getSymbols())
380 for (LVSymbol *Symbol : *Symbols)
382 if (
const LVTypes *Types = Current->getTypes())
383 for (LVType *
Type : *Types)
387 if (
const LVLines *Lines = Current->getLines())
388 for (LVLine *
Line : *Lines)
405 if (Opcode == dwarf::DW_OP_regval_type)
408 if (Opcode == dwarf::DW_OP_regx || Opcode == dwarf::DW_OP_bregx) {
417 return " " + ValueNameMap.getName(Operands[0]);
428 dbgs() <<
"\n[getParentScopeImpl]\n";
429 dbgs() <<
"Context: ";
430 Context->dump(TheModule);
434 if (
LVScope *Parent = getScopeForSeenMD(Context))
438 return traverseParentScope(Context);
443 assert(
DL &&
"Invalid metadata node.");
445 dbgs() <<
"\n[getParentScope]\n";
454LVScope *LVIRReader::getParentScope(
const DINode *DN) {
455 assert(DN &&
"Invalid metadata node.");
457 dbgs() <<
"\n[getParentScope]\n";
462 return getParentScopeImpl(getMDScope(DN));
470 dbgs() <<
"\n[traverseParentScope]\n";
471 dbgs() <<
"Context: \n";
476 if (LVScope *Parent = getScopeForSeenMD(
Context))
480 LVElement *Element = constructElement(
Context);
482 const DIScope *ParentContext =
nullptr;
485 if (DICompileUnit *CU =
SP->getUnit())
486 ParentContext = getMDScope(
SP->getDeclaration() ? CU :
Context);
488 ParentContext = getMDScope(
Context);
490 LVScope *Parent = traverseParentScope(ParentContext);
493 constructScope(Element,
Context);
497 return static_cast<LVScope *
>(Element);
504LVType *LVIRReader::getIndexType() {
507 return NodeIndexType;
510 NodeIndexType =
static_cast<LVType *
>(
createElement(dwarf::DW_TAG_base_type));
512 NodeIndexType->setIsFinalized();
513 NodeIndexType->setName(
"__ARRAY_SIZE_TYPE__");
517 return NodeIndexType;
521 assert(Element &&
"Invalid logical element.");
523 dbgs() <<
"\n[addAccess]\n";
528 switch (Accessibility) {
529 case DINode::FlagProtected:
532 case DINode::FlagPrivate:
535 case DINode::FlagPublic:
538 case DINode::FlagZero:
541 if (Parent->getIsClass()) {
545 if (Parent->getIsStructure() || Parent->getIsUnion()) {
561const DIFile *LVIRReader::getMDFile(
const MDNode *MD)
const {
562 assert(MD &&
"Invalid metadata node.");
564 dbgs() <<
"\n[getMDFile]\n";
610StringRef LVIRReader::getMDName(
const DINode *DN)
const {
611 assert(DN &&
"Invalid metadata node.");
613 dbgs() <<
"\n[getMDName]\n";
652 "Unhandled DINode.");
656const DIScope *LVIRReader::getMDScope(
const DINode *DN)
const {
657 assert(DN &&
"Invalid metadata node.");
659 dbgs() <<
"\n[getMDScope]\n";
669 const DIScope *
Context =
T->getScope();
676 return T->getScope();
679 return T->getScope();
682 return T->getScope();
693void LVIRReader::addTemplateParams(
LVElement *Element,
694 const DINodeArray TParams) {
695 assert(Element &&
"Invalid logical element");
698 dbgs() <<
"\n[addTemplateParams]\n";
699 for (
const auto *Entry : TParams) {
701 Entry->dump(TheModule);
706 for (
const auto *Entry : TParams) {
708 constructTemplateTypeParameter(Element, TTP);
710 constructTemplateValueParameter(Element, TVP);
716 const DISubprogram *SP,
717 bool SkipSPAttributes) {
719 assert(SP &&
"Invalid metadata node.");
721 dbgs() <<
"\n[applySubprogramAttributes]\n";
728 bool SkipSPSourceLocation =
729 SkipSPAttributes && !getCUNode()->getDebugInfoForProfiling();
730 if (!SkipSPSourceLocation)
731 if (applySubprogramDefinitionAttributes(
Function, SP, SkipSPAttributes))
734 if (!SkipSPSourceLocation)
738 if (SkipSPAttributes)
742 if (
const DISubroutineType *SPTy =
SP->getType())
743 Args = SPTy->getTypeArray();
752 Function->setVirtualityCode(
SP->getVirtuality());
754 if (!
SP->isDefinition()) {
757 constructSubprogramArguments(
Function, Args);
760 if (
SP->isArtificial())
763 if (!
SP->isLocalToUnit())
772 const DISubprogram *SP,
775 assert(SP &&
"Invalid metadata node.");
777 dbgs() <<
"\n[applySubprogramDefinitionAttributes]\n";
783 StringRef DeclLinkageName;
784 if (
const DISubprogram *SPDecl =
SP->getDeclaration()) {
786 DITypeArray DeclArgs, DefinitionArgs;
787 DeclArgs = SPDecl->getType()->getTypeArray();
788 DefinitionArgs =
SP->getType()->getTypeArray();
813 if (DeclArgs.size() && DefinitionArgs.size())
814 if (DefinitionArgs[0] !=
nullptr && DeclArgs[0] != DefinitionArgs[0]) {
815 LVElement *
ElementType = getOrCreateType(DefinitionArgs[0]);
822 if (useAllLinkageNames())
823 DeclLinkageName = SPDecl->getLinkageName();
824 unsigned DeclID = getOrCreateSourceID(SPDecl->getFile());
825 unsigned DefID = getOrCreateSourceID(
SP->getFile());
829 if (
SP->getLine() != SPDecl->getLine())
835 addTemplateParams(
Function,
SP->getTemplateParams());
840 if (DeclLinkageName !=
LinkageName && (useAllLinkageNames()))
849 Function->setHasReferenceSpecification();
856 const DICompositeType *CTy) {
857 assert(Aggregate &&
"Invalid logical element");
858 assert(CTy &&
"Invalid metadata node.");
860 dbgs() <<
"\n[constructAggregate]\n";
862 CTy->
dump(TheModule);
865 if (Aggregate->getIsFinalized())
867 Aggregate->setIsFinalized();
872 if (
Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
873 Tag == dwarf::DW_TAG_union_type)
881 dbgs() <<
"\nMember: ";
885 getOrCreateSubprogram(SP);
888 if (
Tag == dwarf::DW_TAG_member ||
Tag == dwarf::DW_TAG_variable) {
889 if (DT->isStaticMember())
890 getOrCreateStaticMember(Aggregate, DT);
892 getOrCreateMember(Aggregate, DT);
894 getOrCreateType(Aggregate, DT);
902 const DICompositeType *CTy) {
903 assert(Array &&
"Invalid logical element");
904 assert(CTy &&
"Invalid metadata node.");
906 dbgs() <<
"\n[constructArray]\n";
908 CTy->
dump(TheModule);
911 if (
Array->getIsFinalized())
913 Array->setIsFinalized();
919 LVType *IndexType = getIndexType();
923 for (DINode *DN : Entries) {
925 if (SR->getTag() == dwarf::DW_TAG_subrange_type)
927 else if (SR->getTag() == dwarf::DW_TAG_generic_subrange)
935 const DICompositeType *CTy) {
936 assert(Enumeration &&
"Invalid logical element");
937 assert(CTy &&
"Invalid metadata node.");
939 dbgs() <<
"\n[constructEnum]\n";
941 CTy->
dump(TheModule);
944 if (Enumeration->getIsFinalized())
946 Enumeration->setIsFinalized();
951 if (LVElement *
BaseType = getOrCreateType(Ty))
954 if (CTy->
getFlags() & DINode::FlagEnumClass)
955 Enumeration->setIsEnumClass();
959 for (
const DINode *DN : Entries) {
961 if (LVElement *
Enumerator = constructElement(Enum)) {
970void LVIRReader::constructGenericSubrange(
LVScopeArray *Array,
971 const DIGenericSubrange *GSR,
973 assert(Array &&
"Invalid logical element");
974 assert(GSR &&
"Invalid metadata node.");
976 dbgs() <<
"\n[constructGenericSubrange]\n";
978 GSR->
dump(TheModule);
985void LVIRReader::constructImportedEntity(
LVElement *Element,
986 const DIImportedEntity *IE) {
987 assert(Element &&
"Invalid logical element");
988 assert(IE &&
"Invalid metadata node.");
990 dbgs() <<
"\n[constructImportedEntity]\n";
995 if (LVElement *
Import = constructElement(IE)) {
997 addSourceLine(
Import, IE);
998 LVScope *Parent = getParentScope(IE);
1001 const DINode *Entity =
IE->getEntity();
1002 LVElement *
Target = getElementForSeenMD(Entity);
1005 Target = getOrCreateType(Ty);
1007 Target = getOrCreateSubprogram(SP);
1009 Target = getOrCreateNamespace(NS);
1011 Target = getOrCreateScope(M);
1018LVScope *LVIRReader::getOrCreateInlinedScope(
const DILocation *
DL) {
1019 assert(
DL &&
"Invalid metadata node.");
1021 dbgs() <<
"\n[getOrCreateInlinedScope]\n";
1026 const DILocalScope *OriginContext =
DL->getScope();
1028 dbgs() <<
"OriginContext: ";
1029 OriginContext->dump(TheModule);
1032 auto CreateScope = [&](
const DILocalScope *
Context) -> LVScope * {
1033 LVScope *
Scope =
nullptr;
1035 Scope = getOrCreateSubprogram(SP);
1039 dbgs() <<
"Scope: ";
1040 Scope->dumpCommon();
1046 const DILocation *InlinedAt =
DL->getInlinedAt();
1048 return CreateScope(OriginContext);
1051 dbgs() <<
"InlinedAt: ";
1052 InlinedAt->
dump(TheModule);
1056 if (LVScope *InlinedScope = getInlinedScope(OriginContext, InlinedAt))
1057 return InlinedScope;
1061 LVScope *OriginScope = CreateScope(OriginContext);
1064 if (OriginScope->getIsFunction() || OriginScope->getIsInlinedFunction()) {
1065 Tag = dwarf::DW_TAG_inlined_subroutine;
1070 addInlinedScope(OriginContext, InlinedAt, InlinedScope);
1072 InlinedScope->setIsFinalized();
1078 getOrCreateSourceID(InlinedAt->getFile()));
1081 InlinedScope->setHasReferenceAbstract();
1086 dbgs() <<
"Linking\n";
1090 addInlinedInfo(OriginScope, InlinedScope);
1093 DILocalScope *AbstractContext = InlinedAt->getScope();
1094 dbgs() <<
"AbstractContext: ";
1095 AbstractContext->
dump(TheModule);
1098 LVScope *AbstractScope = getOrCreateInlinedScope(InlinedAt);
1099 assert(AbstractScope &&
"Logical scope is NULL.");
1101 dbgs() <<
"AbstractScope: ";
1102 AbstractScope->dumpCommon();
1106 AbstractScope->addElement(InlinedScope);
1109 dbgs() <<
"InlinedScope: ";
1114 return InlinedScope;
1117LVScope *LVIRReader::getOrCreateAbstractScope(
const DILocation *
DL) {
1118 assert(
DL &&
"Invalid metadata node.");
1120 dbgs() <<
"\n[getOrCreateAbstractScope]\n";
1126 LVScope *InlinedScope = getOrCreateInlinedScope(
DL);
1127 assert(InlinedScope &&
"InlinedScope is null.");
1128 return InlinedScope;
1131void LVIRReader::constructLine(
LVScope *Scope,
const DISubprogram *SP,
1133 bool &GenerateLineBeforePrologue) {
1134 assert(Scope &&
"Invalid logical element");
1135 assert(SP &&
"Invalid metadata node.");
1137 dbgs() <<
"\n[constructLine]\n";
1138 dbgs() <<
"Instruction: ";
1140 dbgs() <<
"Logical Scope: ";
1141 Scope->dumpCommon();
1144 auto AddDebugLine = [&](LVScope *Parent,
unsigned ID) -> LVLine * {
1145 assert(Parent &&
"Invalid logical element");
1146 assert(
ID == Metadata::DILocationKind &&
"Invalid Metadata Object");
1148 dbgs() <<
"\n[AddDebugLine]\n";
1149 dbgs() <<
"Parent: ";
1153 LVLine *
Line = createLineDebug();
1157 Line->setIsFinalized();
1173 Parent->getHasReferenceSpecification()) {
1176 GenerateLineBeforePrologue =
false;
1182 auto AddAssemblerLine = [&](LVScope *Parent) {
1183 assert(Parent &&
"Invalid logical element");
1185 static const char *WhiteSpace =
" \t\n\r\f\v";
1186 static std::string
Metadata(
"metadata ");
1188 auto RemoveAll = [](std::string &Input, std::string &Pattern) {
1189 std::string::size_type
Len = Pattern.length();
1190 for (std::string::size_type Index = Input.find(Pattern);
1191 Index != std::string::npos; Index = Input.find(Pattern))
1192 Input.erase(Index, Len);
1195 std::string InstructionText;
1196 raw_string_ostream Stream(InstructionText);
1199 RemoveAll(InstructionText,
Metadata);
1200 std::string_view
Text(InstructionText);
1201 const auto pos(
Text.find_first_not_of(WhiteSpace));
1202 Text.remove_prefix(std::min(pos,
Text.length()));
1205 if (LVLineAssembler *
Line = createLineAssembler()) {
1206 Line->setIsFinalized();
1213 LVScope *Parent =
Scope;
1214 if (
const DebugLoc DbgLoc =
I.getDebugLoc()) {
1215 const DILocation *
DL = DbgLoc.get();
1221 Parent = getOrCreateAbstractScope(
DL);
1222 assert(Parent &&
"Invalid logical element");
1224 dbgs() <<
"Parent: ";
1225 Parent->dumpCommon();
1228 if (
options().getPrintLines() &&
DL->getLine()) {
1229 if (LVLine *
Line = AddDebugLine(Parent,
DL->getMetadataID())) {
1232 GenerateLineBeforePrologue =
false;
1238 if (
options().getPrintLines() && GenerateLineBeforePrologue) {
1239 if (LVLine *
Line = AddDebugLine(Parent, Metadata::DILocationKind)) {
1240 addSourceLine(
Line, SP);
1241 GenerateLineBeforePrologue =
false;
1246 if (
options().getPrintInstructions())
1247 AddAssemblerLine(Parent);
1251 const DIDerivedType *DT) {
1252 assert(Aggregate &&
"Invalid logical element");
1253 assert(DT &&
"Invalid metadata node.");
1255 dbgs() <<
"\n[getOrCreateMember]\n";
1257 DT->
dump(TheModule);
1260 LVSymbol *
Member = getSymbolForSeenMD(DT);
1261 if (Member &&
Member->getIsFinalized())
1264 if (!
options().getPrintSymbols()) {
1266 getOrCreateType(DT->getBaseType());
1271 Member =
static_cast<LVSymbol *
>(getOrCreateType(Aggregate, DT));
1273 Member->setIsFinalized();
1274 addSourceLine(Member, DT);
1276 Member->addLocation(dwarf::DW_AT_data_member_location, 0,
1280 uint64_t OffsetInBytes = 0;
1290 if (DwarfVersion <= 2) {
1293 Member->addLocation(dwarf::DW_AT_data_member_location, 0,
1296 Member->addLocationOperands(dwarf::DW_OP_plus_uconst, {OffsetInBytes});
1297 }
else if (!IsBitfield || DwarfVersion < 4) {
1300 Member->addLocationConstant(dwarf::DW_AT_data_member_location,
1312 Member->setVirtualityCode(dwarf::DW_VIRTUALITY_virtual);
1315 Member->setIsArtificial();
1333void LVIRReader::constructScope(
LVElement *Element,
const DIScope *
Context) {
1334 assert(Element &&
"Invalid logical element");
1337 dbgs() <<
"\n[constructScope]\n";
1338 dbgs() <<
"Context: ";
1342 if (
const DICompositeType *CTy =
1344 constructType(
static_cast<LVScope *
>(Element), CTy);
1345 }
else if (
const DIDerivedType *DT =
1347 constructType(Element, DT);
1348 }
else if (
const DISubprogram *SP =
1350 getOrCreateSubprogram(
static_cast<LVScope *
>(Element), SP);
1352 Element->setIsFinalized();
1354 Element->setIsFinalized();
1359 const DIDerivedType *DT) {
1360 assert(Aggregate &&
"Invalid logical element");
1361 assert(DT &&
"Invalid metadata node.");
1363 dbgs() <<
"\n[getOrCreateStaticMember]\n";
1365 DT->
dump(TheModule);
1368 LVSymbol *
Member = getSymbolForSeenMD(DT);
1369 if (Member &&
Member->getIsFinalized())
1372 if (!
options().getPrintSymbols()) {
1374 getOrCreateType(DT->getBaseType());
1379 Member =
static_cast<LVSymbol *
>(getOrCreateType(Aggregate, DT));
1381 Member->setIsFinalized();
1382 addSourceLine(Member, DT);
1390LVScope *LVIRReader::getOrCreateSubprogram(
const DISubprogram *SP) {
1391 assert(SP &&
"Invalid metadata node.");
1393 dbgs() <<
"\n[getOrCreateSubprogram]\n";
1395 SP->dump(TheModule);
1398 LVScope *
Function = getScopeForSeenMD(SP);
1403 Function =
static_cast<LVScope *
>(constructElement(SP));
1408 LVScope *Parent =
SP->getDeclaration()
1409 ?
SP->isLocalToUnit() ||
SP->isDefinition()
1411 : getParentScope(SP)->getParentScope()
1412 : getParentScope(SP);
1419 getOrCreateSubprogram(
Function, SP, includeMinimalInlineScopes());
1427 const DISubprogram *SP,
1430 assert(SP &&
"Invalid metadata node.");
1432 dbgs() <<
"\n[getOrCreateSubprogram]\n";
1434 SP->dump(TheModule);
1442 if (
const DISubprogram *SPDecl =
SP->getDeclaration()) {
1445 getOrCreateSubprogram(SPDecl);
1450 for (
const MDNode *DN :
SP->getRetainedNodes()) {
1452 constructImportedEntity(
Function, IE);
1454 constructTemplateTypeParameter(
Function, TTP);
1456 constructTemplateValueParameter(
Function, TVP);
1458 getOrCreateVariable(GVE);
1461 applySubprogramAttributes(
Function, SP);
1464 if (
SP->isArtificial() &&
SP->isLocalToUnit() &&
SP->isDefinition() &&
1465 SP->getName().empty())
1472 const DITypeArray Args) {
1475 dbgs() <<
"\n[constructSubprogramArguments]\n";
1476 for (
unsigned i = 1,
N =
Args.size(); i <
N; ++i) {
1477 if (
const DIType *Ty = Args[i]) {
1479 Ty->
dump(TheModule);
1484 for (
unsigned I = 1,
N =
Args.size();
I <
N; ++
I) {
1485 const DIType *Ty =
Args[
I];
1489 LVElement *ParameterType = getOrCreateType(Ty);
1508void LVIRReader::constructSubrange(
LVScopeArray *Array,
const DISubrange *SR,
1510 assert(Array &&
"Invalid logical element");
1511 assert(SR &&
"Invalid metadata node.");
1513 dbgs() <<
"\n[constructSubrange]\n";
1515 SR->
dump(TheModule);
1522 static_cast<LVTypeSubrange *
>(constructElement(SR))) {
1533 Count = CI->getSExtValue();
1537 int64_t Lowerbound = getDefaultLowerBound();
1539 Lowerbound = (LI) ? LI->getSExtValue() : Lowerbound;
1540 Count = UI->getSExtValue() - Lowerbound + 1;
1548void LVIRReader::constructTemplateTypeParameter(
1549 LVElement *Element,
const DITemplateTypeParameter *TTP) {
1550 assert(Element &&
"Invalid logical element");
1551 assert(TTP &&
"Invalid metadata node.");
1553 dbgs() <<
"\n[constructTemplateTypeParameter]\n";
1555 TTP->
dump(TheModule);
1562 if (LVElement *Parameter = constructElement(TTP)) {
1565 LVScope *Parent =
static_cast<LVScope *
>(Element);
1568 Parent->setIsTemplate();
1571 if (
const DIType *Ty = TTP->
getType()) {
1572 LVElement *
Type = getElementForSeenMD(Ty);
1574 Type = getOrCreateType(Ty);
1581void LVIRReader::constructTemplateValueParameter(
1582 LVElement *Element,
const DITemplateValueParameter *TVP) {
1583 assert(Element &&
"Invalid logical element");
1584 assert(TVP &&
"Invalid metadata node.");
1586 dbgs() <<
"\n[constructTemplateValueParameter]\n";
1588 TVP->
dump(TheModule);
1595 if (LVElement *Parameter = constructElement(TVP)) {
1598 LVScope *Parent =
static_cast<LVScope *
>(Element);
1601 Parent->setIsTemplate();
1605 if (TVP->
getTag() == dwarf::DW_TAG_template_value_parameter) {
1606 LVElement *
Type = getOrCreateType(TVP->
getType());
1611 addConstantValue(Parameter, CI, TVP->
getType());
1613 addConstantValue(Parameter, CF);
1617 Parameter->setValue(
"Unable to describe global value");
1618 }
else if (TVP->
getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1622 }
else if (TVP->
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1635void LVIRReader::constructType(
LVScope *Scope,
const DICompositeType *CTy) {
1636 assert(Scope &&
"Invalid logical element");
1637 assert(CTy &&
"Invalid metadata node.");
1639 dbgs() <<
"\n[constructType]\n";
1641 CTy->
dump(TheModule);
1646 case dwarf::DW_TAG_array_type:
1647 constructArray(
static_cast<LVScopeArray *
>(Scope), CTy);
1649 case dwarf::DW_TAG_enumeration_type:
1650 constructEnum(
static_cast<LVScopeEnumeration *
>(Scope), CTy);
1653 case dwarf::DW_TAG_variant_part:
1654 case dwarf::DW_TAG_namelist:
1656 case dwarf::DW_TAG_structure_type:
1657 case dwarf::DW_TAG_union_type:
1658 case dwarf::DW_TAG_class_type: {
1659 constructAggregate(
static_cast<LVScopeAggregate *
>(Scope), CTy);
1666 if (
Tag == dwarf::DW_TAG_enumeration_type ||
1667 Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
1668 Tag == dwarf::DW_TAG_union_type) {
1674 addSourceLine(Scope, CTy);
1691void LVIRReader::constructType(
LVElement *Element,
const DIDerivedType *DT) {
1692 assert(Element &&
"Invalid logical element");
1693 assert(DT &&
"Invalid metadata node.");
1695 dbgs() <<
"\n[constructType]\n";
1697 DT->
dump(TheModule);
1702 if (DT->
getTag() != dwarf::DW_TAG_member)
1703 Element->setIsFinalized();
1705 LVElement *
BaseType = getOrCreateType(DT->getBaseType());
1710 addAccess(Element, DT->
getFlags());
1716 Element->setIsArtificial();
1720 addSourceLine(Element, DT);
1725 const DISubroutineType *SPTy) {
1727 assert(SPTy &&
"Invalid metadata node.");
1729 dbgs() <<
"\n[constructType]\n";
1731 SPTy->
dump(TheModule);
1742 LVElement *
ElementType = getOrCreateType(Args[0]);
1746 constructSubprogramArguments(
Function, Args);
1750LVScope *LVIRReader::getOrCreateNamespace(
const DINamespace *NS) {
1752 dbgs() <<
"\n[getOrCreateNamespace]\n";
1754 NS->
dump(TheModule);
1757 LVScope *
Scope = getOrCreateScope(NS);
1761 Scope->setName(
"(anonymous namespace)");
1770 dbgs() <<
"\n[getOrCreateScope]\n";
1771 dbgs() <<
"Context: ";
1780 Scope =
static_cast<LVScope *
>(constructElement(
Context));
1783 LVScope *Parent = getParentScope(
Context);
1798 dbgs() <<
"\n[getOrCreateType]\n";
1800 Ty->
dump(TheModule);
1804 LVElement *Element = getElementForSeenMD(Ty);
1808 Element = constructElement(Ty);
1811 LVScope *Parent =
Scope ?
Scope : getParentScope(Ty);
1815 Element->setIsFinalized();
1817 constructType(Element, DT);
1819 constructType(
static_cast<LVScope *
>(Element), CTy);
1821 constructType(
static_cast<LVScope *
>(Element), SPTy);
1830LVIRReader::getOrCreateVariable(
const DIGlobalVariableExpression *GVE) {
1831 assert(GVE &&
"Invalid metadata node.");
1833 dbgs() <<
"\n[getOrCreateVariable]\n";
1835 GVE->
dump(TheModule);
1838 const DIGlobalVariable *DIGV = GVE->
getVariable();
1839 LVSymbol *
Symbol = getSymbolForSeenMD(DIGV);
1841 Symbol = getOrCreateVariable(DIGV);
1845 Symbol->addLocation(dwarf::DW_AT_location, 0, -1,
1847 Symbol->addLocationOperands(dwarf::DW_OP_addrx, PoolAddressIndex++);
1849 addConstantValue(Symbol, DIExpr);
1855 const DILocation *
DL) {
1856 assert(OriginSymbol &&
"Invalid logical element");
1857 assert(
DL &&
"Invalid metadata node.");
1859 dbgs() <<
"\n[getOrCreateInlinedVariable]\n";
1864 const DILocation *InlinedAt =
DL->getInlinedAt();
1871 if (InlinedSymbol) {
1873 InlinedSymbol->setIsFinalized();
1879 getOrCreateSourceID(InlinedAt->getFile()));
1883 InlinedSymbol->setHasReferenceAbstract();
1885 if (OriginSymbol->getIsParameter())
1886 InlinedSymbol->setIsParameter();
1889 LVScope *InlinedScope = getOrCreateInlinedScope(
DL);
1890 assert(InlinedScope &&
"Invalid logical element");
1896 return InlinedSymbol;
1901LVSymbol *LVIRReader::getOrCreateVariable(
const DIVariable *Var,
1902 const DILocation *
DL) {
1903 assert(Var &&
"Invalid metadata node.");
1905 dbgs() <<
"\n[getOrCreateVariable]\n";
1907 Var->
dump(TheModule);
1916 const DILocation *InlinedAt =
DL ?
DL->getInlinedAt() :
nullptr;
1918 LVSymbol *
Symbol = getSymbolForSeenMD(Var);
1919 if (Symbol &&
Symbol->getIsFinalized() && !InlinedAt)
1922 if (!
options().getPrintSymbols()) {
1924 getOrCreateType(Var->
getType());
1926 if (MDTuple *TP = GV->getTemplateParams())
1927 addTemplateParams(Symbol, DINodeArray(TP));
1933 Symbol =
static_cast<LVSymbol *
>(constructElement(Var));
1934 if (Symbol && !
Symbol->getIsFinalized()) {
1935 Symbol->setIsFinalized();
1936 LVScope *Parent = getParentScope(Var);
1947 addSourceLine(Symbol, LV);
1948 if (LV->isParameter()) {
1949 Symbol->setIsParameter();
1950 if (LV->isArtificial())
1951 Symbol->setIsArtificial();
1955 if (useAllLinkageNames())
1960 LVSymbol *
Reference =
static_cast<LVSymbol *
>(getOrCreateType(GVDecl));
1963 Symbol->setHasReferenceSpecification();
1969 addSourceLine(Symbol, GV);
1973 addTemplateParams(Symbol, DINodeArray(TP));
1979 getOrCreateInlinedVariable(Symbol,
DL);
1991 dbgs() <<
"\nBegin all instructions: '" <<
SP->getName() <<
"'\n";
1992 for (Instruction &
I : *BB) {
1993 dbgs() <<
"I: '" <<
I <<
"'\n";
1994 for (DbgVariableRecord &DVR :
filterDbgVars(
I.getDbgRecordRange())) {
1996 DVR.getVariable()->dump(TheModule);
1998 if (
const auto *
DL =
2004 dbgs() <<
"End all instructions: '" <<
SP->getName() <<
"'\n\n";
2009void LVIRReader::processBasicBlocks(
Function &
F) {
2015 dbgs() <<
"\n[processBasicBlocks]\n";
2017 SP->dump(TheModule);
2021 bool AddUnspecifiedParameters =
false;
2022 if (
const DISubroutineType *SPTy =
SP->getType()) {
2024 unsigned N =
Args.size();
2026 const DIType *Ty =
Args[
N - 1];
2028 AddUnspecifiedParameters =
true;
2032 LVScope *
Scope = getOrCreateSubprogram(SP);
2037 auto HandleDbgVariable = [&](
auto *DbgVar) {
2039 dbgs() <<
"\n[HandleDbgVariable]\n";
2040 dbgs() <<
"DbgVar: ";
2044 DebugVariableAggregate DVA(DbgVar);
2045 if (!DbgValueRanges->hasVariableEntry(DVA)) {
2046 DbgValueRanges->addVariable(&
F, DVA);
2051 if (!DbgVar->isKillLocation())
2052 getOrCreateVariable(DbgVar->getVariable(), DbgVar->getDebugLoc().get());
2056 bool GenerateLineBeforePrologue =
true;
2057 for (BasicBlock &BB :
F) {
2060 for (Instruction &
I : BB) {
2063 if (
const auto *
DL =
2066 dbgs() <<
" Location: ";
2069 getOrCreateAbstractScope(
DL);
2072 for (DbgVariableRecord &DVR :
filterDbgVars(
I.getDbgRecordRange()))
2073 HandleDbgVariable(&DVR);
2075 if (
options().getPrintAnyLine())
2076 constructLine(Scope, SP,
I, GenerateLineBeforePrologue);
2085 GenerateLineBeforePrologue =
false;
2087 if (AddUnspecifiedParameters) {
2091 Scope->addElement(Parameter);
2096 for (
const DebugVariableAggregate &DVA : SeenVars) {
2098 DILocalVariable *LV =
const_cast<DILocalVariable *
>(DVA.getVariable());
2099 LVSymbol *
Symbol = getSymbolForSeenMD(LV);
2105 DIType *Ty = LV->getType();
2107 LV->dump(TheModule);
2108 Ty->
dump(TheModule);
2109 dbgs() <<
"Type size: " <<
Size <<
"\n";
2112 auto AddLocationOp = [&](
Value *
V,
bool IsMem) {
2113 uint64_t RegValue = ValueNameMap.addValue(V);
2115 Symbol->addLocationOperands(dwarf::DW_OP_bregx, {RegValue, 0});
2117 Symbol->addLocationOperands(dwarf::DW_OP_regx, RegValue);
2120 auto AddLocation = [&](DbgValueDef DV) {
2121 bool IsMem = DV.IsMemory;
2122 DIExpression *CanonicalExpr =
const_cast<DIExpression *
>(
2124 RawLocationWrapper
Locations(DV.Locations);
2125 for (DIExpression::ExprOperand ExprOp : CanonicalExpr->
expr_ops()) {
2127 AddLocationOp(
Locations.getVariableLocationOp(ExprOp.getArg(0)),
2130 if (ExprOp.getOp() > std::numeric_limits<uint8_t>::max())
2131 LLVM_DEBUG(
dbgs() <<
"Bad DWARF op: " << ExprOp.getOp() <<
"\n");
2132 uint8_t ShortOp = (uint8_t)ExprOp.getOp();
2133 Symbol->addLocationOperands(
2135 ArrayRef<uint64_t>(std::next(ExprOp.get()), ExprOp.getNumArgs()));
2140 if (DbgValueRanges->hasSingleLocEntry(DVA)) {
2141 DbgValueDef DV = DbgValueRanges->getSingleLoc(DVA);
2142 Symbol->addLocation(llvm::dwarf::DW_AT_location, 0,
2148 for (
const DbgRangeEntry &Entry :
2149 DbgValueRanges->getVariableRanges(DVA)) {
2154 Symbol->addLocation(llvm::dwarf::DW_AT_location, Start, End,
2156 DbgValueDef DV =
Entry.Value;
2168 W.startLine() <<
"\n";
2181 std::unique_ptr<Module> M =
2188 if (
options().getWarningAll())
2189 Err.print(
"",
outs());
2191 "Could not create IR module for: %s",
2195 TheModule = M.get();
2196 if (!TheModule->getNamedMetadata(
"llvm.dbg.cu")) {
2201 DwarfVersion = TheModule->getDwarfVersion();
2207 CU->dump(TheModule);
2213 const DIFile *File =
CU->getFile();
2215 CompileUnit->setCompilationDirectory(File->getDirectory());
2222 uint16_t LanguageName =
CU->getSourceLanguage().getName();
2225 setDefaultLowerBound(&SL);
2227 if (
options().getAttributeLanguage())
2230 if (
options().getAttributeProducer())
2236 getOrCreateVariable(GVE);
2242 for (
auto *ET :
CU->getEnumTypes())
2243 getOrCreateType(ET);
2247 for (
const auto *RT :
CU->getRetainedTypes()) {
2249 getOrCreateType(Ty);
2257 for (
const auto *IE :
CU->getImportedEntities())
2263 dbgs() <<
"\nFunctions\n";
2264 for (
Function &
F : M->getFunctionList())
2266 SP->dump(TheModule);
2269 for (
Function &
F : M->getFunctionList())
2270 processBasicBlocks(
F);
2273 resolveInlinedLexicalScopes();
2274 removeEmptyScopes();
2276 processLocationGaps();
2279 if (
options().getInternalIntegrity())
2282 TheModule =
nullptr;
2288 assert(Scope &&
"Invalid logical element");
2290 dbgs() <<
"\n[constructRange]\n";
2294 dbgs() <<
"Name: " << Scope->getName() <<
"\n";
2298 Scope->addObject(LowPC, HighPC);
2299 if (!Scope->getIsCompileUnit()) {
2301 if ((
options().getAttributePublics() ||
options().getPrintAnyLine()) &&
2302 Scope->getIsFunction() && !Scope->getIsInlinedFunction())
2315void LVIRReader::constructRange(
LVScope *Scope) {
2317 dbgs() <<
"\n[constructRange]\n";
2319 dbgs() <<
"Name: " <<
Scope->getName() <<
"\n\n";
2323 return Offset + OFFSET_INCREASE - 1;
2336 for (
const LVLine *
Line : *Lines) {
2353 Current =
Line->getAddress();
2354 if (Current == Previous) {
2358 if (Current ==
Upper + 1) {
2360 Upper = NextRange(Current);
2377void LVIRReader::removeEmptyScopes() {
2383 auto DeleteEmptyScopes = [&]() {
2384 if (EmptyScopes.empty())
2388 dbgs() <<
"\n** Collected empty scopes **\n";
2389 for (
auto Scope : EmptyScopes)
2393 LVScope *Parent =
nullptr;
2394 for (
auto Scope : EmptyScopes) {
2395 Parent =
Scope->getParentScope();
2397 dbgs() <<
"Scope: " <<
Scope->getID() <<
", ";
2398 dbgs() <<
"Parent: " << Parent->getID() <<
"\n";
2405 std::copy(Lines->begin(), Lines->end(), std::back_inserter(Pack));
2406 for (LVLine *
Line : Pack) {
2409 Line->resetParent();
2410 Parent->addElement(
Line);
2411 Line->updateLevel(Parent,
false);
2416 if (Parent->removeElement(Scope)) {
2419 for (LVScope *Child : *Scopes) {
2421 Child->resetParent();
2422 Parent->addElement(Child);
2423 Child->updateLevel(Parent,
false);
2433 std::function<void(LVScope *)> TraverseScope = [&](LVScope *Current) {
2434 auto IsEmpty = [](LVScope *
Scope) ->
bool {
2435 return !
Scope->getSymbols() && !
Scope->getTypes() && !
Scope->getRanges();
2438 if (
const LVScopes *Scopes = Current->getScopes()) {
2439 for (LVScope *Scope : *Scopes) {
2440 if (
Scope->getIsLexicalBlock() && IsEmpty(Scope))
2441 EmptyScopes.push_back(Scope);
2442 TraverseScope(Scope);
2448 bool InternalID =
options().getInternalID();
2457 dbgs() <<
"\nBefore - RemoveEmptyScopes\n";
2462 DeleteEmptyScopes();
2465 dbgs() <<
"\nAfter - RemoveEmptyScopes\n";
2472void LVIRReader::resolveInlinedLexicalScopes() {
2474 LLVM_DEBUG({ dumpInlinedInfo(
"Before",
false); });
2476 std::function<void(LVScope * Scope)> TraverseChildren = [&](LVScope *Parent) {
2478 dbgs() <<
"\nParent Scope: ";
2479 Parent->dumpCommon();
2483 LVList &ParentInlinedList = getInlinedList(Parent);
2486 auto CheckInlinedScope = [&](LVList &ScopeInlinedList) ->
bool {
2487 bool Matched =
true;
2488 for (
auto &InlinedScope : ScopeInlinedList) {
2490 dbgs() <<
"Inlined Scope: ";
2494 for (
auto &ParentInlinedScope : ParentInlinedList) {
2495 if (ParentInlinedScope != ParentScope) {
2501 dbgs() <<
"\nIncorrect parent scope\n";
2502 dbgs() <<
"ParentInlinedScope: ";
2503 ParentInlinedScope->dumpCommon();
2504 dbgs() <<
"ParentScope: ";
2505 ParentScope->dumpCommon();
2519 auto AdjustInlinedScope = [&](LVList &ScopeInlinedList) {
2520 assert(ScopeInlinedList.size() == ParentInlinedList.size() &&
2521 "Scope list do not have same number of items.");
2524 LVScope *CurrentParent =
nullptr;
2525 LVScope *TargetParent =
nullptr;
2526 LVScope *InlinedScope =
nullptr;
2527 auto ItInlined = ScopeInlinedList.begin();
2528 auto ItParent = ParentInlinedList.begin();
2529 while (ItInlined != ScopeInlinedList.end()) {
2530 TargetParent = *ItParent;
2531 InlinedScope = *ItInlined;
2535 dbgs() <<
"Target Parent: ";
2537 dbgs() <<
"Current Parent: ";
2538 CurrentParent->dumpCommon();
2539 dbgs() <<
"Inlined: ";
2544 if (CurrentParent->removeElement(InlinedScope)) {
2558 dbgs() <<
"\nOrigin Scope: ";
2559 Scope->dumpCommon();
2563 LVList &ScopeInlinedList = getInlinedList(Scope);
2564 if (!CheckInlinedScope(ScopeInlinedList)) {
2566 AdjustInlinedScope(ScopeInlinedList);
2568 TraverseChildren(Scope);
2575 for (
auto &Entry : InlinedList) {
2576 LVScope *OriginScope =
Entry.first;
2577 if (OriginScope->getIsFunction())
2578 TraverseChildren(OriginScope);
2581 LLVM_DEBUG({ dumpInlinedInfo(
"After",
false); });
2586void LVIRReader::checkScopes(
LVScope *Scope) {
2589 auto PrintElement = [](LVElement *Element) {
2592 size_t ID = Element->getID();
2593 const char *
Kind = Element->kind();
2594 StringRef
Name = Element->getName();
2595 uint32_t LineNumber = Element->getLineNumber();
2603 dbgs() <<
"Name: '" << std::string(
Name) <<
"' ";
2608 std::function<void(LVScope * Parent)> Traverse = [&](LVScope *Current) {
2611 if (!
Entry->getIsFinalized())
2612 PrintElement(Entry);
2615 for (LVElement *Element : Current->getChildren())
2618 if (Current->getScopes())
2619 for (LVScope *Scope : *Current->getScopes())
2630 OS <<
"LVIRReader\n";
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Module.h This file contains the declarations for the Module class.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
This file defines the make_scope_exit function, which executes user-defined cleanup logic at scope ex...
APInt bitcastToAPInt() const
Represent a constant reference to an array (0 or more elements consecutively in memory),...
const Function * getParent() const
Return the enclosing method, or null if none.
const APFloat & getValueAPF() const
const APInt & getValue() const
Return the constant as an APInt value reference.
DINodeArray getElements() const
DITemplateParameterArray getTemplateParams() const
DIType * getBaseType() const
iterator_range< expr_op_iterator > expr_ops() const
static LLVM_ABI const DIExpression * convertToVariadicExpression(const DIExpression *Expr)
If Expr is a non-variadic expression (i.e.
uint64_t getElement(unsigned I) const
LLVM_ABI std::optional< SignedOrUnsignedConstant > isConstant() const
Determine whether this represents a constant value, if so.
A pair of DIGlobalVariable and DIExpression.
DIGlobalVariable * getVariable() const
DIExpression * getExpression() const
DIDerivedType * getStaticDataMemberDeclaration() const
MDTuple * getTemplateParams() const
bool isLocalToUnit() const
StringRef getLinkageName() const
StringRef getName() const
Tagged DWARF-like metadata node.
LLVM_ABI dwarf::Tag getTag() const
Base class for scope-like contexts.
LLVM_ABI BoundType getUpperBound() const
LLVM_ABI BoundType getLowerBound() const
LLVM_ABI BoundType getCount() const
DITypeArray getTypeArray() const
Metadata * getValue() const
bool isStaticMember() const
uint64_t getOffsetInBits() const
bool isForwardDecl() const
uint64_t getSizeInBits() const
bool isArtificial() const
StringRef getName() const
static bool isUnsignedDIType(const DIType *Ty)
Return true if type encoding is unsigned.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
This is an important class for using LLVM in a threaded context.
LLVM_ABI void dump() const
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
StringRef str() const
Explicit conversion to StringRef.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Stores all information relating to a compile unit, be it in its original instance in the object file ...
virtual void setCallLineNumber(uint32_t Number)
virtual void setLinkageName(StringRef LinkageName)
virtual void setValue(StringRef Value)
void setFilename(StringRef Filename)
void setInlineCode(uint32_t Code)
virtual void setReference(LVElement *Element)
virtual StringRef getLinkageName() const
void setName(StringRef ElementName) override
StringRef getName() const override
LVElement * getType() const
void setAccessibilityCode(uint32_t Access)
void setVirtualityCode(uint32_t Virtuality)
void setType(LVElement *Element=nullptr)
void setFilenameIndex(size_t Index)
size_t getFilenameIndex() const
virtual void setCallFilenameIndex(size_t Index)
virtual size_t getLinkageNameIndex() const
Error createScopes() override
void print(raw_ostream &OS) const
std::string getRegisterName(LVSmall Opcode, ArrayRef< uint64_t > Operands) override
void sortScopes() override
void printAllInstructions(BasicBlock *BB)
virtual const char * kind() const
LVScope * getParentScope() const
dwarf::Tag getTag() const
uint32_t getLineNumber() const
void setOffset(LVOffset DieOffset)
void setLineNumber(uint32_t Number)
void setTag(dwarf::Tag Tag)
void resolvePatternMatch(LVLine *Line)
std::string FileFormatName
LVElement * createElement(dwarf::Tag Tag)
void printCollectedElements(LVScope *Root)
StringRef getFilename() const
LVScopeCompileUnit * CompileUnit
void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope)
virtual Error createScopes()
virtual LVScope * getReference() const
void addElement(LVElement *Element)
void updateLevel(LVScope *Parent, bool Moved) override
void setReference(LVSymbol *Symbol) override
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ DW_OP_LLVM_arg
Only used in LLVM metadata.
ElementType
The element type of an SRV or UAV resource.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
std::string decString(uint64_t Value, size_t Width=DEC_WIDTH)
std::string hexString(uint64_t Value, size_t Width=HEX_WIDTH)
std::string formattedKind(StringRef Kind)
SmallVector< LVScope *, 8 > LVScopes
std::string hexSquareString(uint64_t Value)
SmallVector< LVSymbol *, 8 > LVSymbols
LLVM_ABI std::string transformPath(StringRef Path)
SmallVector< LVLine *, 8 > LVLines
SmallVector< LVType *, 8 > LVTypes
@ Parameter
An inlay hint that is for a parameter.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
LLVM_ABI StringRef filename(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get filename.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
scope_exit(Callable) -> scope_exit< Callable >
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
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 ...
@ Import
Import information from summary.
auto cast_or_null(const Y &Val)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
auto dyn_cast_or_null(const Y &Val)
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI std::unique_ptr< Module > parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, LLVMContext &Context, ParserCallbacks Callbacks={}, AsmParserContext *ParserContext=nullptr)
If the given MemoryBuffer holds a bitcode image, return a Module for it.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
support::detail::AlignAdapter< T > fmt_align(T &&Item, AlignStyle Where, size_t Amount, char Fill=' ')
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
A source language supported by any of the debug info representations.
LLVM_ABI StringRef getName() const