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 DINode *DN :
SP->getRetainedNodes()) {
1452 constructImportedEntity(
Function, IE);
1454 constructTemplateTypeParameter(
Function, TTP);
1456 constructTemplateValueParameter(
Function, TVP);
1459 applySubprogramAttributes(
Function, SP);
1462 if (
SP->isArtificial() &&
SP->isLocalToUnit() &&
SP->isDefinition() &&
1463 SP->getName().empty())
1470 const DITypeArray Args) {
1473 dbgs() <<
"\n[constructSubprogramArguments]\n";
1474 for (
unsigned i = 1,
N =
Args.size(); i <
N; ++i) {
1475 if (
const DIType *Ty = Args[i]) {
1477 Ty->
dump(TheModule);
1482 for (
unsigned I = 1,
N =
Args.size();
I <
N; ++
I) {
1483 const DIType *Ty =
Args[
I];
1487 LVElement *ParameterType = getOrCreateType(Ty);
1506void LVIRReader::constructSubrange(
LVScopeArray *Array,
const DISubrange *SR,
1508 assert(Array &&
"Invalid logical element");
1509 assert(SR &&
"Invalid metadata node.");
1511 dbgs() <<
"\n[constructSubrange]\n";
1513 SR->
dump(TheModule);
1520 static_cast<LVTypeSubrange *
>(constructElement(SR))) {
1531 Count = CI->getSExtValue();
1535 int64_t Lowerbound = getDefaultLowerBound();
1537 Lowerbound = (LI) ? LI->getSExtValue() : Lowerbound;
1538 Count = UI->getSExtValue() - Lowerbound + 1;
1546void LVIRReader::constructTemplateTypeParameter(
1547 LVElement *Element,
const DITemplateTypeParameter *TTP) {
1548 assert(Element &&
"Invalid logical element");
1549 assert(TTP &&
"Invalid metadata node.");
1551 dbgs() <<
"\n[constructTemplateTypeParameter]\n";
1553 TTP->
dump(TheModule);
1560 if (LVElement *Parameter = constructElement(TTP)) {
1563 LVScope *Parent =
static_cast<LVScope *
>(Element);
1566 Parent->setIsTemplate();
1569 if (
const DIType *Ty = TTP->
getType()) {
1570 LVElement *
Type = getElementForSeenMD(Ty);
1572 Type = getOrCreateType(Ty);
1579void LVIRReader::constructTemplateValueParameter(
1580 LVElement *Element,
const DITemplateValueParameter *TVP) {
1581 assert(Element &&
"Invalid logical element");
1582 assert(TVP &&
"Invalid metadata node.");
1584 dbgs() <<
"\n[constructTemplateValueParameter]\n";
1586 TVP->
dump(TheModule);
1593 if (LVElement *Parameter = constructElement(TVP)) {
1596 LVScope *Parent =
static_cast<LVScope *
>(Element);
1599 Parent->setIsTemplate();
1603 if (TVP->
getTag() == dwarf::DW_TAG_template_value_parameter) {
1604 LVElement *
Type = getOrCreateType(TVP->
getType());
1609 addConstantValue(Parameter, CI, TVP->
getType());
1611 addConstantValue(Parameter, CF);
1615 Parameter->setValue(
"Unable to describe global value");
1616 }
else if (TVP->
getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1620 }
else if (TVP->
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1633void LVIRReader::constructType(
LVScope *Scope,
const DICompositeType *CTy) {
1634 assert(Scope &&
"Invalid logical element");
1635 assert(CTy &&
"Invalid metadata node.");
1637 dbgs() <<
"\n[constructType]\n";
1639 CTy->
dump(TheModule);
1644 case dwarf::DW_TAG_array_type:
1645 constructArray(
static_cast<LVScopeArray *
>(Scope), CTy);
1647 case dwarf::DW_TAG_enumeration_type:
1648 constructEnum(
static_cast<LVScopeEnumeration *
>(Scope), CTy);
1651 case dwarf::DW_TAG_variant_part:
1652 case dwarf::DW_TAG_namelist:
1654 case dwarf::DW_TAG_structure_type:
1655 case dwarf::DW_TAG_union_type:
1656 case dwarf::DW_TAG_class_type: {
1657 constructAggregate(
static_cast<LVScopeAggregate *
>(Scope), CTy);
1664 if (
Tag == dwarf::DW_TAG_enumeration_type ||
1665 Tag == dwarf::DW_TAG_class_type ||
Tag == dwarf::DW_TAG_structure_type ||
1666 Tag == dwarf::DW_TAG_union_type) {
1672 addSourceLine(Scope, CTy);
1689void LVIRReader::constructType(
LVElement *Element,
const DIDerivedType *DT) {
1690 assert(Element &&
"Invalid logical element");
1691 assert(DT &&
"Invalid metadata node.");
1693 dbgs() <<
"\n[constructType]\n";
1695 DT->
dump(TheModule);
1700 if (DT->
getTag() != dwarf::DW_TAG_member)
1701 Element->setIsFinalized();
1703 LVElement *
BaseType = getOrCreateType(DT->getBaseType());
1708 addAccess(Element, DT->
getFlags());
1714 Element->setIsArtificial();
1718 addSourceLine(Element, DT);
1723 const DISubroutineType *SPTy) {
1725 assert(SPTy &&
"Invalid metadata node.");
1727 dbgs() <<
"\n[constructType]\n";
1729 SPTy->
dump(TheModule);
1740 LVElement *
ElementType = getOrCreateType(Args[0]);
1744 constructSubprogramArguments(
Function, Args);
1748LVScope *LVIRReader::getOrCreateNamespace(
const DINamespace *NS) {
1750 dbgs() <<
"\n[getOrCreateNamespace]\n";
1752 NS->
dump(TheModule);
1755 LVScope *
Scope = getOrCreateScope(NS);
1759 Scope->setName(
"(anonymous namespace)");
1768 dbgs() <<
"\n[getOrCreateScope]\n";
1769 dbgs() <<
"Context: ";
1778 Scope =
static_cast<LVScope *
>(constructElement(
Context));
1781 LVScope *Parent = getParentScope(
Context);
1796 dbgs() <<
"\n[getOrCreateType]\n";
1798 Ty->
dump(TheModule);
1802 LVElement *Element = getElementForSeenMD(Ty);
1806 Element = constructElement(Ty);
1809 LVScope *Parent =
Scope ?
Scope : getParentScope(Ty);
1813 Element->setIsFinalized();
1815 constructType(Element, DT);
1817 constructType(
static_cast<LVScope *
>(Element), CTy);
1819 constructType(
static_cast<LVScope *
>(Element), SPTy);
1828LVIRReader::getOrCreateVariable(
const DIGlobalVariableExpression *GVE) {
1829 assert(GVE &&
"Invalid metadata node.");
1831 dbgs() <<
"\n[getOrCreateVariable]\n";
1833 GVE->
dump(TheModule);
1836 const DIGlobalVariable *DIGV = GVE->
getVariable();
1837 LVSymbol *
Symbol = getSymbolForSeenMD(DIGV);
1839 Symbol = getOrCreateVariable(DIGV);
1843 Symbol->addLocation(dwarf::DW_AT_location, 0, -1,
1845 Symbol->addLocationOperands(dwarf::DW_OP_addrx, PoolAddressIndex++);
1847 addConstantValue(Symbol, DIExpr);
1853 const DILocation *
DL) {
1854 assert(OriginSymbol &&
"Invalid logical element");
1855 assert(
DL &&
"Invalid metadata node.");
1857 dbgs() <<
"\n[getOrCreateInlinedVariable]\n";
1862 const DILocation *InlinedAt =
DL->getInlinedAt();
1869 if (InlinedSymbol) {
1871 InlinedSymbol->setIsFinalized();
1877 getOrCreateSourceID(InlinedAt->getFile()));
1881 InlinedSymbol->setHasReferenceAbstract();
1883 if (OriginSymbol->getIsParameter())
1884 InlinedSymbol->setIsParameter();
1887 LVScope *InlinedScope = getOrCreateInlinedScope(
DL);
1888 assert(InlinedScope &&
"Invalid logical element");
1894 return InlinedSymbol;
1899LVSymbol *LVIRReader::getOrCreateVariable(
const DIVariable *Var,
1900 const DILocation *
DL) {
1901 assert(Var &&
"Invalid metadata node.");
1903 dbgs() <<
"\n[getOrCreateVariable]\n";
1905 Var->
dump(TheModule);
1914 const DILocation *InlinedAt =
DL ?
DL->getInlinedAt() :
nullptr;
1916 LVSymbol *
Symbol = getSymbolForSeenMD(Var);
1917 if (Symbol &&
Symbol->getIsFinalized() && !InlinedAt)
1920 if (!
options().getPrintSymbols()) {
1922 getOrCreateType(Var->
getType());
1924 if (MDTuple *TP = GV->getTemplateParams())
1925 addTemplateParams(Symbol, DINodeArray(TP));
1931 Symbol =
static_cast<LVSymbol *
>(constructElement(Var));
1932 if (Symbol && !
Symbol->getIsFinalized()) {
1933 Symbol->setIsFinalized();
1934 LVScope *Parent = getParentScope(Var);
1945 addSourceLine(Symbol, LV);
1946 if (LV->isParameter()) {
1947 Symbol->setIsParameter();
1948 if (LV->isArtificial())
1949 Symbol->setIsArtificial();
1953 if (useAllLinkageNames())
1958 LVSymbol *
Reference =
static_cast<LVSymbol *
>(getOrCreateType(GVDecl));
1961 Symbol->setHasReferenceSpecification();
1967 addSourceLine(Symbol, GV);
1971 addTemplateParams(Symbol, DINodeArray(TP));
1977 getOrCreateInlinedVariable(Symbol,
DL);
1989 dbgs() <<
"\nBegin all instructions: '" <<
SP->getName() <<
"'\n";
1990 for (Instruction &
I : *BB) {
1991 dbgs() <<
"I: '" <<
I <<
"'\n";
1992 for (DbgVariableRecord &DVR :
filterDbgVars(
I.getDbgRecordRange())) {
1994 DVR.getVariable()->dump(TheModule);
1996 if (
const auto *
DL =
2002 dbgs() <<
"End all instructions: '" <<
SP->getName() <<
"'\n\n";
2007void LVIRReader::processBasicBlocks(
Function &
F) {
2013 dbgs() <<
"\n[processBasicBlocks]\n";
2015 SP->dump(TheModule);
2019 bool AddUnspecifiedParameters =
false;
2020 if (
const DISubroutineType *SPTy =
SP->getType()) {
2022 unsigned N =
Args.size();
2024 const DIType *Ty =
Args[
N - 1];
2026 AddUnspecifiedParameters =
true;
2030 LVScope *
Scope = getOrCreateSubprogram(SP);
2035 auto HandleDbgVariable = [&](
auto *DbgVar) {
2037 dbgs() <<
"\n[HandleDbgVariable]\n";
2038 dbgs() <<
"DbgVar: ";
2042 DebugVariableAggregate DVA(DbgVar);
2043 if (!DbgValueRanges->hasVariableEntry(DVA)) {
2044 DbgValueRanges->addVariable(&
F, DVA);
2049 if (!DbgVar->isKillLocation())
2050 getOrCreateVariable(DbgVar->getVariable(), DbgVar->getDebugLoc().get());
2054 bool GenerateLineBeforePrologue =
true;
2055 for (BasicBlock &BB :
F) {
2058 for (Instruction &
I : BB) {
2061 if (
const auto *
DL =
2064 dbgs() <<
" Location: ";
2067 getOrCreateAbstractScope(
DL);
2070 for (DbgVariableRecord &DVR :
filterDbgVars(
I.getDbgRecordRange()))
2071 HandleDbgVariable(&DVR);
2073 if (
options().getPrintAnyLine())
2074 constructLine(Scope, SP,
I, GenerateLineBeforePrologue);
2083 GenerateLineBeforePrologue =
false;
2085 if (AddUnspecifiedParameters) {
2089 Scope->addElement(Parameter);
2094 for (
const DebugVariableAggregate &DVA : SeenVars) {
2096 DILocalVariable *LV =
const_cast<DILocalVariable *
>(DVA.getVariable());
2097 LVSymbol *
Symbol = getSymbolForSeenMD(LV);
2103 DIType *Ty = LV->getType();
2105 LV->dump(TheModule);
2106 Ty->
dump(TheModule);
2107 dbgs() <<
"Type size: " <<
Size <<
"\n";
2110 auto AddLocationOp = [&](
Value *
V,
bool IsMem) {
2111 uint64_t RegValue = ValueNameMap.addValue(V);
2113 Symbol->addLocationOperands(dwarf::DW_OP_bregx, {RegValue, 0});
2115 Symbol->addLocationOperands(dwarf::DW_OP_regx, RegValue);
2118 auto AddLocation = [&](DbgValueDef DV) {
2119 bool IsMem = DV.IsMemory;
2120 DIExpression *CanonicalExpr =
const_cast<DIExpression *
>(
2122 RawLocationWrapper
Locations(DV.Locations);
2123 for (DIExpression::ExprOperand ExprOp : CanonicalExpr->
expr_ops()) {
2125 AddLocationOp(
Locations.getVariableLocationOp(ExprOp.getArg(0)),
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 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