41 #include "llvm/Config/llvm-config.h" 111 std::string &Filepath = FileToFilepathMap[
File];
112 if (!Filepath.empty())
119 if (!Dir.
empty() && Dir[0] ==
'/') {
121 if (Dir.
back() !=
'/')
123 Filepath += Filename;
131 if (Filename.find(
':') == 1)
134 Filepath = (Dir +
"\\" + Filename).str();
139 std::replace(Filepath.begin(), Filepath.end(),
'/',
'\\');
143 while ((Cursor = Filepath.find(
"\\.\\", Cursor)) != std::string::npos)
144 Filepath.erase(Cursor, 2);
149 while ((Cursor = Filepath.find(
"\\..\\", Cursor)) != std::string::npos) {
154 size_t PrevSlash = Filepath.rfind(
'\\', Cursor - 1);
155 if (PrevSlash == std::string::npos)
159 Filepath.erase(PrevSlash, Cursor + 3 - PrevSlash);
166 while ((Cursor = Filepath.find(
"\\\\", Cursor)) != std::string::npos)
167 Filepath.erase(Cursor, 1);
172 unsigned CodeViewDebug::maybeRecordFile(
const DIFile *
F) {
174 unsigned NextId = FileIdMap.size() + 1;
175 auto Insertion = FileIdMap.insert(std::make_pair(FullPath, NextId));
176 if (Insertion.second) {
180 if (F->getChecksum()) {
181 std::string Checksum =
fromHex(F->getChecksum()->Value);
183 memcpy(CKMem, Checksum.data(), Checksum.size());
185 reinterpret_cast<const uint8_t *
>(CKMem), Checksum.size());
186 switch (F->getChecksum()->Kind) {
192 static_cast<unsigned>(CSKind));
194 assert(Success &&
".cv_file directive failed");
196 return Insertion.first->second;
199 CodeViewDebug::InlineSite &
200 CodeViewDebug::getInlineSite(
const DILocation *InlinedAt,
202 auto SiteInsertion = CurFn->InlineSites.insert({InlinedAt, InlineSite()});
203 InlineSite *Site = &SiteInsertion.first->second;
204 if (SiteInsertion.second) {
205 unsigned ParentFuncId = CurFn->FuncId;
206 if (
const DILocation *OuterIA = InlinedAt->getInlinedAt())
208 getInlineSite(OuterIA, InlinedAt->getScope()->getSubprogram())
211 Site->SiteFuncId = NextFuncId++;
213 Site->SiteFuncId, ParentFuncId, maybeRecordFile(InlinedAt->getFile()),
214 InlinedAt->getLine(), InlinedAt->getColumn(),
SMLoc());
215 Site->Inlinee = Inlinee;
216 InlinedSubprograms.insert(Inlinee);
217 getFuncIdForSubprogram(Inlinee);
224 if (!ScopeName.
empty())
227 switch (Scope->
getTag()) {
228 case dwarf::DW_TAG_enumeration_type:
229 case dwarf::DW_TAG_class_type:
230 case dwarf::DW_TAG_structure_type:
231 case dwarf::DW_TAG_union_type:
232 return "<unnamed-tag>";
233 case dwarf::DW_TAG_namespace:
234 return "`anonymous namespace'";
243 while (Scope !=
nullptr) {
244 if (ClosestSubprogram ==
nullptr)
247 if (!ScopeName.empty())
248 QualifiedNameComponents.
push_back(ScopeName);
251 return ClosestSubprogram;
256 std::string FullyQualifiedName;
259 FullyQualifiedName.append(QualifiedNameComponent);
260 FullyQualifiedName.append(
"::");
262 FullyQualifiedName.append(TypeName);
263 return FullyQualifiedName;
277 if (CVD.TypeEmissionLevel == 1)
278 CVD.emitDeferredCompleteTypes();
279 --CVD.TypeEmissionLevel;
291 if (!Scope || isa<DIFile>(Scope))
294 assert(!isa<DIType>(Scope) &&
"shouldn't make a namespace scope for a type");
297 auto I = TypeIndices.find({Scope,
nullptr});
298 if (
I != TypeIndices.end())
304 auto TI = TypeTable.writeLeafType(SID);
305 return recordTypeIndexForDINode(Scope, TI);
312 auto I = TypeIndices.find({SP,
nullptr});
313 if (
I != TypeIndices.end())
322 if (
const auto *Class = dyn_cast_or_null<DICompositeType>(Scope)) {
326 TypeIndex ClassType = getTypeIndex(Class);
329 TI = TypeTable.writeLeafType(MFuncId);
332 TypeIndex ParentScope = getScopeIndex(Scope);
333 FuncIdRecord FuncId(ParentScope, getTypeIndex(SP->getType()), DisplayName);
334 TI = TypeTable.writeLeafType(FuncId);
337 return recordTypeIndexForDINode(SP, TI);
344 if (SP->getDeclaration())
345 SP = SP->getDeclaration();
346 assert(!SP->getDeclaration() &&
"should use declaration as key");
350 auto I = TypeIndices.find({SP, Class});
351 if (I != TypeIndices.end())
357 TypeLoweringScope S(*
this);
358 const bool IsStaticMethod = (SP->getFlags() & DINode::FlagStaticMember) != 0;
360 SP->getType(), Class, SP->getThisAdjustment(), IsStaticMethod);
361 return recordTypeIndexForDINode(SP, TI, Class);
367 auto InsertResult = TypeIndices.insert({{Node, ClassTy}, TI});
369 assert(InsertResult.second &&
"DINode was already assigned a type index");
373 unsigned CodeViewDebug::getPointerSizeInBytes() {
377 void CodeViewDebug::recordLocalVariable(LocalVariable &&Var,
382 InlineSite &Site = getInlineSite(InlinedAt, Inlinee);
383 Site.InlinedLocals.emplace_back(Var);
386 ScopeVariables[
LS].emplace_back(Var);
397 void CodeViewDebug::maybeRecordLocation(
const DebugLoc &DL,
409 if (LI.getStartLine() != DL.
getLine() || LI.isAlwaysStepInto() ||
410 LI.isNeverStepInto())
414 if (CI.getStartColumn() != DL.
getCol())
417 if (!CurFn->HaveLineInfo)
418 CurFn->HaveLineInfo =
true;
421 FileId = CurFn->LastFileId;
423 FileId = CurFn->LastFileId = maybeRecordFile(DL->getFile());
426 unsigned FuncId = CurFn->FuncId;
427 if (
const DILocation *SiteLoc = DL->getInlinedAt()) {
433 getInlineSite(SiteLoc, Loc->getScope()->getSubprogram()).SiteFuncId;
436 bool FirstLoc =
true;
437 while ((SiteLoc = Loc->getInlinedAt())) {
439 getInlineSite(SiteLoc, Loc->getScope()->getSubprogram());
448 OS.EmitCVLocDirective(FuncId, FileId, DL.
getLine(), DL.
getCol(),
450 DL->getFilename(),
SMLoc());
453 void CodeViewDebug::emitCodeViewMagicVersion() {
454 OS.EmitValueToAlignment(4);
455 OS.AddComment(
"Debug section magic");
472 switchToDebugSectionForSymbol(
nullptr);
474 MCSymbol *CompilerInfo = beginCVSubsection(DebugSubsectionKind::Symbols);
475 emitCompilerInformation();
476 endCVSubsection(CompilerInfo);
478 emitInlineeLinesSubsection();
481 for (
auto &
P : FnDebugInfo)
482 if (!
P.first->isDeclarationForLinker())
483 emitDebugInfoForFunction(
P.first, *
P.second);
486 setCurrentSubprogram(
nullptr);
487 emitDebugInfoForGlobals();
490 emitDebugInfoForRetainedTypes();
494 switchToDebugSectionForSymbol(
nullptr);
497 if (!GlobalUDTs.empty()) {
498 MCSymbol *SymbolsEnd = beginCVSubsection(DebugSubsectionKind::Symbols);
499 emitDebugInfoForUDTs(GlobalUDTs);
500 endCVSubsection(SymbolsEnd);
504 OS.AddComment(
"File index to string table offset subsection");
505 OS.EmitCVFileChecksumsDirective();
508 OS.AddComment(
"String table");
509 OS.EmitCVStringTableDirective();
513 emitTypeInformation();
516 emitTypeGlobalHashes();
522 unsigned MaxFixedRecordLength = 0xF00) {
533 void CodeViewDebug::emitTypeInformation() {
534 if (TypeTable.empty())
539 emitCodeViewMagicVersion();
542 if (OS.isVerboseAsm()) {
543 CommentPrefix +=
'\t';
545 CommentPrefix +=
' ';
554 if (OS.isVerboseAsm()) {
573 OS.EmitBinaryData(Record.
str_data());
574 B = Table.getNext(*B);
578 void CodeViewDebug::emitTypeGlobalHashes() {
579 if (TypeTable.empty())
586 OS.EmitValueToAlignment(4);
587 OS.AddComment(
"Magic");
589 OS.AddComment(
"Section Version");
590 OS.EmitIntValue(0, 2);
591 OS.AddComment(
"Hash Algorithm");
592 OS.EmitIntValue(uint16_t(GlobalTypeHashAlg::SHA1_8), 2);
594 TypeIndex TI(TypeIndex::FirstNonSimpleIndex);
595 for (
const auto &GHR : TypeTable.hashes()) {
596 if (OS.isVerboseAsm()) {
602 OS.AddComment(Comment);
605 assert(GHR.Hash.size() == 8);
606 StringRef S(reinterpret_cast<const char *>(GHR.Hash.data()),
608 OS.EmitBinaryData(S);
614 case dwarf::DW_LANG_C:
615 case dwarf::DW_LANG_C89:
616 case dwarf::DW_LANG_C99:
617 case dwarf::DW_LANG_C11:
618 case dwarf::DW_LANG_ObjC:
620 case dwarf::DW_LANG_C_plus_plus:
621 case dwarf::DW_LANG_C_plus_plus_03:
622 case dwarf::DW_LANG_C_plus_plus_11:
623 case dwarf::DW_LANG_C_plus_plus_14:
625 case dwarf::DW_LANG_Fortran77:
626 case dwarf::DW_LANG_Fortran90:
627 case dwarf::DW_LANG_Fortran03:
628 case dwarf::DW_LANG_Fortran08:
630 case dwarf::DW_LANG_Pascal83:
631 return SourceLanguage::Pascal;
632 case dwarf::DW_LANG_Cobol74:
633 case dwarf::DW_LANG_Cobol85:
635 case dwarf::DW_LANG_Java:
637 case dwarf::DW_LANG_D:
658 for (
const char C : Name) {
661 V.Part[
N] +=
C -
'0';
662 }
else if (
C ==
'.') {
674 case Triple::ArchType::x86:
675 return CPUType::Pentium3;
676 case Triple::ArchType::x86_64:
678 case Triple::ArchType::thumb:
679 return CPUType::Thumb;
680 case Triple::ArchType::aarch64:
681 return CPUType::ARM64;
687 void CodeViewDebug::emitCompilerInformation() {
691 OS.AddComment(
"Record length");
692 OS.emitAbsoluteSymbolDiff(CompilerEnd, CompilerBegin, 2);
693 OS.EmitLabel(CompilerBegin);
694 OS.AddComment(
"Record kind: S_COMPILE3");
695 OS.EmitIntValue(SymbolKind::S_COMPILE3, 2);
700 const auto *
CU = cast<DICompileUnit>(Node);
706 OS.AddComment(
"Flags and language");
707 OS.EmitIntValue(Flags, 4);
709 OS.AddComment(
"CPUType");
712 OS.EmitIntValue(static_cast<uint64_t>(CPU), 2);
716 OS.AddComment(
"Frontend version");
717 for (
int N = 0;
N < 4; ++
N)
718 OS.EmitIntValue(FrontVer.Part[
N], 2);
723 int Major = 1000 * LLVM_VERSION_MAJOR +
724 10 * LLVM_VERSION_MINOR +
728 Version BackVer = {{ Major, 0, 0, 0 }};
729 OS.AddComment(
"Backend version");
730 for (
int N = 0;
N < 4; ++
N)
731 OS.EmitIntValue(BackVer.Part[
N], 2);
733 OS.AddComment(
"Null-terminated compiler version string");
736 OS.EmitLabel(CompilerEnd);
739 void CodeViewDebug::emitInlineeLinesSubsection() {
740 if (InlinedSubprograms.empty())
743 OS.AddComment(
"Inlinee lines subsection");
744 MCSymbol *InlineEnd = beginCVSubsection(DebugSubsectionKind::InlineeLines);
750 OS.AddComment(
"Inlinee lines signature");
751 OS.EmitIntValue(
unsigned(InlineeLinesSignature::Normal), 4);
754 assert(TypeIndices.count({SP, nullptr}));
755 TypeIndex InlineeIdx = TypeIndices[{SP,
nullptr}];
758 unsigned FileId = maybeRecordFile(SP->
getFile());
759 OS.AddComment(
"Inlined function " + SP->
getName() +
" starts at " +
762 OS.AddComment(
"Type index of inlined function");
763 OS.EmitIntValue(InlineeIdx.getIndex(), 4);
764 OS.AddComment(
"Offset into filechecksum table");
765 OS.EmitCVFileChecksumOffsetDirective(FileId);
766 OS.AddComment(
"Starting line number");
767 OS.EmitIntValue(SP->getLine(), 4);
770 endCVSubsection(InlineEnd);
773 void CodeViewDebug::emitInlinedCallSite(
const FunctionInfo &FI,
775 const InlineSite &Site) {
779 assert(TypeIndices.count({Site.Inlinee, nullptr}));
780 TypeIndex InlineeIdx = TypeIndices[{Site.Inlinee,
nullptr}];
783 OS.AddComment(
"Record length");
784 OS.emitAbsoluteSymbolDiff(InlineEnd, InlineBegin, 2);
785 OS.EmitLabel(InlineBegin);
786 OS.AddComment(
"Record kind: S_INLINESITE");
787 OS.EmitIntValue(SymbolKind::S_INLINESITE, 2);
789 OS.AddComment(
"PtrParent");
790 OS.EmitIntValue(0, 4);
791 OS.AddComment(
"PtrEnd");
792 OS.EmitIntValue(0, 4);
793 OS.AddComment(
"Inlinee type index");
794 OS.EmitIntValue(InlineeIdx.getIndex(), 4);
796 unsigned FileId = maybeRecordFile(Site.Inlinee->getFile());
797 unsigned StartLineNum = Site.Inlinee->getLine();
799 OS.EmitCVInlineLinetableDirective(Site.SiteFuncId, FileId, StartLineNum,
802 OS.EmitLabel(InlineEnd);
804 emitLocalVariableList(Site.InlinedLocals);
807 for (
const DILocation *ChildSite : Site.ChildSites) {
808 auto I = FI.InlineSites.find(ChildSite);
809 assert(
I != FI.InlineSites.end() &&
810 "child site not in function inline site map");
811 emitInlinedCallSite(FI, ChildSite,
I->second);
815 OS.AddComment(
"Record length");
816 OS.EmitIntValue(2, 2);
817 OS.AddComment(
"Record kind: S_INLINESITE_END");
818 OS.EmitIntValue(SymbolKind::S_INLINESITE_END, 2);
821 void CodeViewDebug::switchToDebugSectionForSymbol(
const MCSymbol *GVSym) {
831 DebugSec = OS.getContext().getAssociativeCOFFSection(DebugSec, KeySym);
833 OS.SwitchSection(DebugSec);
837 if (ComdatDebugSections.insert(DebugSec).second)
838 emitCodeViewMagicVersion();
843 void CodeViewDebug::emitDebugInfoForThunk(
const Function *GV,
849 OS.AddComment(
"Symbol subsection for " +
Twine(FuncName));
850 MCSymbol *SymbolsEnd = beginCVSubsection(DebugSubsectionKind::Symbols);
855 OS.AddComment(
"Record length");
856 OS.emitAbsoluteSymbolDiff(ThunkRecordEnd, ThunkRecordBegin, 2);
857 OS.EmitLabel(ThunkRecordBegin);
858 OS.AddComment(
"Record kind: S_THUNK32");
859 OS.EmitIntValue(
unsigned(SymbolKind::S_THUNK32), 2);
860 OS.AddComment(
"PtrParent");
861 OS.EmitIntValue(0, 4);
862 OS.AddComment(
"PtrEnd");
863 OS.EmitIntValue(0, 4);
864 OS.AddComment(
"PtrNext");
865 OS.EmitIntValue(0, 4);
866 OS.AddComment(
"Thunk section relative address");
867 OS.EmitCOFFSecRel32(Fn, 0);
868 OS.AddComment(
"Thunk section index");
869 OS.EmitCOFFSectionIndex(Fn);
870 OS.AddComment(
"Code size");
871 OS.emitAbsoluteSymbolDiff(FI.End, Fn, 2);
872 OS.AddComment(
"Ordinal");
873 OS.EmitIntValue(
unsigned(ordinal), 1);
874 OS.AddComment(
"Function name");
877 OS.EmitLabel(ThunkRecordEnd);
883 const unsigned RecordLengthForSymbolEnd = 2;
884 OS.AddComment(
"Record length");
885 OS.EmitIntValue(RecordLengthForSymbolEnd, 2);
886 OS.AddComment(
"Record kind: S_PROC_ID_END");
887 OS.EmitIntValue(
unsigned(SymbolKind::S_PROC_ID_END), 2);
889 endCVSubsection(SymbolsEnd);
892 void CodeViewDebug::emitDebugInfoForFunction(
const Function *GV,
900 switchToDebugSectionForSymbol(Fn);
902 std::string FuncName;
905 setCurrentSubprogram(SP);
908 emitDebugInfoForThunk(GV, FI, Fn);
919 if (FuncName.empty())
924 OS.EmitCVFPOData(Fn);
927 OS.AddComment(
"Symbol subsection for " +
Twine(FuncName));
928 MCSymbol *SymbolsEnd = beginCVSubsection(DebugSubsectionKind::Symbols);
932 OS.AddComment(
"Record length");
933 OS.emitAbsoluteSymbolDiff(ProcRecordEnd, ProcRecordBegin, 2);
934 OS.EmitLabel(ProcRecordBegin);
937 OS.AddComment(
"Record kind: S_LPROC32_ID");
938 OS.EmitIntValue(
unsigned(SymbolKind::S_LPROC32_ID), 2);
940 OS.AddComment(
"Record kind: S_GPROC32_ID");
941 OS.EmitIntValue(
unsigned(SymbolKind::S_GPROC32_ID), 2);
945 OS.AddComment(
"PtrParent");
946 OS.EmitIntValue(0, 4);
947 OS.AddComment(
"PtrEnd");
948 OS.EmitIntValue(0, 4);
949 OS.AddComment(
"PtrNext");
950 OS.EmitIntValue(0, 4);
953 OS.AddComment(
"Code size");
954 OS.emitAbsoluteSymbolDiff(FI.End, Fn, 4);
955 OS.AddComment(
"Offset after prologue");
956 OS.EmitIntValue(0, 4);
957 OS.AddComment(
"Offset before epilogue");
958 OS.EmitIntValue(0, 4);
959 OS.AddComment(
"Function type index");
960 OS.EmitIntValue(getFuncIdForSubprogram(GV->
getSubprogram()).getIndex(), 4);
961 OS.AddComment(
"Function section relative address");
962 OS.EmitCOFFSecRel32(Fn, 0);
963 OS.AddComment(
"Function section index");
964 OS.EmitCOFFSectionIndex(Fn);
965 OS.AddComment(
"Flags");
966 OS.EmitIntValue(0, 1);
968 OS.AddComment(
"Function name");
971 OS.EmitLabel(ProcRecordEnd);
973 emitLocalVariableList(FI.Locals);
974 emitLexicalBlockList(FI.ChildBlocks, FI);
979 for (
const DILocation *InlinedAt : FI.ChildSites) {
980 auto I = FI.InlineSites.find(InlinedAt);
981 assert(
I != FI.InlineSites.end() &&
982 "child site not in function inline site map");
983 emitInlinedCallSite(FI, InlinedAt,
I->second);
986 for (
auto Annot : FI.Annotations) {
988 MDTuple *Strs = cast<MDTuple>(Annot.second);
991 OS.AddComment(
"Record length");
992 OS.emitAbsoluteSymbolDiff(AnnotEnd, AnnotBegin, 2);
993 OS.EmitLabel(AnnotBegin);
994 OS.AddComment(
"Record kind: S_ANNOTATION");
995 OS.EmitIntValue(SymbolKind::S_ANNOTATION, 2);
996 OS.EmitCOFFSecRel32(Label, 0);
998 OS.EmitCOFFSectionIndex(Label);
1003 StringRef Str = cast<MDString>(MD)->getString();
1004 assert(Str.
data()[Str.
size()] ==
'\0' &&
"non-nullterminated MDString");
1007 OS.EmitLabel(AnnotEnd);
1011 emitDebugInfoForUDTs(LocalUDTs);
1014 OS.AddComment(
"Record length");
1015 OS.EmitIntValue(0x0002, 2);
1016 OS.AddComment(
"Record kind: S_PROC_ID_END");
1017 OS.EmitIntValue(
unsigned(SymbolKind::S_PROC_ID_END), 2);
1019 endCVSubsection(SymbolsEnd);
1022 OS.EmitCVLinetableDirective(FI.FuncId, Fn, FI.End);
1025 CodeViewDebug::LocalVarDefRange
1026 CodeViewDebug::createDefRangeMem(uint16_t CVRegister,
int Offset) {
1027 LocalVarDefRange DR;
1030 assert(DR.DataOffset == Offset &&
"truncation");
1032 DR.StructOffset = 0;
1033 DR.CVRegister = CVRegister;
1037 CodeViewDebug::LocalVarDefRange
1038 CodeViewDebug::createDefRangeGeneral(uint16_t CVRegister,
bool InMemory,
1039 int Offset,
bool IsSubfield,
1040 uint16_t StructOffset) {
1041 LocalVarDefRange DR;
1042 DR.InMemory = InMemory;
1044 DR.IsSubfield = IsSubfield;
1045 DR.StructOffset = StructOffset;
1046 DR.CVRegister = CVRegister;
1050 void CodeViewDebug::collectVariableInfoFromMFTable(
1060 assert(
VI.Var->isValidLocationForIntrinsic(
VI.Loc) &&
1061 "Expected inlined-at fields to agree");
1063 Processed.
insert(InlinedVariable(
VI.Var,
VI.Loc->getInlinedAt()));
1072 int64_t ExprOffset = 0;
1074 if (!
VI.Expr->extractIfOffset(ExprOffset))
1078 unsigned FrameReg = 0;
1083 LocalVarDefRange DefRange =
1084 createDefRangeMem(CVReg, FrameOffset + ExprOffset);
1089 DefRange.Ranges.emplace_back(Begin, End);
1094 Var.DefRanges.emplace_back(std::move(DefRange));
1095 recordLocalVariable(std::move(Var), Scope);
1107 void CodeViewDebug::calculateRanges(
1112 for (
auto I = Ranges.
begin(),
E = Ranges.
end();
I !=
E; ++
I) {
1130 if (Var.UseReferenceType) {
1133 Location->LoadChain.pop_back();
1139 Var.UseReferenceType =
true;
1140 Var.DefRanges.clear();
1141 calculateRanges(Var, Ranges);
1146 if (Location->Register == 0 || Location->LoadChain.size() > 1)
1149 LocalVarDefRange DR;
1151 DR.InMemory = !Location->LoadChain.empty();
1153 !Location->LoadChain.empty() ? Location->LoadChain.back() : 0;
1154 if (Location->FragmentInfo) {
1155 DR.IsSubfield =
true;
1156 DR.StructOffset = Location->FragmentInfo->OffsetInBits / 8;
1158 DR.IsSubfield =
false;
1159 DR.StructOffset = 0;
1162 if (Var.DefRanges.empty() ||
1163 Var.DefRanges.back().isDifferentLocation(DR)) {
1164 Var.DefRanges.emplace_back(std::move(DR));
1174 auto J = std::next(
I);
1188 Var.DefRanges.back().Ranges;
1189 if (!R.
empty() && R.
back().second == Begin)
1190 R.
back().second = End;
1198 void CodeViewDebug::collectVariableInfo(
const DISubprogram *SP) {
1201 collectVariableInfoFromMFTable(Processed);
1204 InlinedVariable IV =
I.first;
1205 if (Processed.
count(IV))
1211 const auto &Ranges =
I.second;
1225 calculateRanges(Var, Ranges);
1226 recordLocalVariable(std::move(Var), Scope);
1232 auto Insertion = FnDebugInfo.insert({&GV, llvm::make_unique<FunctionInfo>()});
1233 assert(Insertion.second &&
"function already has info");
1234 CurFn = Insertion.first->second.get();
1235 CurFn->FuncId = NextFuncId++;
1238 OS.EmitCVFuncIdDirective(CurFn->FuncId);
1245 bool EmptyPrologue =
true;
1246 for (
const auto &MBB : *MF) {
1247 for (
const auto &
MI : MBB) {
1250 PrologEndLoc =
MI.getDebugLoc();
1252 }
else if (!
MI.isMetaInstruction()) {
1253 EmptyPrologue =
false;
1259 if (PrologEndLoc && !EmptyPrologue) {
1261 maybeRecordLocation(FnStartDL, MF);
1270 if (T->
getTag() == dwarf::DW_TAG_typedef) {
1272 switch (Scope->
getTag()) {
1273 case dwarf::DW_TAG_structure_type:
1274 case dwarf::DW_TAG_class_type:
1275 case dwarf::DW_TAG_union_type:
1288 T = DT->getBaseType().
resolve();
1293 void CodeViewDebug::addToUDTs(
const DIType *Ty) {
1304 std::string FullyQualifiedName =
1307 if (ClosestSubprogram ==
nullptr) {
1308 GlobalUDTs.emplace_back(std::move(FullyQualifiedName), Ty);
1309 }
else if (ClosestSubprogram == CurrentSubprogram) {
1310 LocalUDTs.emplace_back(std::move(FullyQualifiedName), Ty);
1324 case dwarf::DW_TAG_array_type:
1325 return lowerTypeArray(cast<DICompositeType>(Ty));
1326 case dwarf::DW_TAG_typedef:
1327 return lowerTypeAlias(cast<DIDerivedType>(Ty));
1328 case dwarf::DW_TAG_base_type:
1329 return lowerTypeBasic(cast<DIBasicType>(Ty));
1330 case dwarf::DW_TAG_pointer_type:
1331 if (cast<DIDerivedType>(Ty)->
getName() ==
"__vtbl_ptr_type")
1332 return lowerTypeVFTableShape(cast<DIDerivedType>(Ty));
1334 case dwarf::DW_TAG_reference_type:
1335 case dwarf::DW_TAG_rvalue_reference_type:
1336 return lowerTypePointer(cast<DIDerivedType>(Ty));
1337 case dwarf::DW_TAG_ptr_to_member_type:
1338 return lowerTypeMemberPointer(cast<DIDerivedType>(Ty));
1339 case dwarf::DW_TAG_restrict_type:
1340 case dwarf::DW_TAG_const_type:
1341 case dwarf::DW_TAG_volatile_type:
1343 return lowerTypeModifier(cast<DIDerivedType>(Ty));
1344 case dwarf::DW_TAG_subroutine_type:
1348 return lowerTypeMemberFunction(cast<DISubroutineType>(Ty), ClassTy,
1352 return lowerTypeFunction(cast<DISubroutineType>(Ty));
1353 case dwarf::DW_TAG_enumeration_type:
1354 return lowerTypeEnum(cast<DICompositeType>(Ty));
1355 case dwarf::DW_TAG_class_type:
1356 case dwarf::DW_TAG_structure_type:
1357 return lowerTypeClass(cast<DICompositeType>(Ty));
1358 case dwarf::DW_TAG_union_type:
1359 return lowerTypeUnion(cast<DICompositeType>(Ty));
1360 case dwarf::DW_TAG_unspecified_type:
1369 DITypeRef UnderlyingTypeRef = Ty->getBaseType();
1370 TypeIndex UnderlyingTypeIndex = getTypeIndex(UnderlyingTypeRef);
1375 if (UnderlyingTypeIndex ==
TypeIndex(SimpleTypeKind::Int32Long) &&
1376 TypeName ==
"HRESULT")
1377 return TypeIndex(SimpleTypeKind::HResult);
1378 if (UnderlyingTypeIndex ==
TypeIndex(SimpleTypeKind::UInt16Short) &&
1379 TypeName ==
"wchar_t")
1380 return TypeIndex(SimpleTypeKind::WideCharacter);
1382 return UnderlyingTypeIndex;
1387 TypeIndex ElementTypeIndex = getTypeIndex(ElementTypeRef);
1389 TypeIndex IndexType = getPointerSizeInBytes() == 8
1391 :
TypeIndex(SimpleTypeKind::UInt32Long);
1397 for (
int i = Elements.size() - 1; i >= 0; --i) {
1398 const DINode *Element = Elements[i];
1399 assert(Element->
getTag() == dwarf::DW_TAG_subrange_type);
1401 const DISubrange *Subrange = cast<DISubrange>(Element);
1402 assert(Subrange->getLowerBound() == 0 &&
1403 "codeview doesn't support subranges with lower bounds");
1405 if (
auto *CI = Subrange->getCount().dyn_cast<
ConstantInt*>())
1406 Count = CI->getSExtValue();
1416 ElementSize *= Count;
1420 uint64_t ArraySize =
1421 (i == 0 && ElementSize == 0) ? Ty->
getSizeInBits() / 8 : ElementSize;
1424 ArrayRecord AR(ElementTypeIndex, IndexType, ArraySize, Name);
1425 ElementTypeIndex = TypeTable.writeLeafType(AR);
1428 return ElementTypeIndex;
1441 case dwarf::DW_ATE_address:
1444 case dwarf::DW_ATE_boolean:
1446 case 1: STK = SimpleTypeKind::Boolean8;
break;
1447 case 2: STK = SimpleTypeKind::Boolean16;
break;
1448 case 4: STK = SimpleTypeKind::Boolean32;
break;
1449 case 8: STK = SimpleTypeKind::Boolean64;
break;
1450 case 16: STK = SimpleTypeKind::Boolean128;
break;
1453 case dwarf::DW_ATE_complex_float:
1455 case 2: STK = SimpleTypeKind::Complex16;
break;
1456 case 4: STK = SimpleTypeKind::Complex32;
break;
1457 case 8: STK = SimpleTypeKind::Complex64;
break;
1458 case 10: STK = SimpleTypeKind::Complex80;
break;
1459 case 16: STK = SimpleTypeKind::Complex128;
break;
1462 case dwarf::DW_ATE_float:
1464 case 2: STK = SimpleTypeKind::Float16;
break;
1465 case 4: STK = SimpleTypeKind::Float32;
break;
1466 case 6: STK = SimpleTypeKind::Float48;
break;
1467 case 8: STK = SimpleTypeKind::Float64;
break;
1468 case 10: STK = SimpleTypeKind::Float80;
break;
1469 case 16: STK = SimpleTypeKind::Float128;
break;
1472 case dwarf::DW_ATE_signed:
1474 case 1: STK = SimpleTypeKind::SignedCharacter;
break;
1475 case 2: STK = SimpleTypeKind::Int16Short;
break;
1477 case 8: STK = SimpleTypeKind::Int64Quad;
break;
1478 case 16: STK = SimpleTypeKind::Int128Oct;
break;
1481 case dwarf::DW_ATE_unsigned:
1483 case 1: STK = SimpleTypeKind::UnsignedCharacter;
break;
1484 case 2: STK = SimpleTypeKind::UInt16Short;
break;
1486 case 8: STK = SimpleTypeKind::UInt64Quad;
break;
1487 case 16: STK = SimpleTypeKind::UInt128Oct;
break;
1490 case dwarf::DW_ATE_UTF:
1492 case 2: STK = SimpleTypeKind::Character16;
break;
1493 case 4: STK = SimpleTypeKind::Character32;
break;
1496 case dwarf::DW_ATE_signed_char:
1498 STK = SimpleTypeKind::SignedCharacter;
1500 case dwarf::DW_ATE_unsigned_char:
1502 STK = SimpleTypeKind::UnsignedCharacter;
1510 STK = SimpleTypeKind::Int32Long;
1512 STK = SimpleTypeKind::UInt32Long;
1513 if (STK == SimpleTypeKind::UInt16Short &&
1515 STK = SimpleTypeKind::WideCharacter;
1516 if ((STK == SimpleTypeKind::SignedCharacter ||
1517 STK == SimpleTypeKind::UnsignedCharacter) &&
1519 STK = SimpleTypeKind::NarrowCharacter;
1526 TypeIndex PointeeTI = getTypeIndex(Ty->getBaseType());
1532 Ty->
getTag() == dwarf::DW_TAG_pointer_type) {
1534 ? SimpleTypeMode::NearPointer64
1535 : SimpleTypeMode::NearPointer32;
1540 Ty->
getSizeInBits() == 64 ? PointerKind::Near64 : PointerKind::Near32;
1544 case dwarf::DW_TAG_pointer_type:
1545 PM = PointerMode::Pointer;
1547 case dwarf::DW_TAG_reference_type:
1548 PM = PointerMode::LValueReference;
1550 case dwarf::DW_TAG_rvalue_reference_type:
1551 PM = PointerMode::RValueReference;
1556 return TypeTable.writeLeafType(PR);
1568 : PointerToMemberRepresentation::GeneralFunction;
1569 case DINode::FlagSingleInheritance:
1570 return PointerToMemberRepresentation::SingleInheritanceFunction;
1571 case DINode::FlagMultipleInheritance:
1572 return PointerToMemberRepresentation::MultipleInheritanceFunction;
1573 case DINode::FlagVirtualInheritance:
1574 return PointerToMemberRepresentation::VirtualInheritanceFunction;
1580 : PointerToMemberRepresentation::GeneralData;
1581 case DINode::FlagSingleInheritance:
1582 return PointerToMemberRepresentation::SingleInheritanceData;
1583 case DINode::FlagMultipleInheritance:
1584 return PointerToMemberRepresentation::MultipleInheritanceData;
1585 case DINode::FlagVirtualInheritance:
1586 return PointerToMemberRepresentation::VirtualInheritanceData;
1594 assert(Ty->
getTag() == dwarf::DW_TAG_ptr_to_member_type);
1595 TypeIndex ClassTI = getTypeIndex(Ty->getClassType());
1596 TypeIndex PointeeTI = getTypeIndex(Ty->getBaseType(), Ty->getClassType());
1597 PointerKind PK = getPointerSizeInBytes() == 8 ? PointerKind::Near64
1598 : PointerKind::Near32;
1599 bool IsPMF = isa<DISubroutineType>(Ty->getBaseType());
1600 PointerMode PM = IsPMF ? PointerMode::PointerToMemberFunction
1601 : PointerMode::PointerToDataMember;
1608 return TypeTable.writeLeafType(PR);
1615 case dwarf::DW_CC_normal:
return CallingConvention::NearC;
1616 case dwarf::DW_CC_BORLAND_msfastcall:
return CallingConvention::NearFast;
1617 case dwarf::DW_CC_BORLAND_thiscall:
return CallingConvention::ThisCall;
1618 case dwarf::DW_CC_BORLAND_stdcall:
return CallingConvention::NearStdCall;
1619 case dwarf::DW_CC_BORLAND_pascal:
return CallingConvention::NearPascal;
1620 case dwarf::DW_CC_LLVM_vectorcall:
return CallingConvention::NearVector;
1622 return CallingConvention::NearC;
1628 bool IsModifier =
true;
1629 const DIType *BaseTy = Ty;
1630 while (IsModifier && BaseTy) {
1632 switch (BaseTy->
getTag()) {
1633 case dwarf::DW_TAG_const_type:
1634 Mods |= ModifierOptions::Const;
1635 PO |= PointerOptions::Const;
1637 case dwarf::DW_TAG_volatile_type:
1638 Mods |= ModifierOptions::Volatile;
1639 PO |= PointerOptions::Volatile;
1641 case dwarf::DW_TAG_restrict_type:
1644 PO |= PointerOptions::Restrict;
1651 BaseTy = cast<DIDerivedType>(BaseTy)->
getBaseType().resolve();
1659 switch (BaseTy->
getTag()) {
1660 case dwarf::DW_TAG_pointer_type:
1661 case dwarf::DW_TAG_reference_type:
1662 case dwarf::DW_TAG_rvalue_reference_type:
1663 return lowerTypePointer(cast<DIDerivedType>(BaseTy), PO);
1664 case dwarf::DW_TAG_ptr_to_member_type:
1665 return lowerTypeMemberPointer(cast<DIDerivedType>(BaseTy), PO);
1671 TypeIndex ModifiedTI = getTypeIndex(BaseTy);
1679 return TypeTable.writeLeafType(MR);
1685 ReturnAndArgTypeIndices.
push_back(getTypeIndex(ArgTypeRef));
1688 if (ReturnAndArgTypeIndices.
size() > 1 &&
1689 ReturnAndArgTypeIndices.
back() == TypeIndex::Void()) {
1692 TypeIndex ReturnTypeIndex = TypeIndex::Void();
1694 if (!ReturnAndArgTypeIndices.
empty()) {
1695 auto ReturnAndArgTypesRef =
makeArrayRef(ReturnAndArgTypeIndices);
1696 ReturnTypeIndex = ReturnAndArgTypesRef.front();
1697 ArgTypeIndices = ReturnAndArgTypesRef.
drop_front();
1700 ArgListRecord ArgListRec(TypeRecordKind::ArgList, ArgTypeIndices);
1701 TypeIndex ArgListIndex = TypeTable.writeLeafType(ArgListRec);
1706 ArgTypeIndices.
size(), ArgListIndex);
1707 return TypeTable.writeLeafType(Procedure);
1713 bool IsStaticMethod) {
1715 TypeIndex ClassType = getTypeIndex(ClassTy);
1719 ReturnAndArgTypeIndices.
push_back(getTypeIndex(ArgTypeRef));
1722 if (ReturnAndArgTypeIndices.
size() > 1 &&
1723 ReturnAndArgTypeIndices.
back() == TypeIndex::Void()) {
1726 TypeIndex ReturnTypeIndex = TypeIndex::Void();
1728 if (!ReturnAndArgTypeIndices.
empty()) {
1729 auto ReturnAndArgTypesRef =
makeArrayRef(ReturnAndArgTypeIndices);
1730 ReturnTypeIndex = ReturnAndArgTypesRef.front();
1731 ArgTypeIndices = ReturnAndArgTypesRef.
drop_front();
1734 if (!IsStaticMethod && !ArgTypeIndices.
empty()) {
1735 ThisTypeIndex = ArgTypeIndices.
front();
1736 ArgTypeIndices = ArgTypeIndices.
drop_front();
1739 ArgListRecord ArgListRec(TypeRecordKind::ArgList, ArgTypeIndices);
1740 TypeIndex ArgListIndex = TypeTable.writeLeafType(ArgListRec);
1747 ArgListIndex, ThisAdjustment);
1748 return TypeTable.writeLeafType(MFR);
1752 unsigned VSlotCount =
1757 return TypeTable.writeLeafType(VFTSR);
1774 if (SP->isArtificial())
1775 return MethodOptions::CompilerGenerated;
1784 if (SP->getFlags() & DINode::FlagStaticMember)
1787 switch (SP->getVirtuality()) {
1788 case dwarf::DW_VIRTUALITY_none:
1790 case dwarf::DW_VIRTUALITY_virtual:
1792 case dwarf::DW_VIRTUALITY_pure_virtual:
1793 return Introduced ? MethodKind::PureIntroducingVirtual
1794 : MethodKind::PureVirtual;
1799 return MethodKind::Vanilla;
1804 case dwarf::DW_TAG_class_type:
return TypeRecordKind::Class;
1805 case dwarf::DW_TAG_structure_type:
return TypeRecordKind::Struct;
1819 CO |= ClassOptions::HasUniqueName;
1825 if (ImmediateScope && isa<DICompositeType>(ImmediateScope))
1826 CO |= ClassOptions::Nested;
1829 for (
const DIScope *Scope = ImmediateScope; Scope !=
nullptr;
1831 if (isa<DISubprogram>(Scope)) {
1832 CO |= ClassOptions::Scoped;
1842 case dwarf::DW_TAG_class_type:
1843 case dwarf::DW_TAG_structure_type:
1844 case dwarf::DW_TAG_union_type:
1845 case dwarf::DW_TAG_enumeration_type:
1851 if (
const auto *File = Ty->
getFile()) {
1853 TypeIndex SIDI = TypeTable.writeLeafType(SIDR);
1856 TypeTable.writeLeafType(USLR);
1863 unsigned EnumeratorCount = 0;
1866 CO |= ClassOptions::ForwardReference;
1869 ContinuationBuilder.
begin(ContinuationRecordKind::FieldList);
1873 if (
auto *
Enumerator = dyn_cast_or_null<DIEnumerator>(Element)) {
1881 FTI = TypeTable.insertRecord(ContinuationBuilder);
1888 TypeIndex EnumTI = TypeTable.writeLeafType(ER);
1890 addUDTSrcLine(Ty, EnumTI);
1924 void CodeViewDebug::clear() {
1925 assert(CurFn ==
nullptr);
1927 FnDebugInfo.clear();
1928 FileToFilepathMap.clear();
1931 TypeIndices.clear();
1932 CompleteTypeIndices.clear();
1935 void CodeViewDebug::collectMemberInfo(
ClassInfo &Info,
1938 Info.
Members.push_back({DDTy, 0});
1949 bool FullyResolved =
false;
1950 while (!FullyResolved) {
1952 case dwarf::DW_TAG_const_type:
1953 case dwarf::DW_TAG_volatile_type:
1956 Ty = cast<DIDerivedType>(Ty)->
getBaseType().resolve();
1959 FullyResolved =
true;
1968 ClassInfo NestedInfo = collectClassInfo(DCTy);
1978 for (
auto *Element : Elements) {
1983 if (
auto *SP = dyn_cast<DISubprogram>(Element)) {
1984 Info.
Methods[SP->getRawName()].push_back(SP);
1985 }
else if (
auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
1986 if (DDTy->
getTag() == dwarf::DW_TAG_member) {
1987 collectMemberInfo(Info, DDTy);
1988 }
else if (DDTy->
getTag() == dwarf::DW_TAG_inheritance) {
1990 }
else if (DDTy->
getTag() == dwarf::DW_TAG_pointer_type &&
1991 DDTy->
getName() ==
"__vtbl_ptr_type") {
1992 Info.
VShapeTI = getTypeIndex(DDTy);
1993 }
else if (DDTy->
getTag() == dwarf::DW_TAG_typedef) {
1995 }
else if (DDTy->
getTag() == dwarf::DW_TAG_friend) {
1999 }
else if (
auto *Composite = dyn_cast<DICompositeType>(Element)) {
2023 auto I = CompleteTypeIndices.find(Ty);
2024 if (
I != CompleteTypeIndices.end() &&
I->second ==
TypeIndex())
2026 return getCompleteTypeIndex(Ty);
2037 TypeIndex FwdDeclTI = TypeTable.writeLeafType(CR);
2039 DeferredCompleteTypes.push_back(Ty);
2049 unsigned FieldCount;
2051 std::tie(FieldTI, VShapeTI, FieldCount, ContainsNestedClass) =
2052 lowerRecordFieldList(Ty);
2054 if (ContainsNestedClass)
2055 CO |= ClassOptions::ContainsNestedClass;
2063 TypeIndex ClassTI = TypeTable.writeLeafType(CR);
2065 addUDTSrcLine(Ty, ClassTI);
2075 return getCompleteTypeIndex(Ty);
2081 TypeIndex FwdDeclTI = TypeTable.writeLeafType(UR);
2083 DeferredCompleteTypes.push_back(Ty);
2090 unsigned FieldCount;
2092 std::tie(FieldTI, std::ignore, FieldCount, ContainsNestedClass) =
2093 lowerRecordFieldList(Ty);
2095 if (ContainsNestedClass)
2096 CO |= ClassOptions::ContainsNestedClass;
2101 UnionRecord UR(FieldCount, CO, FieldTI, SizeInBytes, FullName,
2103 TypeIndex UnionTI = TypeTable.writeLeafType(UR);
2105 addUDTSrcLine(Ty, UnionTI);
2112 std::tuple<TypeIndex, TypeIndex, unsigned, bool>
2118 unsigned MemberCount = 0;
2121 ContinuationBuilder.
begin(ContinuationRecordKind::FieldList);
2125 if (I->
getFlags() & DINode::FlagVirtual) {
2127 unsigned VBPtrOffset = I->getVBPtrOffset();
2130 auto RecordKind = (I->
getFlags() & DINode::FlagIndirectVirtualBase) == DINode::FlagIndirectVirtualBase
2131 ? TypeRecordKind::IndirectVirtualBaseClass
2132 : TypeRecordKind::VirtualBaseClass;
2135 getTypeIndex(I->getBaseType()), getVBPTypeIndex(), VBPtrOffset,
2142 "bases must be on byte boundaries");
2144 getTypeIndex(I->getBaseType()),
2154 TypeIndex MemberBaseType = getTypeIndex(Member->getBaseType());
2167 if ((Member->
getFlags() & DINode::FlagArtificial) &&
2169 VFPtrRecord VFPR(getTypeIndex(Member->getBaseType()));
2176 uint64_t MemberOffsetInBits =
2179 uint64_t StartBitOffset = MemberOffsetInBits;
2180 if (
const auto *CI =
2181 dyn_cast_or_null<ConstantInt>(Member->getStorageOffsetInBits())) {
2182 MemberOffsetInBits = CI->getZExtValue() + MemberInfo.
BaseOffset;
2184 StartBitOffset -= MemberOffsetInBits;
2187 MemberBaseType = TypeTable.writeLeafType(BFR);
2189 uint64_t MemberOffsetInBytes = MemberOffsetInBits / 8;
2197 for (
auto &MethodItr : Info.
Methods) {
2200 std::vector<OneMethodRecord> Methods;
2202 TypeIndex MethodType = getMemberFunctionType(SP, Ty);
2203 bool Introduced = SP->getFlags() & DINode::FlagIntroducedVirtual;
2205 unsigned VFTableOffset = -1;
2207 VFTableOffset = SP->getVirtualIndex() * getPointerSizeInBytes();
2215 assert(!Methods.empty() &&
"Empty methods map entry");
2216 if (Methods.size() == 1)
2222 TypeIndex MethodList = TypeTable.writeLeafType(MOLR);
2236 TypeIndex FieldTI = TypeTable.insertRecord(ContinuationBuilder);
2237 return std::make_tuple(FieldTI, Info.
VShapeTI, MemberCount,
2241 TypeIndex CodeViewDebug::getVBPTypeIndex() {
2242 if (!VBPType.getIndex()) {
2245 TypeIndex ModifiedTI = TypeTable.writeLeafType(MR);
2247 PointerKind PK = getPointerSizeInBytes() == 8 ? PointerKind::Near64
2248 : PointerKind::Near32;
2251 PointerRecord PR(ModifiedTI, PK, PM, PO, getPointerSizeInBytes());
2252 VBPType = TypeTable.writeLeafType(PR);
2264 return TypeIndex::Void();
2269 auto I = TypeIndices.find({Ty, ClassTy});
2270 if (
I != TypeIndices.end())
2273 TypeLoweringScope S(*
this);
2275 return recordTypeIndexForDINode(Ty, TI, ClassTy);
2281 getPointerSizeInBytes() == 8 ? PointerKind::Near64
2282 : PointerKind::Near32,
2285 return TypeTable.writeLeafType(PR);
2293 return TypeIndex::Void();
2298 case dwarf::DW_TAG_class_type:
2299 case dwarf::DW_TAG_structure_type:
2300 case dwarf::DW_TAG_union_type:
2303 return getTypeIndex(Ty);
2307 const auto *CTy = cast<DICompositeType>(Ty);
2308 auto InsertResult = CompleteTypeIndices.insert({CTy,
TypeIndex()});
2309 if (!InsertResult.second)
2310 return InsertResult.first->second;
2312 TypeLoweringScope S(*
this);
2318 if (!CTy->getName().empty() || !CTy->getIdentifier().empty()) {
2319 TypeIndex FwdDeclTI = getTypeIndex(CTy);
2324 if (CTy->isForwardDecl())
2329 switch (CTy->getTag()) {
2330 case dwarf::DW_TAG_class_type:
2331 case dwarf::DW_TAG_structure_type:
2332 TI = lowerCompleteTypeClass(CTy);
2334 case dwarf::DW_TAG_union_type:
2335 TI = lowerCompleteTypeUnion(CTy);
2345 CompleteTypeIndices[CTy] = TI;
2353 void CodeViewDebug::emitDeferredCompleteTypes() {
2355 while (!DeferredCompleteTypes.empty()) {
2356 std::swap(DeferredCompleteTypes, TypesToEmit);
2358 getCompleteTypeIndex(RecordTy);
2359 TypesToEmit.clear();
2366 for (
const LocalVariable &L : Locals)
2367 if (L.DIVar->isParameter())
2370 [](
const LocalVariable *L,
const LocalVariable *R) {
2371 return L->DIVar->getArg() < R->DIVar->getArg();
2373 for (
const LocalVariable *L : Params)
2374 emitLocalVariable(*L);
2377 for (
const LocalVariable &L : Locals)
2378 if (!L.DIVar->isParameter())
2379 emitLocalVariable(L);
2382 void CodeViewDebug::emitLocalVariable(
const LocalVariable &Var) {
2386 OS.AddComment(
"Record length");
2387 OS.emitAbsoluteSymbolDiff(LocalEnd, LocalBegin, 2);
2388 OS.EmitLabel(LocalBegin);
2390 OS.AddComment(
"Record kind: S_LOCAL");
2391 OS.EmitIntValue(
unsigned(SymbolKind::S_LOCAL), 2);
2394 if (Var.DIVar->isParameter())
2395 Flags |= LocalSymFlags::IsParameter;
2396 if (Var.DefRanges.empty())
2397 Flags |= LocalSymFlags::IsOptimizedOut;
2399 OS.AddComment(
"TypeIndex");
2401 ? getTypeIndexForReferenceTo(Var.DIVar->getType())
2402 : getCompleteTypeIndex(Var.DIVar->getType());
2404 OS.AddComment(
"Flags");
2405 OS.EmitIntValue(static_cast<uint16_t>(Flags), 2);
2408 OS.EmitLabel(LocalEnd);
2414 for (
const LocalVarDefRange &DefRange : Var.DefRanges) {
2416 if (DefRange.InMemory) {
2417 uint16_t RegRelFlags = 0;
2418 if (DefRange.IsSubfield) {
2419 RegRelFlags = DefRangeRegisterRelSym::IsSubfieldFlag |
2420 (DefRange.StructOffset
2421 << DefRangeRegisterRelSym::OffsetInParentShift);
2429 StringRef(reinterpret_cast<const char *>(&SymKind),
sizeof(SymKind));
2433 assert(DefRange.DataOffset == 0 &&
"unexpected offset into register");
2434 if (DefRange.IsSubfield) {
2442 BytePrefix +=
StringRef(reinterpret_cast<const char *>(&SymKind),
2444 BytePrefix +=
StringRef(reinterpret_cast<const char *>(&Sym.
Hdr),
2452 BytePrefix +=
StringRef(reinterpret_cast<const char *>(&SymKind),
2454 BytePrefix +=
StringRef(reinterpret_cast<const char *>(&Sym.
Hdr),
2458 OS.EmitCVDefRangeDirective(DefRange.Ranges, BytePrefix);
2463 const FunctionInfo& FI) {
2464 for (LexicalBlock *Block : Blocks)
2465 emitLexicalBlock(*Block, FI);
2470 void CodeViewDebug::emitLexicalBlock(
const LexicalBlock &Block,
2471 const FunctionInfo& FI) {
2476 OS.AddComment(
"Record length");
2477 OS.emitAbsoluteSymbolDiff(RecordEnd, RecordBegin, 2);
2478 OS.EmitLabel(RecordBegin);
2479 OS.AddComment(
"Record kind: S_BLOCK32");
2480 OS.EmitIntValue(SymbolKind::S_BLOCK32, 2);
2481 OS.AddComment(
"PtrParent");
2482 OS.EmitIntValue(0, 4);
2483 OS.AddComment(
"PtrEnd");
2484 OS.EmitIntValue(0, 4);
2485 OS.AddComment(
"Code size");
2486 OS.emitAbsoluteSymbolDiff(Block.End, Block.Begin, 4);
2487 OS.AddComment(
"Function section relative address");
2488 OS.EmitCOFFSecRel32(Block.Begin, 0);
2489 OS.AddComment(
"Function section index");
2490 OS.EmitCOFFSectionIndex(FI.Begin);
2491 OS.AddComment(
"Lexical block name");
2493 OS.EmitLabel(RecordEnd);
2496 emitLocalVariableList(Block.Locals);
2499 emitLexicalBlockList(Block.Children, FI);
2502 OS.AddComment(
"Record length");
2503 OS.EmitIntValue(2, 2);
2504 OS.AddComment(
"Record kind: S_END");
2505 OS.EmitIntValue(SymbolKind::S_END, 2);
2510 void CodeViewDebug::collectLexicalBlockInfo(
2515 collectLexicalBlockInfo(*Scope, Blocks, Locals);
2520 void CodeViewDebug::collectLexicalBlockInfo(
2527 auto LocalsIter = ScopeVariables.find(&Scope);
2528 if (LocalsIter == ScopeVariables.end()) {
2530 collectLexicalBlockInfo(Scope.
getChildren(), ParentBlocks, ParentLocals);
2540 collectLexicalBlockInfo(Scope.
getChildren(), ParentBlocks, ParentLocals);
2561 collectLexicalBlockInfo(Scope.
getChildren(), ParentBlocks, ParentLocals);
2568 auto BlockInsertion = CurFn->LexicalBlocks.insert({DILB, LexicalBlock()});
2569 if (!BlockInsertion.second)
2575 assert(Range.first && Range.second);
2576 LexicalBlock &Block = BlockInsertion.first->second;
2579 assert(Block.Begin &&
"missing label for scope begin");
2580 assert(Block.End &&
"missing label for scope end");
2582 Block.Locals = std::move(Locals);
2584 collectLexicalBlockInfo(Scope.
getChildren(), Block.Children, Block.Locals);
2589 assert(FnDebugInfo.count(&GV));
2590 assert(CurFn == FnDebugInfo[&GV].
get());
2596 collectLexicalBlockInfo(*CFS, CurFn->ChildBlocks, CurFn->Locals);
2601 ScopeVariables.clear();
2605 if (!CurFn->HaveLineInfo && !GV.
getSubprogram()->isThunk()) {
2606 FnDebugInfo.erase(&GV);
2630 for (
const auto &NextMI : *MI->
getParent()) {
2631 if (NextMI.isDebugInstr())
2633 DL = NextMI.getDebugLoc();
2644 maybeRecordLocation(DL,
Asm->
MF);
2650 OS.EmitIntValue(
unsigned(Kind), 4);
2651 OS.AddComment(
"Subsection size");
2652 OS.emitAbsoluteSymbolDiff(EndLabel, BeginLabel, 4);
2653 OS.EmitLabel(BeginLabel);
2657 void CodeViewDebug::endCVSubsection(
MCSymbol *EndLabel) {
2658 OS.EmitLabel(EndLabel);
2660 OS.EmitValueToAlignment(4);
2663 void CodeViewDebug::emitDebugInfoForUDTs(
2664 ArrayRef<std::pair<std::string, const DIType *>> UDTs) {
2665 for (
const auto &UDT : UDTs) {
2671 OS.AddComment(
"Record length");
2672 OS.emitAbsoluteSymbolDiff(UDTRecordEnd, UDTRecordBegin, 2);
2673 OS.EmitLabel(UDTRecordBegin);
2675 OS.AddComment(
"Record kind: S_UDT");
2676 OS.EmitIntValue(
unsigned(SymbolKind::S_UDT), 2);
2678 OS.AddComment(
"Type");
2679 OS.EmitIntValue(getCompleteTypeIndex(T).getIndex(), 4);
2682 OS.EmitLabel(UDTRecordEnd);
2686 void CodeViewDebug::emitDebugInfoForGlobals() {
2691 GV.getDebugInfo(GVEs);
2692 for (
const auto *GVE : GVEs)
2693 GlobalMap[GVE] = &GV;
2698 const auto *
CU = cast<DICompileUnit>(Node);
2703 switchToDebugSectionForSymbol(
nullptr);
2705 for (
const auto *GVE :
CU->getGlobalVariables()) {
2706 if (
const auto *GV = GlobalMap.
lookup(GVE))
2709 OS.AddComment(
"Symbol subsection for globals");
2710 EndLabel = beginCVSubsection(DebugSubsectionKind::Symbols);
2713 emitDebugInfoForGlobal(GVE->getVariable(), GV,
Asm->
getSymbol(GV));
2717 endCVSubsection(EndLabel);
2721 for (
const auto *GVE :
CU->getGlobalVariables()) {
2722 if (
const auto *GV = GlobalMap.
lookup(GVE)) {
2725 OS.AddComment(
"Symbol subsection for " +
2727 switchToDebugSectionForSymbol(GVSym);
2728 EndLabel = beginCVSubsection(DebugSubsectionKind::Symbols);
2730 emitDebugInfoForGlobal(GVE->getVariable(), GV, GVSym);
2731 endCVSubsection(EndLabel);
2738 void CodeViewDebug::emitDebugInfoForRetainedTypes() {
2741 for (
auto *Ty : cast<DICompileUnit>(Node)->getRetainedTypes()) {
2742 if (
DIType *RT = dyn_cast<DIType>(Ty)) {
2757 const unsigned FixedLengthOfThisRecord = 12;
2758 OS.AddComment(
"Record length");
2759 OS.emitAbsoluteSymbolDiff(DataEnd, DataBegin, 2);
2760 OS.EmitLabel(DataBegin);
2763 OS.AddComment(
"Record kind: S_LTHREAD32");
2764 OS.EmitIntValue(
unsigned(SymbolKind::S_LTHREAD32), 2);
2766 OS.AddComment(
"Record kind: S_LDATA32");
2767 OS.EmitIntValue(
unsigned(SymbolKind::S_LDATA32), 2);
2771 OS.AddComment(
"Record kind: S_GTHREAD32");
2772 OS.EmitIntValue(
unsigned(SymbolKind::S_GTHREAD32), 2);
2774 OS.AddComment(
"Record kind: S_GDATA32");
2775 OS.EmitIntValue(
unsigned(SymbolKind::S_GDATA32), 2);
2778 OS.AddComment(
"Type");
2779 OS.EmitIntValue(getCompleteTypeIndex(DIGV->
getType()).getIndex(), 4);
2780 OS.AddComment(
"DataOffset");
2781 OS.EmitCOFFSecRel32(GVSym, 0);
2782 OS.AddComment(
"Segment");
2783 OS.EmitCOFFSectionIndex(GVSym);
2784 OS.AddComment(
"Name");
2786 OS.EmitLabel(DataEnd);
const T & front() const
front - Get the first element.
bool isDeclarationForLinker() const
PointerKind
Equivalent to CV_ptrtype_e.
TypeLoweringScope(CodeViewDebug &CVD)
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
ArrayRef< std::pair< MCSymbol *, MDNode * > > getCodeViewAnnotations() const
void push_back(const T &Elt)
const DILocalScope * getScopeNode() const
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
uint64_t getOffsetInBits() const
static bool shouldAlwaysEmitCompleteClassType(const DICompositeType *Ty)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
bool hasLocalLinkage() const
DILocation * get() const
Get the underlying DILocation.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
bool hasDebugInfo() const
Returns true if valid debug info is present.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
bool isAbstractScope() const
MCSection * getCOFFDebugTypesSection() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner)
Log all errors (if any) in E to OS.
virtual int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
Implements a dense probed hash-table based set.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
SimpleTypeKind getSimpleKind() const
DITypeRef getBaseType() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
void writeMemberType(RecordType &Record)
void endModule() override
Emit the COFF section that holds the line table information.
SmallVectorImpl< InsnRange > & getRanges()
static enum BaseType getBaseType(const Value *Val)
Return the baseType for Val which states whether Val is exclusively derived from constant/null, or not exclusively derived from constant.
A raw_ostream that writes to an SmallVector or SmallString.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
unsigned const TargetRegisterInfo * TRI
MachineFunction * MF
The current machine function.
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
bool isForwardDecl() const
LexicalScope - This class is used to track scope information.
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
void endFunctionImpl(const MachineFunction *) override
Gather post-function debug information.
MCSection * getCOFFGlobalTypeHashesSection() const
StringRef getName() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
VariableDbgInfoMapTy & getVariableDbgInfo()
Tagged DWARF-like metadata node.
std::string fromHex(StringRef Input)
Convert hexadecimal string Input to its binary representation.
DINodeArray getElements() const
SimpleTypeMode getSimpleMode() const
This represents a section on Windows.
MCContext & getContext() const
static cl::opt< bool > EmitDebugGlobalHashes("emit-codeview-ghash-section", cl::ReallyHidden, cl::init(false))
DebugLoc PrevInstLoc
Previous instruction's location information.
StringRef getName() const
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
bool isStaticMember() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SmallVectorImpl< LexicalScope * > & getChildren()
DbgValueHistoryMap DbgValues
History of DBG_VALUE and clobber instructions for each user variable.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
static StringRef getName(Value *V)
static std::string getFullyQualifiedName(const DIScope *Scope, StringRef Name)
uint64_t getSizeInBits() const
void * allocate(unsigned Size, unsigned Align=8)
Holds a subclass of DINode.
StringRef getFilename() const
static StringRef getPrettyScopeName(const DIScope *Scope)
Context object for machine code objects.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
bool isLocalToUnit() const
virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename, ArrayRef< uint8_t > Checksum, unsigned ChecksumKind)
Associate a filename with a specified logical file number, and also specify that file's checksum info...
static bool canUseReferenceType(const DbgVariableLocation &Loc)
ModifierOptions
Equivalent to CV_modifier_t.
MCSymbol * getFunctionBegin() const
op_range operands() const
static SourceLanguage MapDWLangToCVLang(unsigned DWLang)
static void addLocIfNotPresent(SmallVectorImpl< const DILocation *> &Locs, const DILocation *Loc)
const MCContext & getContext() const
MCSection * getCOFFDebugSymbolsSection() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
LexicalScope * findLexicalScope(const DILocation *DL)
findLexicalScope - Find lexical scope, either regular or inlined, for the given DebugLoc.
MethodKind
Part of member attribute flags. (CV_methodprop_e)
iterator_range< op_iterator > operands()
void resolve()
Resolve a unique, unresolved node.
TypeRecordKind
Distinguishes individual records in .debug$T or .debug$P section or PDB type stream.
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
initializer< Ty > init(const Ty &Val)
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static MemberAccess translateAccessFlags(unsigned RecordTag, unsigned Flags)
const MachineBasicBlock * PrevInstBB
const MCAsmInfo * MAI
Target Asm Printer information.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
DISubprogram * getSubprogram() const
Get the attached subprogram.
const DILocation * getInlinedAt() const
StringRef str_data() const
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static CPUType mapArchToCVCPUType(Triple::ArchType Type)
std::vector< MemberInfo > MemberList
AsmPrinter * Asm
Target of debug info emission.
std::pair< iterator, bool > insert(const ValueT &V)
This class is intended to be used as a driving class for all asm writers.
For method overload sets. LF_METHOD.
StringRef getCommentString() const
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
Error visitTypeRecord(CVType &Record, TypeIndex Index, TypeVisitorCallbacks &Callbacks, VisitorDataSource Source=VDS_BytesPresent)
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
StringRef getDirectory() const
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVM_NODISCARD char back() const
back - Get the last character in the string.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
bool isDebugInstr() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
Triple - Helper class for working with autoconf configuration names.
Base class for scope-like contexts.
uint32_t getIndex() const
void sort(IteratorTy Start, IteratorTy End)
PointerOptions
Equivalent to misc lfPointerAttr bitfields.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
LexicalScope * findInlinedScope(const DILocalScope *N, const DILocation *IA)
findInlinedScope - Find an inlined scope for the given scope/inlined-at.
Represents the location at which a variable is stored.
SourceLanguage
These values correspond to the CV_CFL_LANG enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx.
static Optional< DbgVariableLocation > extractFromMachineInstruction(const MachineInstr &Instruction)
Extract a VariableLocation from a MachineInstr.
This is the shared class of boolean and integer constants.
void setDebugInfoAvailability(bool avail)
static TypeRecordKind getRecordKind(const DICompositeType *Ty)
StringRef getName() const
MCSymbol * getSymbol(const GlobalValue *GV) const
MCSymbol * getCOMDATSymbol() const
bool isDebugValue() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn...
Information about stack frame layout on the target.
StringRef str()
Return a StringRef for the vector contents.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
DebugLoc getFnDebugLoc() const
Find the debug info location for the start of the function.
MCSymbol * getFunctionEnd() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
Collects and handles line tables information in a CodeView format.
PointerMode
Equivalent to CV_ptrmode_e.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This file contains constants used for implementing Dwarf debug support.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1', drop it.
bool fragmentsOverlap(const DIExpression *Other) const
Check if fragments overlap between this DIExpression and Other.
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
DebugLoc PrologEndLoc
This location indicates end of function prologue and beginning of function body.
MethodOptions
Equivalent to CV_fldattr_t bitfield.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
static const DISubprogram * getQualifiedNameComponents(const DIScope *Scope, SmallVectorImpl< StringRef > &QualifiedNameComponents)
const MachineBasicBlock * getParent() const
Dumper for CodeView type streams found in COFF object files and PDB files.
TargetSubtargetInfo - Generic base class for all target subtargets.
StringRef getIdentifier() const
static MethodKind translateMethodKindFlags(const DISubprogram *SP, bool Introduced)
Type array for a subprogram.
int getCodeViewRegNum(unsigned RegNum) const
Map a target register to an equivalent CodeView register number.
Representation of each machine instruction.
const DIDerivedType * MemberTypeNode
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void setPrefix(StringRef P)
unsigned getEncoding() const
void emplace_back(ArgTypes &&... Args)
LLVM_NODISCARD bool empty() const
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
StringRef getName() const
Return a constant reference to the value's name.
static void emitNullTerminatedSymbolName(MCStreamer &OS, StringRef S, unsigned MaxFixedRecordLength=0xF00)
virtual const TargetFrameLowering * getFrameLowering() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Base class for debug information backends.
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
static std::string getQualifiedName(ArrayRef< StringRef > QualifiedNameComponents, StringRef TypeName)
const Module * getModule() const
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
static Version parseVersion(StringRef Name)
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
DITypeRef getType() const
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
MemberAccess
Source-level access specifier. (CV_access_e)
SmallVector< int64_t, 1 > LoadChain
Chain of offsetted loads necessary to load the value if it lives in memory.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static APSInt getUnsigned(uint64_t X)
static MethodOptions translateMethodOptionFlags(const DISubprogram *SP)
std::vector< const DIType * > NestedTypes
virtual bool EmitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol, SMLoc Loc)
Introduces an inline call site id for use with .cv_loc.
DIScopeRef getScope() const
Lightweight error class with error context and mandatory checking.
static bool shouldEmitUdt(const DIType *T)
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
DITypeRefArray getTypeArray() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
MachineModuleInfo * MMI
Collected machine module information.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
iterator_range< global_iterator > globals()
static uint64_t getBaseTypeSize(const DITypeRef TyRef)
If this type is derived from a base type then return base type size.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
StringRef - Represent a constant reference to a string, i.e.
static Expected< std::string > replace(StringRef S, StringRef From, StringRef To)
static PointerToMemberRepresentation translatePtrToMemberRep(unsigned SizeInBytes, bool IsPMF, unsigned Flags)
static CallingConvention dwarfCCToCodeView(unsigned DwarfCC)
Given a DWARF calling convention, get the CodeView equivalent.
TypedDINodeRef< DIType > DITypeRef
Represents a location in source code.
DILocalScope * getScope() const
Get the local scope for this variable.
unsigned getNumOperands() const
Return number of MDNode operands.
LocalSymFlags
Corresponds to CV_LVARFLAGS bitfield.
static ClassOptions getCommonClassOptions(const DICompositeType *Ty)
Return ClassOptions that should be present on both the forward declaration and the defintion of a tag...
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
void begin(ContinuationRecordKind RecordKind)
CodeViewDebug(AsmPrinter *AP)
MemberList Members
Direct members.
std::pair< const MachineInstr *, const MachineInstr * > InsnRange
InsnRange - This is used to track range of instructions with identical lexical scope.
std::vector< const DIDerivedType * > Inheritance
Base classes.
static bool needsReferenceType(const DbgVariableLocation &Loc)
bool empty() const
empty - Check if the array is empty.
LexicalScope * getCurrentFunctionScope() const
getCurrentFunctionScope - Return lexical scope for the current function.
Basic type, like 'int' or 'float'.
DIScopeRef getScope() const