35#define DEBUG_TYPE "IRReader"
42using LVScopeEntry = std::pair<const DILocalScope *, const DILocation *>;
43using LVInlinedScopes =
44 std::unordered_map<LVScopeEntry,
LVScope *,
46LVInlinedScopes InlinedScopes;
50 auto Entry = LVScopeEntry(OriginContext, InlinedAt);
51 InlinedScopes.try_emplace(Entry, InlinedScope);
55 auto Entry = LVScopeEntry(OriginContext, InlinedAt);
56 LVInlinedScopes::const_iterator Iter = InlinedScopes.find(Entry);
57 return Iter != InlinedScopes.end() ? Iter->second :
nullptr;
63using LVInlinedToOrigin = std::unordered_map<LVScope *, LVScope *>;
64LVInlinedToOrigin InlinedToOrigin;
69using LVInlinedList = std::unordered_map<LVScope *, LVList>;
70LVInlinedList InlinedList;
74 InlinedToOrigin.try_emplace(
Inlined, Origin);
77 auto [It,
_] = InlinedList.try_emplace(Origin, LVList{});
78 LVList &List = It->second;
82LVList &getInlinedList(
LVScope *Origin) {
83 static LVList EmptyList;
84 auto It = InlinedList.find(Origin);
85 return (It == InlinedList.end()) ? EmptyList : It->second;
88#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
89void dumpInlinedInfo(
const char *
Text,
bool Full =
false) {
91 constexpr unsigned LEN = 17;
97 << std::setw(LEN) << std::left <<
formattedKind(Scope->kind());
106 dbgs() <<
"\nOrigin -> Inlined list: " <<
Text <<
"\n\n";
107 for (
auto &Entry : InlinedList) {
108 LVScope *OriginScope = Entry.first;
109 LVList &List = Entry.second;
110 PrintEntry(
"", OriginScope);
113 for (
auto &Scope : List) {
115 PrintEntry(
" ", Scope);
120 dbgs() <<
"\nOrigin -> Inlined: " <<
Text <<
"\n\n";
121 for (
auto &Entry : InlinedToOrigin) {
122 LVScope *InlinedScope = Entry.first;
123 LVScope *OriginScope = Entry.second;
124 PrintEntry(
"", InlinedScope);
126 PrintEntry(
"", OriginScope);
132 for (
auto &Entry : InlinedToOrigin) {
133 LVScope *InlinedScope = Entry.first;
134 LVScope *OriginScope = Entry.second;
136 PrintExtra(
"Origin: ", OriginScope);
138 PrintExtra(
"Inlined: ", InlinedScope);
168 if (StringRef
Name = getMDName(DN); !
Name.empty())
172 if (
const DIFile *File = getMDFile(DN))
173 getOrCreateSourceID(File);
179 assert(SL &&
"Invalid language ID.");
180 StringRef LanguageName = SL->
getName();
183 DefaultLowerBound = LanguageName.
contains(
"fortran") ? 1 : 0;
185 LLVM_DEBUG({
dbgs() <<
"Language Name: " << LanguageName <<
"\n"; });
188bool LVIRReader::includeMinimalInlineScopes()
const {
192size_t LVIRReader::getOrCreateSourceID(
const DIFile *File) {
197 dbgs() <<
"\n[getOrCreateSourceID]\n";
199 File->dump(TheModule);
204 dbgs() <<
"Directory: '" <<
File->getDirectory() <<
"'\n";
205 dbgs() <<
"Filename: '" <<
File->getFilename() <<
"'\n";
209 auto [Iter,
Inserted] = CompileUnitFiles.try_emplace(File, ++FileIndex);
211 std::string Directory(
File->getDirectory());
212 if (Directory.empty())
213 Directory = std::string(
CompileUnit->getCompilationDirectory());
215 std::string FullName;
216 raw_string_ostream Out(FullName);
221 FileIndex = Iter->second;
228void LVIRReader::addSourceLine(
LVElement *Element,
unsigned Line,
229 const DIFile *File) {
239 size_t FileID = getOrCreateSourceID(File);
240 if (Element->getIsLine())
247 dbgs() <<
"\n[addSourceLine]\n";
248 File->dump(TheModule);
250 dbgs() <<
"ID: " << Element->
getID() <<
", ";
251 dbgs() <<
"Kind: " << Element->
kind() <<
", ";
257void LVIRReader::addSourceLine(
LVElement *Element,
const DIGlobalVariable *
G) {
259 addSourceLine(Element,
G->getLine(),
G->getFile());
262void LVIRReader::addSourceLine(
LVElement *Element,
const DIImportedEntity *IE) {
264 addSourceLine(Element,
IE->getLine(),
IE->getFile());
267void LVIRReader::addSourceLine(
LVElement *Element,
const DILabel *L) {
269 addSourceLine(Element,
L->getLine(),
L->getFile());
272void LVIRReader::addSourceLine(
LVElement *Element,
const DILocalVariable *V) {
274 addSourceLine(Element,
V->getLine(),
V->getFile());
277void LVIRReader::addSourceLine(
LVElement *Element,
const DILocation *
DL) {
279 addSourceLine(Element,
DL->getLine(),
DL->getFile());
282void LVIRReader::addSourceLine(
LVElement *Element,
const DIObjCProperty *
OP) {
284 addSourceLine(Element,
OP->getLine(),
OP->getFile());
287void LVIRReader::addSourceLine(
LVElement *Element,
const DISubprogram *SP) {
289 addSourceLine(Element,
SP->getLine(),
SP->getFile());
292void LVIRReader::addSourceLine(
LVElement *Element,
const DIType *Ty) {
297void LVIRReader::addConstantValue(
LVElement *Element,
298 const DIExpression *DIExpr) {
299 std::optional<DIExpression::SignedOrUnsignedConstant>
Constant =
301 if (Constant == std::nullopt)
303 std::stringstream Stream;
306 if (int64_t SignedValue =
static_cast<int64_t
>(
Value); SignedValue < 0) {
315void LVIRReader::addConstantValue(
LVElement *Element,
const ConstantFP *CFP) {
319void LVIRReader::addConstantValue(
LVElement *Element,
const ConstantInt *CI,
321 addConstantValue(Element, CI->
getValue(), Ty);
334void LVIRReader::addConstantValue(
LVElement *Element,
const APInt &Val,
339void LVIRReader::addConstantValue(
LVElement *Element,
const APInt &
Value,
341 SmallString<128> StringValue;
348void LVIRReader::processLocationGaps() {
349 if (
options().getAttributeAnyLocation())
350 for (LVSymbol *Symbol : SymbolsWithLocations)
351 Symbol->fillLocationGaps();
354void LVIRReader::processScopes() {
363 auto SetOffset = [&](LVElement *Element) {
365 Offset += OFFSET_INCREASE;
368 std::function<void(LVScope *)> TraverseScope = [&](LVScope *Current) {
371 constructRange(Current);
373 if (
const LVScopes *Scopes = Current->getScopes())
374 for (LVScope *Scope : *Scopes)
375 TraverseScope(Scope);
378 if (
const LVSymbols *Symbols = Current->getSymbols())
379 for (LVSymbol *Symbol : *Symbols)
381 if (
const LVTypes *Types = Current->getTypes())
382 for (LVType *
Type : *Types)
386 if (
const LVLines *Lines = Current->getLines())
387 for (LVLine *
Line : *Lines)
404 if (Opcode == dwarf::DW_OP_regval_type)
407 if (Opcode == dwarf::DW_OP_regx || Opcode == dwarf::DW_OP_bregx) {
416 return " " + ValueNameMap.getName(
Operands[0]);
427 dbgs() <<
"\n[getParentScopeImpl]\n";
428 dbgs() <<
"Context: ";
429 Context->dump(TheModule);
433 if (
LVScope *Parent = getScopeForSeenMD(Context))
437 return traverseParentScope(Context);
442 assert(
DL &&
"Invalid metadata node.");
444 dbgs() <<
"\n[getParentScope]\n";
453LVScope *LVIRReader::getParentScope(
const DINode *DN) {
454 assert(DN &&
"Invalid metadata node.");
456 dbgs() <<
"\n[getParentScope]\n";
461 return getParentScopeImpl(getMDScope(DN));
469 dbgs() <<
"\n[traverseParentScope]\n";
470 dbgs() <<
"Context: \n";
475 if (LVScope *Parent = getScopeForSeenMD(
Context))
479 LVElement *Element = constructElement(
Context);
481 const DIScope *ParentContext =
nullptr;
484 if (DICompileUnit *CU =
SP->getUnit())
485 ParentContext = getMDScope(
SP->getDeclaration() ? CU :
Context);
487 ParentContext = getMDScope(
Context);
489 LVScope *Parent = traverseParentScope(ParentContext);
492 constructScope(Element,
Context);
496 return static_cast<LVScope *
>(Element);
503LVType *LVIRReader::getIndexType() {
506 return NodeIndexType;
509 NodeIndexType =
static_cast<LVType *
>(
createElement(dwarf::DW_TAG_base_type));
511 NodeIndexType->setIsFinalized();
512 NodeIndexType->setName(
"__ARRAY_SIZE_TYPE__");
516 return NodeIndexType;
520 assert(Element &&
"Invalid logical element.");
522 dbgs() <<
"\n[addAccess]\n";
527 switch (Accessibility) {
528 case DINode::FlagProtected:
531 case DINode::FlagPrivate:
534 case DINode::FlagPublic:
537 case DINode::FlagZero:
540 if (Parent->getIsClass()) {
544 if (Parent->getIsStructure() || Parent->getIsUnion()) {
560const DIFile *LVIRReader::getMDFile(
const MDNode *MD)
const {
561 assert(MD &&
"Invalid metadata node.");
563 dbgs() <<
"\n[getMDFile]\n";
609StringRef LVIRReader::getMDName(
const DINode *DN)
const {
610 assert(DN &&
"Invalid metadata node.");
612 dbgs() <<
"\n[getMDName]\n";
651 "Unhandled DINode.");
655const DIScope *LVIRReader::getMDScope(
const DINode *DN)
const {
656 assert(DN &&
"Invalid metadata node.");
658 dbgs() <<
"\n[getMDScope]\n";
668 const DIScope *
Context =
T->getScope();
675 return T->getScope();
678 return T->getScope();
681 return T->getScope();
692void LVIRReader::addTemplateParams(
LVElement *Element,
693 const DINodeArray TParams) {
694 assert(Element &&
"Invalid logical element");
697 dbgs() <<
"\n[addTemplateParams]\n";
698 for (
const auto *Entry : TParams) {
700 Entry->dump(TheModule);
705 for (
const auto *Entry : TParams) {
707 constructTemplateTypeParameter(Element, TTP);
709 constructTemplateValueParameter(Element, TVP);
715 const DISubprogram *SP,
716 bool SkipSPAttributes) {
718 assert(SP &&
"Invalid metadata node.");
720 dbgs() <<
"\n[applySubprogramAttributes]\n";
727 bool SkipSPSourceLocation =
728 SkipSPAttributes && !getCUNode()->getDebugInfoForProfiling();
729 if (!SkipSPSourceLocation)
730 if (applySubprogramDefinitionAttributes(
Function, SP, SkipSPAttributes))
733 if (!SkipSPSourceLocation)
737 if (SkipSPAttributes)
741 if (
const DISubroutineType *SPTy =
SP->getType())
742 Args = SPTy->getTypeArray();
751 Function->setVirtualityCode(
SP->getVirtuality());
753 if (!
SP->isDefinition()) {
756 constructSubprogramArguments(
Function, Args);
759 if (
SP->isArtificial())
762 if (!
SP->isLocalToUnit())
771 const DISubprogram *SP,
774 assert(SP &&
"Invalid metadata node.");
776 dbgs() <<
"\n[applySubprogramDefinitionAttributes]\n";
782 StringRef DeclLinkageName;
783 if (
const DISubprogram *SPDecl =
SP->getDeclaration()) {
785 DITypeArray DeclArgs, DefinitionArgs;
786 DeclArgs = SPDecl->getType()->getTypeArray();
787 DefinitionArgs =
SP->getType()->getTypeArray();
812 if (DeclArgs.size() && DefinitionArgs.size())
813 if (DefinitionArgs[0] !=
nullptr && DeclArgs[0] != DefinitionArgs[0]) {
814 LVElement *
ElementType = getOrCreateType(DefinitionArgs[0]);
821 if (useAllLinkageNames())
822 DeclLinkageName = SPDecl->getLinkageName();
823 unsigned DeclID = getOrCreateSourceID(SPDecl->getFile());
824 unsigned DefID = getOrCreateSourceID(
SP->getFile());
828 if (
SP->getLine() != SPDecl->getLine())
834 addTemplateParams(
Function,
SP->getTemplateParams());
839 if (DeclLinkageName !=
LinkageName && (useAllLinkageNames()))
848 Function->setHasReferenceSpecification();
855 const DICompositeType *CTy) {
856 assert(Aggregate &&
"Invalid logical element");
857 assert(CTy &&
"Invalid metadata node.");
859 dbgs() <<
"\n[constructAggregate]\n";
861 CTy->
dump(TheModule);
864 if (Aggregate->getIsFinalized())
866 Aggregate->setIsFinalized();
871 if (
Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
872 Tag == dwarf::DW_TAG_union_type)
880 dbgs() <<
"\nMember: ";
884 getOrCreateSubprogram(SP);
887 if (
Tag == dwarf::DW_TAG_member ||
Tag == dwarf::DW_TAG_variable) {
888 if (DT->isStaticMember())
889 getOrCreateStaticMember(Aggregate, DT);
891 getOrCreateMember(Aggregate, DT);
893 getOrCreateType(Aggregate, DT);
901 const DICompositeType *CTy) {
902 assert(Array &&
"Invalid logical element");
903 assert(CTy &&
"Invalid metadata node.");
905 dbgs() <<
"\n[constructArray]\n";
907 CTy->
dump(TheModule);
910 if (
Array->getIsFinalized())
912 Array->setIsFinalized();
918 LVType *IndexType = getIndexType();
922 for (DINode *DN : Entries) {
924 if (SR->getTag() == dwarf::DW_TAG_subrange_type)
926 else if (SR->getTag() == dwarf::DW_TAG_generic_subrange)
934 const DICompositeType *CTy) {
935 assert(Enumeration &&
"Invalid logical element");
936 assert(CTy &&
"Invalid metadata node.");
938 dbgs() <<
"\n[constructEnum]\n";
940 CTy->
dump(TheModule);
943 if (Enumeration->getIsFinalized())
945 Enumeration->setIsFinalized();
950 if (LVElement *
BaseType = getOrCreateType(Ty))
953 if (CTy->
getFlags() & DINode::FlagEnumClass)
954 Enumeration->setIsEnumClass();
958 for (
const DINode *DN : Entries) {
960 if (LVElement *
Enumerator = constructElement(Enum)) {
969void LVIRReader::constructGenericSubrange(
LVScopeArray *Array,
970 const DIGenericSubrange *GSR,
972 assert(Array &&
"Invalid logical element");
973 assert(GSR &&
"Invalid metadata node.");
975 dbgs() <<
"\n[constructGenericSubrange]\n";
977 GSR->
dump(TheModule);
984void LVIRReader::constructImportedEntity(
LVElement *Element,
985 const DIImportedEntity *IE) {
986 assert(Element &&
"Invalid logical element");
987 assert(IE &&
"Invalid metadata node.");
989 dbgs() <<
"\n[constructImportedEntity]\n";
994 if (LVElement *
Import = constructElement(IE)) {
996 addSourceLine(
Import, IE);
997 LVScope *Parent = getParentScope(IE);
1000 const DINode *Entity =
IE->getEntity();
1001 LVElement *
Target = getElementForSeenMD(Entity);
1004 Target = getOrCreateType(Ty);
1006 Target = getOrCreateSubprogram(SP);
1008 Target = getOrCreateNamespace(NS);
1010 Target = getOrCreateScope(M);
1017LVScope *LVIRReader::getOrCreateInlinedScope(
const DILocation *
DL) {
1018 assert(
DL &&
"Invalid metadata node.");
1020 dbgs() <<
"\n[getOrCreateInlinedScope]\n";
1025 const DILocalScope *OriginContext =
DL->getScope();
1027 dbgs() <<
"OriginContext: ";
1028 OriginContext->dump(TheModule);
1031 auto CreateScope = [&](
const DILocalScope *
Context) -> LVScope * {
1032 LVScope *
Scope =
nullptr;
1034 Scope = getOrCreateSubprogram(SP);
1038 dbgs() <<
"Scope: ";
1039 Scope->dumpCommon();
1045 const DILocation *InlinedAt =
DL->getInlinedAt();
1047 return CreateScope(OriginContext);
1050 dbgs() <<
"InlinedAt: ";
1051 InlinedAt->
dump(TheModule);
1055 if (LVScope *InlinedScope = getInlinedScope(OriginContext, InlinedAt))
1056 return InlinedScope;
1060 LVScope *OriginScope = CreateScope(OriginContext);
1063 if (OriginScope->getIsFunction() || OriginScope->getIsInlinedFunction()) {
1064 Tag = dwarf::DW_TAG_inlined_subroutine;
1069 addInlinedScope(OriginContext, InlinedAt, InlinedScope);
1071 InlinedScope->setIsFinalized();
1077 getOrCreateSourceID(InlinedAt->getFile()));
1080 InlinedScope->setHasReferenceAbstract();
1085 dbgs() <<
"Linking\n";
1089 addInlinedInfo(OriginScope, InlinedScope);
1092 DILocalScope *AbstractContext = InlinedAt->getScope();
1093 dbgs() <<
"AbstractContext: ";
1094 AbstractContext->
dump(TheModule);
1097 LVScope *AbstractScope = getOrCreateInlinedScope(InlinedAt);
1098 assert(AbstractScope &&
"Logical scope is NULL.");
1100 dbgs() <<
"AbstractScope: ";
1101 AbstractScope->dumpCommon();
1105 AbstractScope->addElement(InlinedScope);
1108 dbgs() <<
"InlinedScope: ";
1113 return InlinedScope;
1116LVScope *LVIRReader::getOrCreateAbstractScope(
const DILocation *
DL) {
1117 assert(
DL &&
"Invalid metadata node.");
1119 dbgs() <<
"\n[getOrCreateAbstractScope]\n";
1125 LVScope *InlinedScope = getOrCreateInlinedScope(
DL);
1126 assert(InlinedScope &&
"InlinedScope is null.");
1127 return InlinedScope;
1130void LVIRReader::constructLine(
LVScope *Scope,
const DISubprogram *SP,
1132 bool &GenerateLineBeforePrologue) {
1133 assert(Scope &&
"Invalid logical element");
1134 assert(SP &&
"Invalid metadata node.");
1136 dbgs() <<
"\n[constructLine]\n";
1137 dbgs() <<
"Instruction: ";
1139 dbgs() <<
"Logical Scope: ";
1140 Scope->dumpCommon();
1143 auto AddDebugLine = [&](LVScope *Parent,
unsigned ID) -> LVLine * {
1144 assert(Parent &&
"Invalid logical element");
1145 assert(
ID == Metadata::DILocationKind &&
"Invalid Metadata Object");
1147 dbgs() <<
"\n[AddDebugLine]\n";
1148 dbgs() <<
"Parent: ";
1152 LVLine *
Line = createLineDebug();
1156 Line->setIsFinalized();
1172 Parent->getHasReferenceSpecification()) {
1175 GenerateLineBeforePrologue =
false;
1181 auto AddAssemblerLine = [&](LVScope *Parent) {
1182 assert(Parent &&
"Invalid logical element");
1184 static const char *WhiteSpace =
" \t\n\r\f\v";
1185 static std::string
Metadata(
"metadata ");
1187 auto RemoveAll = [](std::string &Input, std::string &Pattern) {
1188 std::string::size_type
Len = Pattern.length();
1189 for (std::string::size_type Index = Input.find(Pattern);
1190 Index != std::string::npos; Index = Input.find(Pattern))
1191 Input.erase(Index, Len);
1194 std::string InstructionText;
1195 raw_string_ostream Stream(InstructionText);
1198 RemoveAll(InstructionText,
Metadata);
1199 std::string_view
Text(InstructionText);
1200 const auto pos(
Text.find_first_not_of(WhiteSpace));
1201 Text.remove_prefix(std::min(pos,
Text.length()));
1204 if (LVLineAssembler *
Line = createLineAssembler()) {
1205 Line->setIsFinalized();
1212 LVScope *Parent =
Scope;
1213 if (
const DebugLoc DbgLoc =
I.getDebugLoc()) {
1214 const DILocation *
DL = DbgLoc.get();
1220 Parent = getOrCreateAbstractScope(
DL);
1221 assert(Parent &&
"Invalid logical element");
1223 dbgs() <<
"Parent: ";
1224 Parent->dumpCommon();
1227 if (
options().getPrintLines() &&
DL->getLine()) {
1228 if (LVLine *
Line = AddDebugLine(Parent,
DL->getMetadataID())) {
1231 GenerateLineBeforePrologue =
false;
1237 if (
options().getPrintLines() && GenerateLineBeforePrologue) {
1238 if (LVLine *
Line = AddDebugLine(Parent, Metadata::DILocationKind)) {
1239 addSourceLine(
Line, SP);
1240 GenerateLineBeforePrologue =
false;
1245 if (
options().getPrintInstructions())
1246 AddAssemblerLine(Parent);
1250 const DIDerivedType *DT) {
1251 assert(Aggregate &&
"Invalid logical element");
1252 assert(DT &&
"Invalid metadata node.");
1254 dbgs() <<
"\n[getOrCreateMember]\n";
1256 DT->
dump(TheModule);
1259 LVSymbol *
Member = getSymbolForSeenMD(DT);
1260 if (Member &&
Member->getIsFinalized())
1263 if (!
options().getPrintSymbols()) {
1265 getOrCreateType(DT->getBaseType());
1270 Member =
static_cast<LVSymbol *
>(getOrCreateType(Aggregate, DT));
1272 Member->setIsFinalized();
1273 addSourceLine(Member, DT);
1275 Member->addLocation(dwarf::DW_AT_data_member_location, 0,
1289 if (DwarfVersion <= 2) {
1292 Member->addLocation(dwarf::DW_AT_data_member_location, 0,
1295 Member->addLocationOperands(dwarf::DW_OP_plus_uconst, {OffsetInBytes});
1296 }
else if (!IsBitfield || DwarfVersion < 4) {
1299 Member->addLocationConstant(dwarf::DW_AT_data_member_location,
1311 Member->setVirtualityCode(dwarf::DW_VIRTUALITY_virtual);
1314 Member->setIsArtificial();
1332void LVIRReader::constructScope(
LVElement *Element,
const DIScope *
Context) {
1333 assert(Element &&
"Invalid logical element");
1336 dbgs() <<
"\n[constructScope]\n";
1337 dbgs() <<
"Context: ";
1341 if (
const DICompositeType *CTy =
1343 constructType(
static_cast<LVScope *
>(Element), CTy);
1344 }
else if (
const DIDerivedType *DT =
1346 constructType(Element, DT);
1347 }
else if (
const DISubprogram *SP =
1349 getOrCreateSubprogram(
static_cast<LVScope *
>(Element), SP);
1351 Element->setIsFinalized();
1353 Element->setIsFinalized();
1358 const DIDerivedType *DT) {
1359 assert(Aggregate &&
"Invalid logical element");
1360 assert(DT &&
"Invalid metadata node.");
1362 dbgs() <<
"\n[getOrCreateStaticMember]\n";
1364 DT->
dump(TheModule);
1367 LVSymbol *
Member = getSymbolForSeenMD(DT);
1368 if (Member &&
Member->getIsFinalized())
1371 if (!
options().getPrintSymbols()) {
1373 getOrCreateType(DT->getBaseType());
1378 Member =
static_cast<LVSymbol *
>(getOrCreateType(Aggregate, DT));
1380 Member->setIsFinalized();
1381 addSourceLine(Member, DT);
1389LVScope *LVIRReader::getOrCreateSubprogram(
const DISubprogram *SP) {
1390 assert(SP &&
"Invalid metadata node.");
1392 dbgs() <<
"\n[getOrCreateSubprogram]\n";
1394 SP->dump(TheModule);
1397 LVScope *
Function = getScopeForSeenMD(SP);
1402 Function =
static_cast<LVScope *
>(constructElement(SP));
1407 LVScope *Parent =
SP->getDeclaration()
1408 ?
SP->isLocalToUnit() ||
SP->isDefinition()
1410 : getParentScope(SP)->getParentScope()
1411 : getParentScope(SP);
1418 getOrCreateSubprogram(
Function, SP, includeMinimalInlineScopes());
1426 const DISubprogram *SP,
1429 assert(SP &&
"Invalid metadata node.");
1431 dbgs() <<
"\n[getOrCreateSubprogram]\n";
1433 SP->dump(TheModule);
1441 if (
const DISubprogram *SPDecl =
SP->getDeclaration()) {
1444 getOrCreateSubprogram(SPDecl);
1449 for (
const MDNode *DN :
SP->getRetainedNodes()) {
1451 constructImportedEntity(
Function, IE);
1453 constructTemplateTypeParameter(
Function, TTP);
1455 constructTemplateValueParameter(
Function, TVP);
1457 getOrCreateVariable(GVE);
1460 applySubprogramAttributes(
Function, SP);
1463 if (
SP->isArtificial() &&
SP->isLocalToUnit() &&
SP->isDefinition() &&
1464 SP->getName().empty())
1471 const DITypeArray Args) {
1474 dbgs() <<
"\n[constructSubprogramArguments]\n";
1475 for (
unsigned i = 1,
N =
Args.size(); i <
N; ++i) {
1476 if (
const DIType *Ty = Args[i]) {
1478 Ty->
dump(TheModule);
1483 for (
unsigned I = 1,
N =
Args.size();
I <
N; ++
I) {
1484 const DIType *Ty =
Args[
I];
1488 LVElement *ParameterType = getOrCreateType(Ty);
1507void LVIRReader::constructSubrange(
LVScopeArray *Array,
const DISubrange *SR,
1509 assert(Array &&
"Invalid logical element");
1510 assert(SR &&
"Invalid metadata node.");
1512 dbgs() <<
"\n[constructSubrange]\n";
1514 SR->
dump(TheModule);
1521 static_cast<LVTypeSubrange *
>(constructElement(SR))) {
1532 Count = CI->getSExtValue();
1536 int64_t Lowerbound = getDefaultLowerBound();
1538 Lowerbound = (LI) ? LI->getSExtValue() : Lowerbound;
1539 Count = UI->getSExtValue() - Lowerbound + 1;
1547void LVIRReader::constructTemplateTypeParameter(
1548 LVElement *Element,
const DITemplateTypeParameter *TTP) {
1549 assert(Element &&
"Invalid logical element");
1550 assert(TTP &&
"Invalid metadata node.");
1552 dbgs() <<
"\n[constructTemplateTypeParameter]\n";
1554 TTP->
dump(TheModule);
1561 if (LVElement *Parameter = constructElement(TTP)) {
1564 LVScope *Parent =
static_cast<LVScope *
>(Element);
1567 Parent->setIsTemplate();
1570 if (
const DIType *Ty = TTP->
getType()) {
1571 LVElement *
Type = getElementForSeenMD(Ty);
1573 Type = getOrCreateType(Ty);
1580void LVIRReader::constructTemplateValueParameter(
1581 LVElement *Element,
const DITemplateValueParameter *TVP) {
1582 assert(Element &&
"Invalid logical element");
1583 assert(TVP &&
"Invalid metadata node.");
1585 dbgs() <<
"\n[constructTemplateValueParameter]\n";
1587 TVP->
dump(TheModule);
1594 if (LVElement *Parameter = constructElement(TVP)) {
1597 LVScope *Parent =
static_cast<LVScope *
>(Element);
1600 Parent->setIsTemplate();
1604 if (TVP->
getTag() == dwarf::DW_TAG_template_value_parameter) {
1605 LVElement *
Type = getOrCreateType(TVP->
getType());
1610 addConstantValue(Parameter, CI, TVP->
getType());
1612 addConstantValue(Parameter, CF);
1616 Parameter->setValue(
"Unable to describe global value");
1617 }
else if (TVP->
getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1621 }
else if (TVP->
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1634void LVIRReader::constructType(
LVScope *Scope,
const DICompositeType *CTy) {
1635 assert(Scope &&
"Invalid logical element");
1636 assert(CTy &&
"Invalid metadata node.");
1638 dbgs() <<
"\n[constructType]\n";
1640 CTy->
dump(TheModule);
1645 case dwarf::DW_TAG_array_type:
1646 constructArray(
static_cast<LVScopeArray *
>(Scope), CTy);
1648 case dwarf::DW_TAG_enumeration_type:
1649 constructEnum(
static_cast<LVScopeEnumeration *
>(Scope), CTy);
1652 case dwarf::DW_TAG_variant_part:
1653 case dwarf::DW_TAG_namelist:
1655 case dwarf::DW_TAG_structure_type:
1656 case dwarf::DW_TAG_union_type:
1657 case dwarf::DW_TAG_class_type: {
1658 constructAggregate(
static_cast<LVScopeAggregate *
>(Scope), CTy);
1665 if (
Tag == dwarf::DW_TAG_enumeration_type ||
1666 Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
1667 Tag == dwarf::DW_TAG_union_type) {
1673 addSourceLine(Scope, CTy);
1690void LVIRReader::constructType(
LVElement *Element,
const DIDerivedType *DT) {
1691 assert(Element &&
"Invalid logical element");
1692 assert(DT &&
"Invalid metadata node.");
1694 dbgs() <<
"\n[constructType]\n";
1696 DT->
dump(TheModule);
1701 if (DT->
getTag() != dwarf::DW_TAG_member)
1702 Element->setIsFinalized();
1704 LVElement *
BaseType = getOrCreateType(DT->getBaseType());
1709 addAccess(Element, DT->
getFlags());
1715 Element->setIsArtificial();
1719 addSourceLine(Element, DT);
1724 const DISubroutineType *SPTy) {
1726 assert(SPTy &&
"Invalid metadata node.");
1728 dbgs() <<
"\n[constructType]\n";
1730 SPTy->
dump(TheModule);
1741 LVElement *
ElementType = getOrCreateType(Args[0]);
1745 constructSubprogramArguments(
Function, Args);
1749LVScope *LVIRReader::getOrCreateNamespace(
const DINamespace *NS) {
1751 dbgs() <<
"\n[getOrCreateNamespace]\n";
1753 NS->
dump(TheModule);
1756 LVScope *
Scope = getOrCreateScope(NS);
1760 Scope->setName(
"(anonymous namespace)");
1769 dbgs() <<
"\n[getOrCreateScope]\n";
1770 dbgs() <<
"Context: ";
1779 Scope =
static_cast<LVScope *
>(constructElement(
Context));
1782 LVScope *Parent = getParentScope(
Context);
1797 dbgs() <<
"\n[getOrCreateType]\n";
1799 Ty->
dump(TheModule);
1803 LVElement *Element = getElementForSeenMD(Ty);
1807 Element = constructElement(Ty);
1810 LVScope *Parent =
Scope ?
Scope : getParentScope(Ty);
1814 Element->setIsFinalized();
1816 constructType(Element, DT);
1818 constructType(
static_cast<LVScope *
>(Element), CTy);
1820 constructType(
static_cast<LVScope *
>(Element), SPTy);
1829LVIRReader::getOrCreateVariable(
const DIGlobalVariableExpression *GVE) {
1830 assert(GVE &&
"Invalid metadata node.");
1832 dbgs() <<
"\n[getOrCreateVariable]\n";
1834 GVE->
dump(TheModule);
1837 const DIGlobalVariable *DIGV = GVE->
getVariable();
1838 LVSymbol *
Symbol = getSymbolForSeenMD(DIGV);
1840 Symbol = getOrCreateVariable(DIGV);
1844 Symbol->addLocation(dwarf::DW_AT_location, 0, -1,
1846 Symbol->addLocationOperands(dwarf::DW_OP_addrx, PoolAddressIndex++);
1848 addConstantValue(Symbol, DIExpr);
1854 const DILocation *
DL) {
1855 assert(OriginSymbol &&
"Invalid logical element");
1856 assert(
DL &&
"Invalid metadata node.");
1858 dbgs() <<
"\n[getOrCreateInlinedVariable]\n";
1863 const DILocation *InlinedAt =
DL->getInlinedAt();
1870 if (InlinedSymbol) {
1872 InlinedSymbol->setIsFinalized();
1878 getOrCreateSourceID(InlinedAt->getFile()));
1882 InlinedSymbol->setHasReferenceAbstract();
1884 if (OriginSymbol->getIsParameter())
1885 InlinedSymbol->setIsParameter();
1888 LVScope *InlinedScope = getOrCreateInlinedScope(
DL);
1889 assert(InlinedScope &&
"Invalid logical element");
1895 return InlinedSymbol;
1900LVSymbol *LVIRReader::getOrCreateVariable(
const DIVariable *Var,
1901 const DILocation *
DL) {
1902 assert(Var &&
"Invalid metadata node.");
1904 dbgs() <<
"\n[getOrCreateVariable]\n";
1906 Var->
dump(TheModule);
1915 const DILocation *InlinedAt =
DL ?
DL->getInlinedAt() :
nullptr;
1917 LVSymbol *
Symbol = getSymbolForSeenMD(Var);
1918 if (Symbol &&
Symbol->getIsFinalized() && !InlinedAt)
1921 if (!
options().getPrintSymbols()) {
1923 getOrCreateType(Var->
getType());
1925 if (MDTuple *TP = GV->getTemplateParams())
1926 addTemplateParams(Symbol, DINodeArray(TP));
1932 Symbol =
static_cast<LVSymbol *
>(constructElement(Var));
1933 if (Symbol && !
Symbol->getIsFinalized()) {
1934 Symbol->setIsFinalized();
1935 LVScope *Parent = getParentScope(Var);
1946 addSourceLine(Symbol, LV);
1947 if (LV->isParameter()) {
1948 Symbol->setIsParameter();
1949 if (LV->isArtificial())
1950 Symbol->setIsArtificial();
1954 if (useAllLinkageNames())
1959 LVSymbol *
Reference =
static_cast<LVSymbol *
>(getOrCreateType(GVDecl));
1962 Symbol->setHasReferenceSpecification();
1968 addSourceLine(Symbol, GV);
1972 addTemplateParams(Symbol, DINodeArray(TP));
1978 getOrCreateInlinedVariable(Symbol,
DL);
1990 dbgs() <<
"\nBegin all instructions: '" <<
SP->getName() <<
"'\n";
1991 for (Instruction &
I : *BB) {
1992 dbgs() <<
"I: '" <<
I <<
"'\n";
1993 for (DbgVariableRecord &DVR :
filterDbgVars(
I.getDbgRecordRange())) {
1995 DVR.getVariable()->dump(TheModule);
1997 if (
const auto *
DL =
2003 dbgs() <<
"End all instructions: '" <<
SP->getName() <<
"'\n\n";
2008void LVIRReader::processBasicBlocks(
Function &
F) {
2014 dbgs() <<
"\n[processBasicBlocks]\n";
2016 SP->dump(TheModule);
2020 bool AddUnspecifiedParameters =
false;
2021 if (
const DISubroutineType *SPTy =
SP->getType()) {
2023 unsigned N =
Args.size();
2025 const DIType *Ty =
Args[
N - 1];
2027 AddUnspecifiedParameters =
true;
2031 LVScope *
Scope = getOrCreateSubprogram(SP);
2036 auto HandleDbgVariable = [&](
auto *DbgVar) {
2038 dbgs() <<
"\n[HandleDbgVariable]\n";
2039 dbgs() <<
"DbgVar: ";
2043 DebugVariableAggregate DVA(DbgVar);
2044 if (!DbgValueRanges->hasVariableEntry(DVA)) {
2045 DbgValueRanges->addVariable(&
F, DVA);
2050 if (!DbgVar->isKillLocation())
2051 getOrCreateVariable(DbgVar->getVariable(), DbgVar->getDebugLoc().get());
2055 bool GenerateLineBeforePrologue =
true;
2056 for (BasicBlock &BB :
F) {
2059 for (Instruction &
I : BB) {
2062 if (
const auto *
DL =
2065 dbgs() <<
" Location: ";
2068 getOrCreateAbstractScope(
DL);
2071 for (DbgVariableRecord &DVR :
filterDbgVars(
I.getDbgRecordRange()))
2072 HandleDbgVariable(&DVR);
2074 if (
options().getPrintAnyLine())
2075 constructLine(Scope, SP,
I, GenerateLineBeforePrologue);
2084 GenerateLineBeforePrologue =
false;
2086 if (AddUnspecifiedParameters) {
2090 Scope->addElement(Parameter);
2095 for (
const DebugVariableAggregate &DVA : SeenVars) {
2097 DILocalVariable *LV =
const_cast<DILocalVariable *
>(DVA.getVariable());
2098 LVSymbol *
Symbol = getSymbolForSeenMD(LV);
2104 DIType *Ty = LV->getType();
2106 LV->dump(TheModule);
2107 Ty->
dump(TheModule);
2108 dbgs() <<
"Type size: " <<
Size <<
"\n";
2111 auto AddLocationOp = [&](
Value *
V,
bool IsMem) {
2112 uint64_t RegValue = ValueNameMap.addValue(V);
2114 Symbol->addLocationOperands(dwarf::DW_OP_bregx, {RegValue, 0});
2116 Symbol->addLocationOperands(dwarf::DW_OP_regx, RegValue);
2119 auto AddLocation = [&](DbgValueDef DV) {
2120 bool IsMem = DV.IsMemory;
2121 DIExpression *CanonicalExpr =
const_cast<DIExpression *
>(
2123 RawLocationWrapper
Locations(DV.Locations);
2124 for (DIExpression::ExprOperand ExprOp : CanonicalExpr->
expr_ops()) {
2126 AddLocationOp(
Locations.getVariableLocationOp(Arg.getIndex()), IsMem);
2128 if (ExprOp.getOp() > std::numeric_limits<uint8_t>::max())
2129 LLVM_DEBUG(
dbgs() <<
"Bad DWARF op: " << ExprOp.getOp() <<
"\n");
2130 uint8_t ShortOp = (uint8_t)ExprOp.getOp();
2131 Symbol->addLocationOperands(
2133 ArrayRef<uint64_t>(std::next(ExprOp.get()), ExprOp.getNumArgs()));
2138 if (DbgValueRanges->hasSingleLocEntry(DVA)) {
2139 DbgValueDef DV = DbgValueRanges->getSingleLoc(DVA);
2140 Symbol->addLocation(llvm::dwarf::DW_AT_location, 0,
2146 for (
const DbgRangeEntry &Entry :
2147 DbgValueRanges->getVariableRanges(DVA)) {
2152 Symbol->addLocation(llvm::dwarf::DW_AT_location, Start, End,
2154 DbgValueDef DV =
Entry.Value;
2166 W.startLine() <<
"\n";
2179 std::unique_ptr<Module> M =
2186 if (
options().getWarningAll())
2187 Err.print(
"",
outs());
2189 "Could not create IR module for: %s",
2193 TheModule = M.get();
2194 if (!TheModule->getNamedMetadata(
"llvm.dbg.cu")) {
2199 DwarfVersion = TheModule->getDwarfVersion();
2205 CU->dump(TheModule);
2211 const DIFile *File =
CU->getFile();
2213 CompileUnit->setCompilationDirectory(File->getDirectory());
2220 uint16_t LanguageName =
CU->getSourceLanguage().getName();
2223 setDefaultLowerBound(&SL);
2225 if (
options().getAttributeLanguage())
2228 if (
options().getAttributeProducer())
2234 getOrCreateVariable(GVE);
2240 for (
auto *ET :
CU->getEnumTypes())
2241 getOrCreateType(ET);
2245 for (
const auto *RT :
CU->getRetainedTypes()) {
2247 getOrCreateType(Ty);
2255 for (
const auto *IE :
CU->getImportedEntities())
2261 dbgs() <<
"\nFunctions\n";
2262 for (
Function &
F : M->getFunctionList())
2264 SP->dump(TheModule);
2267 for (
Function &
F : M->getFunctionList())
2268 processBasicBlocks(
F);
2271 resolveInlinedLexicalScopes();
2272 removeEmptyScopes();
2274 processLocationGaps();
2277 if (
options().getInternalIntegrity())
2280 TheModule =
nullptr;
2286 assert(Scope &&
"Invalid logical element");
2288 dbgs() <<
"\n[constructRange]\n";
2292 dbgs() <<
"Name: " << Scope->getName() <<
"\n";
2296 Scope->addObject(LowPC, HighPC);
2297 if (!Scope->getIsCompileUnit()) {
2299 if ((
options().getAttributePublics() ||
options().getPrintAnyLine()) &&
2300 Scope->getIsFunction() && !Scope->getIsInlinedFunction())
2313void LVIRReader::constructRange(
LVScope *Scope) {
2315 dbgs() <<
"\n[constructRange]\n";
2317 dbgs() <<
"Name: " <<
Scope->getName() <<
"\n\n";
2321 return Offset + OFFSET_INCREASE - 1;
2334 for (
const LVLine *
Line : *Lines) {
2351 Current =
Line->getAddress();
2352 if (Current == Previous) {
2356 if (Current ==
Upper + 1) {
2358 Upper = NextRange(Current);
2375void LVIRReader::removeEmptyScopes() {
2381 auto DeleteEmptyScopes = [&]() {
2382 if (EmptyScopes.empty())
2386 dbgs() <<
"\n** Collected empty scopes **\n";
2387 for (
auto Scope : EmptyScopes)
2391 LVScope *Parent =
nullptr;
2392 for (
auto Scope : EmptyScopes) {
2393 Parent =
Scope->getParentScope();
2395 dbgs() <<
"Scope: " <<
Scope->getID() <<
", ";
2396 dbgs() <<
"Parent: " << Parent->getID() <<
"\n";
2403 std::copy(Lines->begin(), Lines->end(), std::back_inserter(Pack));
2404 for (LVLine *
Line : Pack) {
2407 Line->resetParent();
2408 Parent->addElement(
Line);
2409 Line->updateLevel(Parent,
false);
2414 if (Parent->removeElement(Scope)) {
2417 for (LVScope *Child : *Scopes) {
2419 Child->resetParent();
2420 Parent->addElement(Child);
2421 Child->updateLevel(Parent,
false);
2431 std::function<void(LVScope *)> TraverseScope = [&](LVScope *Current) {
2432 auto IsEmpty = [](LVScope *
Scope) ->
bool {
2433 return !
Scope->getSymbols() && !
Scope->getTypes() && !
Scope->getRanges();
2436 if (
const LVScopes *Scopes = Current->getScopes()) {
2437 for (LVScope *Scope : *Scopes) {
2438 if (
Scope->getIsLexicalBlock() && IsEmpty(Scope))
2439 EmptyScopes.push_back(Scope);
2440 TraverseScope(Scope);
2446 bool InternalID =
options().getInternalID();
2455 dbgs() <<
"\nBefore - RemoveEmptyScopes\n";
2460 DeleteEmptyScopes();
2463 dbgs() <<
"\nAfter - RemoveEmptyScopes\n";
2470void LVIRReader::resolveInlinedLexicalScopes() {
2472 LLVM_DEBUG({ dumpInlinedInfo(
"Before",
false); });
2474 std::function<void(LVScope * Scope)> TraverseChildren = [&](LVScope *Parent) {
2476 dbgs() <<
"\nParent Scope: ";
2477 Parent->dumpCommon();
2481 LVList &ParentInlinedList = getInlinedList(Parent);
2484 auto CheckInlinedScope = [&](LVList &ScopeInlinedList) ->
bool {
2485 bool Matched =
true;
2486 for (
auto &InlinedScope : ScopeInlinedList) {
2488 dbgs() <<
"Inlined Scope: ";
2492 for (
auto &ParentInlinedScope : ParentInlinedList) {
2493 if (ParentInlinedScope != ParentScope) {
2499 dbgs() <<
"\nIncorrect parent scope\n";
2500 dbgs() <<
"ParentInlinedScope: ";
2501 ParentInlinedScope->dumpCommon();
2502 dbgs() <<
"ParentScope: ";
2503 ParentScope->dumpCommon();
2517 auto AdjustInlinedScope = [&](LVList &ScopeInlinedList) {
2518 assert(ScopeInlinedList.size() == ParentInlinedList.size() &&
2519 "Scope list do not have same number of items.");
2522 LVScope *CurrentParent =
nullptr;
2523 LVScope *TargetParent =
nullptr;
2524 LVScope *InlinedScope =
nullptr;
2525 auto ItInlined = ScopeInlinedList.begin();
2526 auto ItParent = ParentInlinedList.begin();
2527 while (ItInlined != ScopeInlinedList.end()) {
2528 TargetParent = *ItParent;
2529 InlinedScope = *ItInlined;
2533 dbgs() <<
"Target Parent: ";
2535 dbgs() <<
"Current Parent: ";
2536 CurrentParent->dumpCommon();
2537 dbgs() <<
"Inlined: ";
2542 if (CurrentParent->removeElement(InlinedScope)) {
2556 dbgs() <<
"\nOrigin Scope: ";
2557 Scope->dumpCommon();
2561 LVList &ScopeInlinedList = getInlinedList(Scope);
2562 if (!CheckInlinedScope(ScopeInlinedList)) {
2564 AdjustInlinedScope(ScopeInlinedList);
2566 TraverseChildren(Scope);
2573 for (
auto &Entry : InlinedList) {
2574 LVScope *OriginScope =
Entry.first;
2575 if (OriginScope->getIsFunction())
2576 TraverseChildren(OriginScope);
2579 LLVM_DEBUG({ dumpInlinedInfo(
"After",
false); });
2584void LVIRReader::checkScopes(
LVScope *Scope) {
2587 auto PrintElement = [](LVElement *Element) {
2590 size_t ID = Element->getID();
2591 const char *
Kind = Element->kind();
2592 StringRef
Name = Element->getName();
2593 uint32_t LineNumber = Element->getLineNumber();
2601 dbgs() <<
"Name: '" << std::string(
Name) <<
"' ";
2606 std::function<void(LVScope * Parent)> Traverse = [&](LVScope *Current) {
2609 if (!
Entry->getIsFinalized())
2610 PrintElement(Entry);
2613 for (LVElement *Element : Current->getChildren())
2616 if (Current->getScopes())
2617 for (LVScope *Scope : *Current->getScopes())
2628 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 scope_exit class, which executes user-defined cleanup logic at scope exit.
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.
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