aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp58
1 files changed, 25 insertions, 33 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 6f75dbd..f167cea 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -343,24 +343,8 @@ static std::string formatNestedName(ArrayRef<StringRef> QualifiedNameComponents,
return FullyQualifiedName;
}
-struct CodeViewDebug::TypeLoweringScope {
- TypeLoweringScope(CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel; }
- ~TypeLoweringScope() {
- // Don't decrement TypeEmissionLevel until after emitting deferred types, so
- // inner TypeLoweringScopes don't attempt to emit deferred types.
- if (CVD.TypeEmissionLevel == 1)
- CVD.emitDeferredCompleteTypes();
- --CVD.TypeEmissionLevel;
- }
- CodeViewDebug &CVD;
-};
-
std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
StringRef Name) {
- // Ensure types in the scope chain are emitted as soon as possible.
- // This can create otherwise a situation where S_UDTs are emitted while
- // looping in emitDebugInfoForUDTs.
- TypeLoweringScope S(*this);
SmallVector<StringRef, 5> QualifiedNameComponents;
collectParentScopeNames(Scope, QualifiedNameComponents);
return formatNestedName(QualifiedNameComponents, Name);
@@ -371,6 +355,18 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Ty) {
return getFullyQualifiedName(Scope, getPrettyScopeName(Ty));
}
+struct CodeViewDebug::TypeLoweringScope {
+ TypeLoweringScope(CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel; }
+ ~TypeLoweringScope() {
+ // Don't decrement TypeEmissionLevel until after emitting deferred types, so
+ // inner TypeLoweringScopes don't attempt to emit deferred types.
+ if (CVD.TypeEmissionLevel == 1)
+ CVD.emitDeferredCompleteTypes();
+ --CVD.TypeEmissionLevel;
+ }
+ CodeViewDebug &CVD;
+};
+
TypeIndex CodeViewDebug::getScopeIndex(const DIScope *Scope) {
// No scope means global scope and that uses the zero index.
if (!Scope || isa<DIFile>(Scope))
@@ -2985,16 +2981,10 @@ void CodeViewDebug::emitEndSymbolRecord(SymbolKind EndKind) {
}
void CodeViewDebug::emitDebugInfoForUDTs(
- const std::vector<std::pair<std::string, const DIType *>> &UDTs) {
-#ifndef NDEBUG
- size_t OriginalSize = UDTs.size();
-#endif
+ ArrayRef<std::pair<std::string, const DIType *>> UDTs) {
for (const auto &UDT : UDTs) {
const DIType *T = UDT.second;
assert(shouldEmitUdt(T));
- // Ensure no new types are discovered when executing the code below.
- // See discussion in https://reviews.llvm.org/D79512
- assert(OriginalSize == UDTs.size());
MCSymbol *UDTRecordEnd = beginSymbolRecord(SymbolKind::S_UDT);
OS.AddComment("Type");
@@ -3102,14 +3092,6 @@ void CodeViewDebug::emitGlobalVariableList(ArrayRef<CVGlobalVariable> Globals) {
void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) {
const DIGlobalVariable *DIGV = CVGV.DIGV;
-
- const DIScope *Scope = DIGV->getScope();
- // For static data members, get the scope from the declaration.
- if (const auto *MemberDecl = dyn_cast_or_null<DIDerivedType>(
- DIGV->getRawStaticDataMemberDeclaration()))
- Scope = MemberDecl->getScope();
- std::string QualifiedName = getFullyQualifiedName(Scope, DIGV->getName());
-
if (const GlobalVariable *GV =
CVGV.GVInfo.dyn_cast<const GlobalVariable *>()) {
// DataSym record, see SymbolRecord.h for more info. Thread local data
@@ -3129,9 +3111,13 @@ void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) {
OS.EmitCOFFSectionIndex(GVSym);
OS.AddComment("Name");
const unsigned LengthOfDataRecord = 12;
- emitNullTerminatedSymbolName(OS, QualifiedName, LengthOfDataRecord);
+ emitNullTerminatedSymbolName(
+ OS, getFullyQualifiedName(DIGV->getScope(), DIGV->getName()),
+ LengthOfDataRecord);
endSymbolRecord(DataEnd);
} else {
+ // FIXME: Currently this only emits the global variables in the IR metadata.
+ // This should also emit enums and static data members.
const DIExpression *DIE = CVGV.GVInfo.get<const DIExpression *>();
assert(DIE->isConstant() &&
"Global constant variables must contain a constant expression.");
@@ -3151,7 +3137,13 @@ void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) {
OS.emitBinaryData(SRef);
OS.AddComment("Name");
- emitNullTerminatedSymbolName(OS, QualifiedName);
+ const DIScope *Scope = DIGV->getScope();
+ // For static data members, get the scope from the declaration.
+ if (const auto *MemberDecl = dyn_cast_or_null<DIDerivedType>(
+ DIGV->getRawStaticDataMemberDeclaration()))
+ Scope = MemberDecl->getScope();
+ emitNullTerminatedSymbolName(OS,
+ getFullyQualifiedName(Scope, DIGV->getName()));
endSymbolRecord(SConstantEnd);
}
}