37 #include "llvm/Config/llvm-config.h"
87 using namespace llvm::codeview;
104 std::string &Filepath = FileToFilepathMap[
File];
105 if (!Filepath.empty())
114 if (Filename.find(
':') == 1)
117 Filepath = (Dir +
"\\" + Filename).str();
122 std::replace(Filepath.begin(), Filepath.end(),
'/',
'\\');
126 while ((Cursor = Filepath.find(
"\\.\\", Cursor)) != std::string::npos)
127 Filepath.erase(Cursor, 2);
132 while ((Cursor = Filepath.find(
"\\..\\", Cursor)) != std::string::npos) {
137 size_t PrevSlash = Filepath.rfind(
'\\', Cursor - 1);
138 if (PrevSlash == std::string::npos)
142 Filepath.erase(PrevSlash, Cursor + 3 - PrevSlash);
149 while ((Cursor = Filepath.find(
"\\\\", Cursor)) != std::string::npos)
150 Filepath.erase(Cursor, 1);
155 unsigned CodeViewDebug::maybeRecordFile(
const DIFile *
F) {
156 unsigned NextId = FileIdMap.size() + 1;
157 auto Insertion = FileIdMap.insert(std::make_pair(F, NextId));
158 if (Insertion.second) {
163 assert(Success &&
".cv_file directive failed");
165 return Insertion.first->second;
168 CodeViewDebug::InlineSite &
169 CodeViewDebug::getInlineSite(
const DILocation *InlinedAt,
171 auto SiteInsertion = CurFn->InlineSites.insert({InlinedAt, InlineSite()});
172 InlineSite *Site = &SiteInsertion.first->second;
173 if (SiteInsertion.second) {
174 unsigned ParentFuncId = CurFn->FuncId;
175 if (
const DILocation *OuterIA = InlinedAt->getInlinedAt())
177 getInlineSite(OuterIA, InlinedAt->getScope()->getSubprogram())
180 Site->SiteFuncId = NextFuncId++;
182 Site->SiteFuncId, ParentFuncId, maybeRecordFile(InlinedAt->getFile()),
183 InlinedAt->getLine(), InlinedAt->getColumn(),
SMLoc());
184 Site->Inlinee = Inlinee;
185 InlinedSubprograms.insert(Inlinee);
186 getFuncIdForSubprogram(Inlinee);
193 if (!ScopeName.
empty())
196 switch (Scope->
getTag()) {
197 case dwarf::DW_TAG_enumeration_type:
198 case dwarf::DW_TAG_class_type:
199 case dwarf::DW_TAG_structure_type:
200 case dwarf::DW_TAG_union_type:
201 return "<unnamed-tag>";
202 case dwarf::DW_TAG_namespace:
203 return "`anonymous namespace'";
212 while (Scope !=
nullptr) {
213 if (ClosestSubprogram ==
nullptr)
216 if (!ScopeName.empty())
217 QualifiedNameComponents.
push_back(ScopeName);
220 return ClosestSubprogram;
225 std::string FullyQualifiedName;
228 FullyQualifiedName.append(QualifiedNameComponent);
229 FullyQualifiedName.append(
"::");
231 FullyQualifiedName.append(TypeName);
232 return FullyQualifiedName;
246 if (
CVD.TypeEmissionLevel == 1)
247 CVD.emitDeferredCompleteTypes();
248 --
CVD.TypeEmissionLevel;
260 if (!Scope || isa<DIFile>(Scope))
263 assert(!isa<DIType>(Scope) &&
"shouldn't make a namespace scope for a type");
266 auto I = TypeIndices.find({Scope,
nullptr});
267 if (
I != TypeIndices.end())
274 return recordTypeIndexForDINode(Scope, TI);
281 auto I = TypeIndices.find({SP,
nullptr});
282 if (
I != TypeIndices.end())
291 if (
const auto *Class = dyn_cast_or_null<DICompositeType>(Scope)) {
295 TypeIndex ClassType = getTypeIndex(Class);
301 TypeIndex ParentScope = getScopeIndex(Scope);
302 FuncIdRecord FuncId(ParentScope, getTypeIndex(SP->getType()), DisplayName);
306 return recordTypeIndexForDINode(SP, TI);
313 if (SP->getDeclaration())
314 SP = SP->getDeclaration();
315 assert(!SP->getDeclaration() &&
"should use declaration as key");
319 auto I = TypeIndices.find({SP, Class});
320 if (I != TypeIndices.end())
326 TypeLoweringScope S(*
this);
328 lowerTypeMemberFunction(SP->getType(), Class, SP->getThisAdjustment());
329 return recordTypeIndexForDINode(SP, TI, Class);
335 auto InsertResult = TypeIndices.insert({{Node, ClassTy}, TI});
337 assert(InsertResult.second &&
"DINode was already assigned a type index");
341 unsigned CodeViewDebug::getPointerSizeInBytes() {
345 void CodeViewDebug::recordLocalVariable(LocalVariable &&Var,
350 InlineSite &Site = getInlineSite(InlinedAt, Inlinee);
351 Site.InlinedLocals.emplace_back(Var);
354 CurFn->Locals.emplace_back(Var);
365 void CodeViewDebug::maybeRecordLocation(
const DebugLoc &
DL,
377 if (LI.getStartLine() != DL.
getLine() || LI.isAlwaysStepInto() ||
378 LI.isNeverStepInto())
382 if (CI.getStartColumn() != DL.
getCol())
385 if (!CurFn->HaveLineInfo)
386 CurFn->HaveLineInfo =
true;
389 FileId = CurFn->LastFileId;
391 FileId = CurFn->LastFileId = maybeRecordFile(DL->getFile());
394 unsigned FuncId = CurFn->FuncId;
395 if (
const DILocation *SiteLoc = DL->getInlinedAt()) {
401 getInlineSite(SiteLoc, Loc->getScope()->getSubprogram()).SiteFuncId;
404 bool FirstLoc =
true;
405 while ((SiteLoc = Loc->getInlinedAt())) {
407 getInlineSite(SiteLoc, Loc->getScope()->getSubprogram());
418 DL->getFilename(),
SMLoc());
421 void CodeViewDebug::emitCodeViewMagicVersion() {
440 switchToDebugSectionForSymbol(
nullptr);
442 MCSymbol *CompilerInfo = beginCVSubsection(DebugSubsectionKind::Symbols);
443 emitCompilerInformation();
444 endCVSubsection(CompilerInfo);
446 emitInlineeLinesSubsection();
449 for (
auto &
P : FnDebugInfo)
450 if (!
P.first->isDeclarationForLinker())
451 emitDebugInfoForFunction(
P.first,
P.second);
454 setCurrentSubprogram(
nullptr);
455 emitDebugInfoForGlobals();
458 emitDebugInfoForRetainedTypes();
462 switchToDebugSectionForSymbol(
nullptr);
465 if (!GlobalUDTs.empty()) {
466 MCSymbol *SymbolsEnd = beginCVSubsection(DebugSubsectionKind::Symbols);
467 emitDebugInfoForUDTs(GlobalUDTs);
468 endCVSubsection(SymbolsEnd);
472 OS.
AddComment(
"File index to string table offset subsection");
481 emitTypeInformation();
491 unsigned MaxFixedRecordLength = 0xF00;
498 void CodeViewDebug::emitTypeInformation() {
504 if (TypeTable.
empty())
509 emitCodeViewMagicVersion();
513 CommentPrefix +=
'\t';
515 CommentPrefix +=
' ';
529 SP.setPrefix(CommentPrefix);
541 CommentOS.str().drop_front(CommentPrefix.
size() - 1).rtrim());
544 B = Table.getNext(*B);
552 case dwarf::DW_LANG_C:
553 case dwarf::DW_LANG_C89:
554 case dwarf::DW_LANG_C99:
555 case dwarf::DW_LANG_C11:
556 case dwarf::DW_LANG_ObjC:
558 case dwarf::DW_LANG_C_plus_plus:
559 case dwarf::DW_LANG_C_plus_plus_03:
560 case dwarf::DW_LANG_C_plus_plus_11:
561 case dwarf::DW_LANG_C_plus_plus_14:
563 case dwarf::DW_LANG_Fortran77:
564 case dwarf::DW_LANG_Fortran90:
565 case dwarf::DW_LANG_Fortran03:
566 case dwarf::DW_LANG_Fortran08:
568 case dwarf::DW_LANG_Pascal83:
570 case dwarf::DW_LANG_Cobol74:
571 case dwarf::DW_LANG_Cobol85:
573 case dwarf::DW_LANG_Java:
592 for (
const char C : Name) {
595 V.Part[
N] +=
C -
'0';
596 }
else if (
C ==
'.') {
608 case Triple::ArchType::x86:
609 return CPUType::Pentium3;
610 case Triple::ArchType::x86_64:
612 case Triple::ArchType::thumb:
613 return CPUType::Thumb;
622 void CodeViewDebug::emitCompilerInformation() {
635 const auto *CU = cast<DICompileUnit>(Node);
638 Flags = MapDWLangToCVLang(CU->getSourceLanguage());
649 StringRef CompilerVersion = CU->getProducer();
650 Version FrontVer = parseVersion(CompilerVersion);
652 for (
int N = 0; N < 4; ++
N)
658 int Major = 1000 * LLVM_VERSION_MAJOR +
659 10 * LLVM_VERSION_MINOR +
663 Version BackVer = {{ Major, 0, 0, 0 }};
665 for (
int N = 0; N < 4; ++
N)
668 OS.
AddComment(
"Null-terminated compiler version string");
674 void CodeViewDebug::emitInlineeLinesSubsection() {
675 if (InlinedSubprograms.empty())
679 MCSymbol *InlineEnd = beginCVSubsection(DebugSubsectionKind::InlineeLines);
684 OS.
EmitIntValue(
unsigned(InlineeLinesSignature::Normal), 4);
687 assert(TypeIndices.count({SP,
nullptr}));
688 TypeIndex InlineeIdx = TypeIndices[{SP,
nullptr}];
691 unsigned FileId = maybeRecordFile(SP->
getFile());
697 unsigned FileOffset = (FileId - 1) * 8;
698 OS.
AddComment(
"Type index of inlined function");
700 OS.
AddComment(
"Offset into filechecksum table");
706 endCVSubsection(InlineEnd);
709 void CodeViewDebug::emitInlinedCallSite(
const FunctionInfo &FI,
711 const InlineSite &Site) {
715 assert(TypeIndices.count({Site.Inlinee,
nullptr}));
716 TypeIndex InlineeIdx = TypeIndices[{Site.Inlinee,
nullptr}];
719 OS.AddComment(
"Record length");
720 OS.emitAbsoluteSymbolDiff(InlineEnd, InlineBegin, 2);
721 OS.EmitLabel(InlineBegin);
722 OS.AddComment(
"Record kind: S_INLINESITE");
723 OS.EmitIntValue(SymbolKind::S_INLINESITE, 2);
725 OS.AddComment(
"PtrParent");
726 OS.EmitIntValue(0, 4);
727 OS.AddComment(
"PtrEnd");
728 OS.EmitIntValue(0, 4);
729 OS.AddComment(
"Inlinee type index");
730 OS.EmitIntValue(InlineeIdx.
getIndex(), 4);
732 unsigned FileId = maybeRecordFile(Site.Inlinee->getFile());
733 unsigned StartLineNum = Site.Inlinee->getLine();
735 OS.EmitCVInlineLinetableDirective(Site.SiteFuncId, FileId, StartLineNum,
738 OS.EmitLabel(InlineEnd);
740 emitLocalVariableList(Site.InlinedLocals);
743 for (
const DILocation *ChildSite : Site.ChildSites) {
744 auto I = FI.InlineSites.find(ChildSite);
745 assert(I != FI.InlineSites.end() &&
746 "child site not in function inline site map");
747 emitInlinedCallSite(FI, ChildSite, I->second);
751 OS.AddComment(
"Record length");
752 OS.EmitIntValue(2, 2);
753 OS.AddComment(
"Record kind: S_INLINESITE_END");
754 OS.EmitIntValue(SymbolKind::S_INLINESITE_END, 2);
757 void CodeViewDebug::switchToDebugSectionForSymbol(
const MCSymbol *GVSym) {
773 if (ComdatDebugSections.insert(DebugSec).second)
774 emitCodeViewMagicVersion();
777 void CodeViewDebug::emitDebugInfoForFunction(
const Function *GV,
785 switchToDebugSectionForSymbol(Fn);
787 std::string FuncName;
790 setCurrentSubprogram(SP);
799 if (FuncName.empty())
804 MCSymbol *SymbolsEnd = beginCVSubsection(DebugSubsectionKind::Symbols);
837 OS.
AddComment(
"Function section relative address");
849 emitLocalVariableList(FI.Locals);
854 for (
const DILocation *InlinedAt : FI.ChildSites) {
855 auto I = FI.InlineSites.find(InlinedAt);
856 assert(I != FI.InlineSites.end() &&
857 "child site not in function inline site map");
858 emitInlinedCallSite(FI, InlinedAt, I->second);
862 emitDebugInfoForUDTs(LocalUDTs);
868 OS.
EmitIntValue(
unsigned(SymbolKind::S_PROC_ID_END), 2);
870 endCVSubsection(SymbolsEnd);
876 CodeViewDebug::LocalVarDefRange
877 CodeViewDebug::createDefRangeMem(uint16_t CVRegister,
int Offset) {
881 assert(DR.DataOffset == Offset &&
"truncation");
884 DR.CVRegister = CVRegister;
888 CodeViewDebug::LocalVarDefRange
889 CodeViewDebug::createDefRangeGeneral(uint16_t CVRegister,
bool InMemory,
890 int Offset,
bool IsSubfield,
891 uint16_t StructOffset) {
893 DR.InMemory = InMemory;
895 DR.IsSubfield = IsSubfield;
896 DR.StructOffset = StructOffset;
897 DR.CVRegister = CVRegister;
901 void CodeViewDebug::collectVariableInfoFromMFTable(
911 assert(
VI.Var->isValidLocationForIntrinsic(
VI.Loc) &&
912 "Expected inlined-at fields to agree");
914 Processed.
insert(InlinedVariable(
VI.Var,
VI.Loc->getInlinedAt()));
923 int64_t ExprOffset = 0;
925 if (!
VI.Expr->extractIfOffset(ExprOffset))
929 unsigned FrameReg = 0;
934 LocalVarDefRange DefRange =
935 createDefRangeMem(CVReg, FrameOffset + ExprOffset);
940 DefRange.Ranges.emplace_back(Begin, End);
945 Var.DefRanges.emplace_back(std::move(DefRange));
946 recordLocalVariable(std::move(Var),
VI.Loc->getInlinedAt());
950 void CodeViewDebug::collectVariableInfo(
const DISubprogram *SP) {
953 collectVariableInfoFromMFTable(Processed);
958 InlinedVariable IV = I.first;
959 if (Processed.
count(IV))
965 const auto &Ranges = I.second;
980 for (
auto I = Ranges.begin(), E = Ranges.end(); I !=
E; ++
I) {
985 bool IsSubfield =
false;
986 unsigned StructOffset = 0;
992 StructOffset = Fragment->OffsetInBits / 8;
993 }
else if (DIExpr->getNumElements() > 0) {
1011 LocalVarDefRange DR;
1012 DR.CVRegister = CVReg;
1013 DR.InMemory = InMemory;
1015 DR.IsSubfield = IsSubfield;
1016 DR.StructOffset = StructOffset;
1018 if (Var.DefRanges.empty() ||
1019 Var.DefRanges.back().isDifferentLocation(DR)) {
1020 Var.DefRanges.emplace_back(std::move(DR));
1030 auto J = std::next(I);
1043 Var.DefRanges.
back().Ranges;
1044 if (!Ranges.
empty() && Ranges.
back().second == Begin)
1052 recordLocalVariable(std::move(Var), InlinedAt);
1058 assert(FnDebugInfo.count(GV) ==
false);
1059 CurFn = &FnDebugInfo[GV];
1060 CurFn->FuncId = NextFuncId++;
1070 bool EmptyPrologue =
true;
1071 for (
const auto &MBB : *MF) {
1072 for (
const auto &
MI : MBB) {
1075 PrologEndLoc =
MI.getDebugLoc();
1077 }
else if (!
MI.isMetaInstruction()) {
1078 EmptyPrologue =
false;
1084 if (PrologEndLoc && !EmptyPrologue) {
1086 maybeRecordLocation(FnStartDL, MF);
1099 std::string FullyQualifiedName =
1102 if (ClosestSubprogram ==
nullptr)
1103 GlobalUDTs.emplace_back(std::move(FullyQualifiedName), TI);
1104 else if (ClosestSubprogram == CurrentSubprogram)
1105 LocalUDTs.emplace_back(std::move(FullyQualifiedName), TI);
1118 case dwarf::DW_TAG_array_type:
1119 return lowerTypeArray(cast<DICompositeType>(Ty));
1120 case dwarf::DW_TAG_typedef:
1121 return lowerTypeAlias(cast<DIDerivedType>(Ty));
1122 case dwarf::DW_TAG_base_type:
1123 return lowerTypeBasic(cast<DIBasicType>(Ty));
1124 case dwarf::DW_TAG_pointer_type:
1125 if (cast<DIDerivedType>(Ty)->
getName() ==
"__vtbl_ptr_type")
1126 return lowerTypeVFTableShape(cast<DIDerivedType>(Ty));
1128 case dwarf::DW_TAG_reference_type:
1129 case dwarf::DW_TAG_rvalue_reference_type:
1130 return lowerTypePointer(cast<DIDerivedType>(Ty));
1131 case dwarf::DW_TAG_ptr_to_member_type:
1132 return lowerTypeMemberPointer(cast<DIDerivedType>(Ty));
1133 case dwarf::DW_TAG_const_type:
1134 case dwarf::DW_TAG_volatile_type:
1136 return lowerTypeModifier(cast<DIDerivedType>(Ty));
1137 case dwarf::DW_TAG_subroutine_type:
1141 return lowerTypeMemberFunction(cast<DISubroutineType>(Ty), ClassTy,
1144 return lowerTypeFunction(cast<DISubroutineType>(Ty));
1145 case dwarf::DW_TAG_enumeration_type:
1146 return lowerTypeEnum(cast<DICompositeType>(Ty));
1147 case dwarf::DW_TAG_class_type:
1148 case dwarf::DW_TAG_structure_type:
1149 return lowerTypeClass(cast<DICompositeType>(Ty));
1150 case dwarf::DW_TAG_union_type:
1151 return lowerTypeUnion(cast<DICompositeType>(Ty));
1159 DITypeRef UnderlyingTypeRef = Ty->getBaseType();
1160 TypeIndex UnderlyingTypeIndex = getTypeIndex(UnderlyingTypeRef);
1163 addToUDTs(Ty, UnderlyingTypeIndex);
1165 if (UnderlyingTypeIndex ==
TypeIndex(SimpleTypeKind::Int32Long) &&
1166 TypeName ==
"HRESULT")
1167 return TypeIndex(SimpleTypeKind::HResult);
1168 if (UnderlyingTypeIndex ==
TypeIndex(SimpleTypeKind::UInt16Short) &&
1169 TypeName ==
"wchar_t")
1170 return TypeIndex(SimpleTypeKind::WideCharacter);
1172 return UnderlyingTypeIndex;
1177 TypeIndex ElementTypeIndex = getTypeIndex(ElementTypeRef);
1187 for (
int i = Elements.size() - 1; i >= 0; --i) {
1188 const DINode *Element = Elements[i];
1189 assert(Element->
getTag() == dwarf::DW_TAG_subrange_type);
1191 const DISubrange *Subrange = cast<DISubrange>(Element);
1192 assert(Subrange->getLowerBound() == 0 &&
1193 "codeview doesn't support subranges with lower bounds");
1194 int64_t Count = Subrange->getCount();
1203 ElementSize *= Count;
1207 uint64_t ArraySize =
1208 (i == 0 && ElementSize == 0) ? Ty->
getSizeInBits() / 8 : ElementSize;
1211 ArrayRecord AR(ElementTypeIndex, IndexType, ArraySize, Name);
1215 return ElementTypeIndex;
1228 case dwarf::DW_ATE_address:
1231 case dwarf::DW_ATE_boolean:
1233 case 1: STK = SimpleTypeKind::Boolean8;
break;
1234 case 2: STK = SimpleTypeKind::Boolean16;
break;
1235 case 4: STK = SimpleTypeKind::Boolean32;
break;
1236 case 8: STK = SimpleTypeKind::Boolean64;
break;
1237 case 16: STK = SimpleTypeKind::Boolean128;
break;
1240 case dwarf::DW_ATE_complex_float:
1242 case 2: STK = SimpleTypeKind::Complex16;
break;
1243 case 4: STK = SimpleTypeKind::Complex32;
break;
1244 case 8: STK = SimpleTypeKind::Complex64;
break;
1245 case 10: STK = SimpleTypeKind::Complex80;
break;
1246 case 16: STK = SimpleTypeKind::Complex128;
break;
1249 case dwarf::DW_ATE_float:
1251 case 2: STK = SimpleTypeKind::Float16;
break;
1252 case 4: STK = SimpleTypeKind::Float32;
break;
1253 case 6: STK = SimpleTypeKind::Float48;
break;
1254 case 8: STK = SimpleTypeKind::Float64;
break;
1255 case 10: STK = SimpleTypeKind::Float80;
break;
1256 case 16: STK = SimpleTypeKind::Float128;
break;
1259 case dwarf::DW_ATE_signed:
1261 case 1: STK = SimpleTypeKind::SignedCharacter;
break;
1262 case 2: STK = SimpleTypeKind::Int16Short;
break;
1264 case 8: STK = SimpleTypeKind::Int64Quad;
break;
1265 case 16: STK = SimpleTypeKind::Int128Oct;
break;
1268 case dwarf::DW_ATE_unsigned:
1270 case 1: STK = SimpleTypeKind::UnsignedCharacter;
break;
1271 case 2: STK = SimpleTypeKind::UInt16Short;
break;
1273 case 8: STK = SimpleTypeKind::UInt64Quad;
break;
1274 case 16: STK = SimpleTypeKind::UInt128Oct;
break;
1277 case dwarf::DW_ATE_UTF:
1279 case 2: STK = SimpleTypeKind::Character16;
break;
1280 case 4: STK = SimpleTypeKind::Character32;
break;
1283 case dwarf::DW_ATE_signed_char:
1285 STK = SimpleTypeKind::SignedCharacter;
1287 case dwarf::DW_ATE_unsigned_char:
1289 STK = SimpleTypeKind::UnsignedCharacter;
1297 STK = SimpleTypeKind::Int32Long;
1299 STK = SimpleTypeKind::UInt32Long;
1300 if (STK == SimpleTypeKind::UInt16Short &&
1302 STK = SimpleTypeKind::WideCharacter;
1303 if ((STK == SimpleTypeKind::SignedCharacter ||
1304 STK == SimpleTypeKind::UnsignedCharacter) &&
1306 STK = SimpleTypeKind::NarrowCharacter;
1312 TypeIndex PointeeTI = getTypeIndex(Ty->getBaseType());
1318 Ty->
getTag() == dwarf::DW_TAG_pointer_type) {
1320 ? SimpleTypeMode::NearPointer64
1321 : SimpleTypeMode::NearPointer32;
1326 Ty->
getSizeInBits() == 64 ? PointerKind::Near64 : PointerKind::Near32;
1330 case dwarf::DW_TAG_pointer_type:
1331 PM = PointerMode::Pointer;
1333 case dwarf::DW_TAG_reference_type:
1334 PM = PointerMode::LValueReference;
1336 case dwarf::DW_TAG_rvalue_reference_type:
1337 PM = PointerMode::RValueReference;
1357 : PointerToMemberRepresentation::GeneralFunction;
1358 case DINode::FlagSingleInheritance:
1359 return PointerToMemberRepresentation::SingleInheritanceFunction;
1360 case DINode::FlagMultipleInheritance:
1361 return PointerToMemberRepresentation::MultipleInheritanceFunction;
1362 case DINode::FlagVirtualInheritance:
1363 return PointerToMemberRepresentation::VirtualInheritanceFunction;
1369 : PointerToMemberRepresentation::GeneralData;
1370 case DINode::FlagSingleInheritance:
1371 return PointerToMemberRepresentation::SingleInheritanceData;
1372 case DINode::FlagMultipleInheritance:
1373 return PointerToMemberRepresentation::MultipleInheritanceData;
1374 case DINode::FlagVirtualInheritance:
1375 return PointerToMemberRepresentation::VirtualInheritanceData;
1382 assert(Ty->
getTag() == dwarf::DW_TAG_ptr_to_member_type);
1383 TypeIndex ClassTI = getTypeIndex(Ty->getClassType());
1384 TypeIndex PointeeTI = getTypeIndex(Ty->getBaseType(), Ty->getClassType());
1386 : PointerKind::Near32;
1387 bool IsPMF = isa<DISubroutineType>(Ty->getBaseType());
1388 PointerMode PM = IsPMF ? PointerMode::PointerToMemberFunction
1389 : PointerMode::PointerToDataMember;
1403 case dwarf::DW_CC_normal:
return CallingConvention::NearC;
1404 case dwarf::DW_CC_BORLAND_msfastcall:
return CallingConvention::NearFast;
1405 case dwarf::DW_CC_BORLAND_thiscall:
return CallingConvention::ThisCall;
1406 case dwarf::DW_CC_BORLAND_stdcall:
return CallingConvention::NearStdCall;
1407 case dwarf::DW_CC_BORLAND_pascal:
return CallingConvention::NearPascal;
1408 case dwarf::DW_CC_LLVM_vectorcall:
return CallingConvention::NearVector;
1410 return CallingConvention::NearC;
1415 bool IsModifier =
true;
1416 const DIType *BaseTy = Ty;
1417 while (IsModifier && BaseTy) {
1419 switch (BaseTy->
getTag()) {
1420 case dwarf::DW_TAG_const_type:
1421 Mods |= ModifierOptions::Const;
1423 case dwarf::DW_TAG_volatile_type:
1424 Mods |= ModifierOptions::Volatile;
1431 BaseTy = cast<DIDerivedType>(BaseTy)->
getBaseType().resolve();
1433 TypeIndex ModifiedTI = getTypeIndex(BaseTy);
1441 ReturnAndArgTypeIndices.
push_back(getTypeIndex(ArgTypeRef));
1443 TypeIndex ReturnTypeIndex = TypeIndex::Void();
1445 if (!ReturnAndArgTypeIndices.
empty()) {
1446 auto ReturnAndArgTypesRef =
makeArrayRef(ReturnAndArgTypeIndices);
1447 ReturnTypeIndex = ReturnAndArgTypesRef.front();
1448 ArgTypeIndices = ReturnAndArgTypesRef.
drop_front();
1451 ArgListRecord ArgListRec(TypeRecordKind::ArgList, ArgTypeIndices);
1457 ArgTypeIndices.
size(), ArgListIndex);
1463 int ThisAdjustment) {
1465 TypeIndex ClassType = getTypeIndex(ClassTy);
1469 ReturnAndArgTypeIndices.
push_back(getTypeIndex(ArgTypeRef));
1471 TypeIndex ReturnTypeIndex = TypeIndex::Void();
1473 if (!ReturnAndArgTypeIndices.
empty()) {
1474 auto ReturnAndArgTypesRef =
makeArrayRef(ReturnAndArgTypeIndices);
1475 ReturnTypeIndex = ReturnAndArgTypesRef.front();
1476 ArgTypeIndices = ReturnAndArgTypesRef.
drop_front();
1478 TypeIndex ThisTypeIndex = TypeIndex::Void();
1479 if (!ArgTypeIndices.
empty()) {
1480 ThisTypeIndex = ArgTypeIndices.
front();
1481 ArgTypeIndices = ArgTypeIndices.
drop_front();
1484 ArgListRecord ArgListRec(TypeRecordKind::ArgList, ArgTypeIndices);
1494 ArgListIndex, ThisAdjustment);
1501 unsigned VSlotCount =
1511 case DINode::FlagPrivate:
return MemberAccess::Private;
1512 case DINode::FlagPublic:
return MemberAccess::Public;
1513 case DINode::FlagProtected:
return MemberAccess::Protected;
1516 return RecordTag == dwarf::DW_TAG_class_type ? MemberAccess::Private
1517 : MemberAccess::Public;
1523 if (SP->isArtificial())
1524 return MethodOptions::CompilerGenerated;
1533 switch (SP->getVirtuality()) {
1534 case dwarf::DW_VIRTUALITY_none:
1536 case dwarf::DW_VIRTUALITY_virtual:
1537 return Introduced ? MethodKind::IntroducingVirtual : MethodKind::Virtual;
1538 case dwarf::DW_VIRTUALITY_pure_virtual:
1539 return Introduced ? MethodKind::PureIntroducingVirtual
1540 : MethodKind::PureVirtual;
1547 return MethodKind::Vanilla;
1553 case dwarf::DW_TAG_structure_type:
return TypeRecordKind::Struct;
1567 CO |= ClassOptions::HasUniqueName;
1573 if (ImmediateScope && isa<DICompositeType>(ImmediateScope))
1574 CO |= ClassOptions::Nested;
1577 for (
const DIScope *Scope = ImmediateScope; Scope !=
nullptr;
1578 Scope = Scope->getScope().resolve()) {
1579 if (isa<DISubprogram>(Scope)) {
1580 CO |= ClassOptions::Scoped;
1591 unsigned EnumeratorCount = 0;
1594 CO |= ClassOptions::ForwardReference;
1602 if (
auto *
Enumerator = dyn_cast_or_null<DIEnumerator>(Element)) {
1606 FLRB.writeMemberType(ER);
1610 FTI = FLRB.end(
true);
1649 void CodeViewDebug::clear() {
1650 assert(CurFn ==
nullptr);
1652 FnDebugInfo.clear();
1653 FileToFilepathMap.clear();
1656 TypeIndices.clear();
1657 CompleteTypeIndices.clear();
1660 void CodeViewDebug::collectMemberInfo(
ClassInfo &Info,
1663 Info.
Members.push_back({DDTy, 0});
1670 const DIType *Ty = DDTy->getBaseType().resolve();
1672 ClassInfo NestedInfo = collectClassInfo(DCTy);
1682 for (
auto *Element : Elements) {
1687 if (
auto *SP = dyn_cast<DISubprogram>(Element)) {
1688 Info.
Methods[SP->getRawName()].push_back(SP);
1689 }
else if (
auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
1690 if (DDTy->
getTag() == dwarf::DW_TAG_member) {
1691 collectMemberInfo(Info, DDTy);
1692 }
else if (DDTy->
getTag() == dwarf::DW_TAG_inheritance) {
1694 }
else if (DDTy->
getTag() == dwarf::DW_TAG_pointer_type &&
1695 DDTy->
getName() ==
"__vtbl_ptr_type") {
1696 Info.
VShapeTI = getTypeIndex(DDTy);
1697 }
else if (DDTy->
getTag() == dwarf::DW_TAG_friend) {
1701 }
else if (
auto *Composite = dyn_cast<DICompositeType>(Element)) {
1720 DeferredCompleteTypes.push_back(Ty);
1730 unsigned FieldCount;
1732 std::tie(FieldTI, VShapeTI, FieldCount, ContainsNestedClass) =
1733 lowerRecordFieldList(Ty);
1735 if (ContainsNestedClass)
1736 CO |= ClassOptions::ContainsNestedClass;
1746 if (
const auto *File = Ty->
getFile()) {
1753 addToUDTs(Ty, ClassTI);
1765 DeferredCompleteTypes.push_back(Ty);
1772 unsigned FieldCount;
1773 bool ContainsNestedClass;
1774 std::tie(FieldTI, std::ignore, FieldCount, ContainsNestedClass) =
1775 lowerRecordFieldList(Ty);
1777 if (ContainsNestedClass)
1778 CO |= ClassOptions::ContainsNestedClass;
1783 UnionRecord UR(FieldCount, CO, FieldTI, SizeInBytes, FullName,
1792 addToUDTs(Ty, UnionTI);
1797 std::tuple<TypeIndex, TypeIndex, unsigned, bool>
1803 unsigned MemberCount = 0;
1810 if (I->
getFlags() & DINode::FlagVirtual) {
1813 unsigned VBPtrOffset = 0;
1816 auto RecordKind = (I->
getFlags() & DINode::FlagIndirectVirtualBase) == DINode::FlagIndirectVirtualBase
1817 ? TypeRecordKind::IndirectVirtualBaseClass
1818 : TypeRecordKind::VirtualBaseClass;
1821 getTypeIndex(I->getBaseType()), getVBPTypeIndex(), VBPtrOffset,
1824 FLBR.writeMemberType(VBCR);
1827 "bases must be on byte boundaries");
1829 getTypeIndex(I->getBaseType()),
1831 FLBR.writeMemberType(BCR);
1838 TypeIndex MemberBaseType = getTypeIndex(Member->getBaseType());
1845 FLBR.writeMemberType(SDMR);
1851 if ((Member->
getFlags() & DINode::FlagArtificial) &&
1853 VFPtrRecord VFPR(getTypeIndex(Member->getBaseType()));
1854 FLBR.writeMemberType(VFPR);
1860 uint64_t MemberOffsetInBits =
1863 uint64_t StartBitOffset = MemberOffsetInBits;
1864 if (
const auto *CI =
1865 dyn_cast_or_null<ConstantInt>(Member->getStorageOffsetInBits())) {
1866 MemberOffsetInBits = CI->getZExtValue() + MemberInfo.
BaseOffset;
1868 StartBitOffset -= MemberOffsetInBits;
1873 uint64_t MemberOffsetInBytes = MemberOffsetInBits / 8;
1876 FLBR.writeMemberType(DMR);
1881 for (
auto &MethodItr : Info.
Methods) {
1882 StringRef Name = MethodItr.first->getString();
1884 std::vector<OneMethodRecord> Methods;
1886 TypeIndex MethodType = getMemberFunctionType(SP, Ty);
1887 bool Introduced = SP->getFlags() & DINode::FlagIntroducedVirtual;
1889 unsigned VFTableOffset = -1;
1891 VFTableOffset = SP->getVirtualIndex() * getPointerSizeInBytes();
1899 assert(!Methods.empty() &&
"Empty methods map entry");
1900 if (Methods.size() == 1)
1901 FLBR.writeMemberType(Methods[0]);
1906 FLBR.writeMemberType(OMR);
1913 FLBR.writeMemberType(R);
1918 return std::make_tuple(FieldTI, Info.
VShapeTI, MemberCount,
1922 TypeIndex CodeViewDebug::getVBPTypeIndex() {
1928 PointerKind PK = getPointerSizeInBytes() == 8 ? PointerKind::Near64
1929 : PointerKind::Near32;
1932 PointerRecord PR(ModifiedTI, PK, PM, PO, getPointerSizeInBytes());
1946 return TypeIndex::Void();
1951 auto I = TypeIndices.find({Ty, ClassTy});
1952 if (I != TypeIndices.end())
1955 TypeLoweringScope S(*
this);
1957 return recordTypeIndexForDINode(Ty, TI, ClassTy);
1965 return TypeIndex::Void();
1970 case dwarf::DW_TAG_class_type:
1971 case dwarf::DW_TAG_structure_type:
1972 case dwarf::DW_TAG_union_type:
1975 return getTypeIndex(Ty);
1981 const auto *CTy = cast<DICompositeType>(Ty);
1982 auto InsertResult = CompleteTypeIndices.insert({CTy,
TypeIndex()});
1983 if (!InsertResult.second)
1984 return InsertResult.first->second;
1986 TypeLoweringScope S(*
this);
1991 TypeIndex FwdDeclTI = getTypeIndex(CTy);
1996 if (CTy->isForwardDecl())
2000 switch (CTy->getTag()) {
2001 case dwarf::DW_TAG_class_type:
2002 case dwarf::DW_TAG_structure_type:
2003 TI = lowerCompleteTypeClass(CTy);
2005 case dwarf::DW_TAG_union_type:
2006 TI = lowerCompleteTypeUnion(CTy);
2012 InsertResult.first->second = TI;
2020 void CodeViewDebug::emitDeferredCompleteTypes() {
2022 while (!DeferredCompleteTypes.empty()) {
2023 std::swap(DeferredCompleteTypes, TypesToEmit);
2025 getCompleteTypeIndex(RecordTy);
2026 TypesToEmit.clear();
2033 for (
const LocalVariable &
L : Locals)
2034 if (
L.DIVar->isParameter())
2037 [](
const LocalVariable *
L,
const LocalVariable *R) {
2038 return L->DIVar->getArg() < R->DIVar->getArg();
2040 for (
const LocalVariable *L : Params)
2041 emitLocalVariable(*L);
2044 for (
const LocalVariable &L : Locals)
2045 if (!L.DIVar->isParameter())
2046 emitLocalVariable(L);
2049 void CodeViewDebug::emitLocalVariable(
const LocalVariable &Var) {
2061 if (Var.DIVar->isParameter())
2062 Flags |= LocalSymFlags::IsParameter;
2063 if (Var.DefRanges.empty())
2064 Flags |= LocalSymFlags::IsOptimizedOut;
2067 TypeIndex TI = getCompleteTypeIndex(Var.DIVar->getType());
2079 for (
const LocalVarDefRange &DefRange : Var.DefRanges) {
2081 if (DefRange.InMemory) {
2082 uint16_t RegRelFlags = 0;
2083 if (DefRange.IsSubfield) {
2084 RegRelFlags = DefRangeRegisterRelSym::IsSubfieldFlag |
2085 (DefRange.StructOffset
2086 << DefRangeRegisterRelSym::OffsetInParentShift);
2089 Sym.Hdr.Register = DefRange.CVRegister;
2090 Sym.Hdr.Flags = RegRelFlags;
2091 Sym.Hdr.BasePointerOffset = DefRange.DataOffset;
2094 StringRef(reinterpret_cast<const char *>(&SymKind),
sizeof(SymKind));
2096 StringRef(reinterpret_cast<const char *>(&Sym.Hdr),
sizeof(Sym.Hdr));
2098 assert(DefRange.DataOffset == 0 &&
"unexpected offset into register");
2099 if (DefRange.IsSubfield) {
2102 Sym.Hdr.Register = DefRange.CVRegister;
2103 Sym.Hdr.MayHaveNoName = 0;
2104 Sym.Hdr.OffsetInParent = DefRange.StructOffset;
2107 BytePrefix +=
StringRef(reinterpret_cast<const char *>(&SymKind),
2109 BytePrefix +=
StringRef(reinterpret_cast<const char *>(&Sym.Hdr),
2114 Sym.Hdr.Register = DefRange.CVRegister;
2115 Sym.Hdr.MayHaveNoName = 0;
2117 BytePrefix +=
StringRef(reinterpret_cast<const char *>(&SymKind),
2119 BytePrefix +=
StringRef(reinterpret_cast<const char *>(&Sym.Hdr),
2129 assert(FnDebugInfo.count(GV));
2130 assert(CurFn == &FnDebugInfo[GV]);
2132 collectVariableInfo(GV->getSubprogram());
2135 if (!CurFn->HaveLineInfo) {
2136 FnDebugInfo.erase(GV);
2158 for (
const auto &NextMI : *MI->
getParent()) {
2159 DL = NextMI.getDebugLoc();
2170 maybeRecordLocation(DL,
Asm->
MF);
2183 void CodeViewDebug::endCVSubsection(
MCSymbol *EndLabel) {
2189 void CodeViewDebug::emitDebugInfoForUDTs(
2190 ArrayRef<std::pair<std::string, TypeIndex>> UDTs) {
2191 for (
const std::pair<std::string, codeview::TypeIndex> &UDT : UDTs) {
2209 void CodeViewDebug::emitDebugInfoForGlobals() {
2214 GV.getDebugInfo(GVEs);
2215 for (
const auto *GVE : GVEs)
2216 GlobalMap[GVE] = &GV;
2221 const auto *CU = cast<DICompileUnit>(Node);
2226 switchToDebugSectionForSymbol(
nullptr);
2228 for (
const auto *GVE : CU->getGlobalVariables()) {
2229 if (
const auto *GV = GlobalMap.
lookup(GVE))
2232 OS.
AddComment(
"Symbol subsection for globals");
2233 EndLabel = beginCVSubsection(DebugSubsectionKind::Symbols);
2236 emitDebugInfoForGlobal(GVE->getVariable(), GV,
Asm->
getSymbol(GV));
2240 endCVSubsection(EndLabel);
2244 for (
const auto *GVE : CU->getGlobalVariables()) {
2245 if (
const auto *GV = GlobalMap.
lookup(GVE)) {
2250 switchToDebugSectionForSymbol(GVSym);
2251 EndLabel = beginCVSubsection(DebugSubsectionKind::Symbols);
2253 emitDebugInfoForGlobal(GVE->getVariable(), GV, GVSym);
2254 endCVSubsection(EndLabel);
2261 void CodeViewDebug::emitDebugInfoForRetainedTypes() {
2264 for (
auto *Ty : cast<DICompileUnit>(Node)->getRetainedTypes()) {
2265 if (
DIType *RT = dyn_cast<DIType>(Ty)) {
StringRef getName() const
PointerKind
Equivalent to CV_ptrtype_e.
TypeLoweringScope(CodeViewDebug &CVD)
void push_back(const T &Elt)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
virtual void EmitCVStringTableDirective()
This implements the CodeView '.cv_stringtable' assembler directive.
TypeIndex writeKnownType(T &Record)
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...
StringRef getIdentifier() const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
MCSymbol * getSymbol(const GlobalValue *GV) const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner)
Log all errors (if any) in E to OS.
const T & front() const
front - Get the first element.
CodeViewDebug(AsmPrinter *Asm)
DILocalScope * getScope() const
Get the local scope for this variable.
Implements a dense probed hash-table based set.
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
void endModule() override
Emit the COFF section that holds the line table information.
const MachineFunction * MF
The current machine function.
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.
DITypeRef getBaseType() const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
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.
DebugLoc getFnDebugLoc() const
Find the debug info location for the start of the function.
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
VariableDbgInfoMapTy & getVariableDbgInfo()
Tagged DWARF-like metadata node.
StringRef getName() const
Return a constant reference to the value's name.
StringRef str_data() const
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=GenericSectionID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym...
StringRef getCommentString() const
This represents a section on Windows.
DebugLoc PrevInstLoc
Previous instruction's location information.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
DILocation * get() const
Get the underlying DILocation.
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.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
DINodeArray getElements() const
const Module * getModule() const
Reg
All possible values of the reg field in the ModR/M byte.
static StringRef getName(Value *V)
StringRef getFilename() const
static std::string getFullyQualifiedName(const DIScope *Scope, StringRef Name)
Holds a subclass of DINode.
virtual bool isVerboseAsm() const
Return true if this streamer supports verbose assembly and if it is enabled.
bool hasDebugInfo() const
Returns true if valid debug info is present.
StringRef getName() const
MCContext & getContext() const
DITypeRefArray getTypeArray() const
virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
LLVM_NODISCARD bool empty() 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()))
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
virtual void EmitCVFileChecksumsDirective()
This implements the CodeView '.cv_filechecksums' assembler directive.
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.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
ModifierOptions
Equivalent to CV_modifier_t.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static Optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
DIScopeRef getScope() const
virtual void emitRawComment(const Twine &T, bool TabPrefix=true)
Print T and prefix it with the comment string (normally #) and optionally a tab.
LexicalScope * findLexicalScope(const DILocation *DL)
findLexicalScope - Find lexical scope, either regular or inlined, for the given DebugLoc.
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
MethodKind
Part of member attribute flags. (CV_methodprop_e)
int getCodeViewRegNum(unsigned RegNum) const
Map a target register to an equivalent CodeView register number.
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
iterator_range< op_iterator > operands()
DIScopeRef getScope() const
size_t size() const
size - Get the array size.
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...
uint32_t getIndex() const
const MachineBasicBlock * getParent() const
bool isDebugValue() const
TypeRecordKind
Distinguishes individual records in .debug$T section or PDB type stream.
std::vector< const DICompositeType * > NestedClasses
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
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 MemberAccess translateAccessFlags(unsigned RecordTag, unsigned Flags)
StringRef getName() const
static bool fragmentsOverlap(const DIExpression *P1, const DIExpression *P2)
Determine whether two variable fragments overlap.
const MachineBasicBlock * PrevInstBB
const MCAsmInfo * MAI
Target Asm Printer information.
The instances of the Type class are immutable: once they are created, they are never changed...
virtual void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const MachineOperand & getOperand(unsigned i) const
bool isLocalToUnit() const
std::vector< MemberInfo > MemberList
AsmPrinter * Asm
Target of debug info emission.
MCSymbol * getCOMDATSymbol() const
std::pair< iterator, bool > insert(const ValueT &V)
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
For method overload sets. LF_METHOD.
static const unsigned End
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
unsigned getEncoding() const
uint64_t getOffsetInBits() const
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
Error visitTypeRecord(CVType &Record, TypeIndex Index, TypeVisitorCallbacks &Callbacks, VisitorDataSource Source=VDS_BytesPresent)
bool empty() const
empty - Check if the array is empty.
SimpleTypeKind getSimpleKind() const
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
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...
Triple - Helper class for working with autoconf configuration names.
DITypeRef getType() const
Base class for scope-like contexts.
virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename)
Associate a filename with a specified logical file number.
MCSection * getCOFFDebugTypesSection() const
PointerOptions
Equivalent to misc lfPointerAttr bitfields.
StringRef getDirectory() const
virtual const TargetFrameLowering * getFrameLowering() const
static void addLocIfNotPresent(SmallVectorImpl< const DILocation * > &Locs, const DILocation *Loc)
LexicalScope * findInlinedScope(const DILocalScope *N, const DILocation *IA)
findInlinedScope - Find an inlined scope for the given scope/inlined-at.
SourceLanguage
These values correspond to the CV_CFL_LANG enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx.
auto find(R &&Range, const T &Val) -> decltype(std::begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
void setDebugInfoAvailability(bool avail)
static TypeRecordKind getRecordKind(const DICompositeType *Ty)
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
const MCContext & getContext() 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.
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.
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.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1', drop it.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
DISubprogram * getSubprogram() const
Get the attached subprogram.
bool isForwardDecl() const
bool isStaticMember() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
DebugLoc PrologEndLoc
This location indicates end of function prologue and beginning of function body.
MethodOptions
Equivalent to CV_fldattr_t bitfield.
MCSection & getSection(bool SetUsed=true) const
Get the section associated with a defined, non-absolute symbol.
static const DISubprogram * getQualifiedNameComponents(const DIScope *Scope, SmallVectorImpl< StringRef > &QualifiedNameComponents)
llvm_unreachable("Unknown RegBank!")
Dumper for CodeView type streams found in COFF object files and PDB files.
TargetSubtargetInfo - Generic base class for all target subtargets.
static MethodKind translateMethodKindFlags(const DISubprogram *SP, bool Introduced)
virtual void EmitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
Type array for a subprogram.
static std::vector< std::string > Flags
Representation of each machine instruction.
const DIDerivedType * MemberTypeNode
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void emplace_back(ArgTypes &&...Args)
MCSymbol * getFunctionBegin() const
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
MCSymbol * getFunctionEnd() const
uint64_t getSizeInBits() 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.
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
static void emitNullTerminatedSymbolName(MCStreamer &OS, StringRef S)
static std::string getQualifiedName(ArrayRef< StringRef > QualifiedNameComponents, StringRef TypeName)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
bool hasLocalLinkage() const
MCSection * getCOFFDebugSymbolsSection() const
unsigned getPointerSize() const
Get the pointer size for this target.
unsigned getReg() const
getReg - Returns the register number.
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
MemberAccess
Source-level access specifier. (CV_access_e)
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
virtual void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static APSInt getUnsigned(uint64_t X)
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
static MethodOptions translateMethodOptionFlags(const DISubprogram *SP)
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.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
virtual bool EmitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
Lightweight error class with error context and mandatory checking.
SimpleTypeMode getSimpleMode() const
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
MachineModuleInfo * MMI
Collected machine module information.
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.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
ArrayRef< ArrayRef< uint8_t > > records() const
StringRef - Represent a constant reference to a string, i.e.
static Expected< std::string > replace(StringRef S, StringRef From, StringRef To)
void sort(Policy policy, RandomAccessIterator Start, RandomAccessIterator End, const Comparator &Comp=Comparator())
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.
LocalSymFlags
Corresponds to CV_LVARFLAGS bitfield.
virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
bool isDeclarationForLinker() const
static ClassOptions getCommonClassOptions(const DICompositeType *Ty)
Return ClassOptions that should be present on both the forward declaration and the defintion of a tag...
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.
Basic type, like 'int' or 'float'.