[PATCH] D79512: [DebugInfo][CodeView] Fix lowering of UDT
Alexandre Ganea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 6 12:26:10 PDT 2020
aganea created this revision.
aganea added reviewers: rnk, akhuang.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
aganea marked an inline comment as done.
aganea added inline comments.
aganea edited the summary of this revision.
================
Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:363
+ // looping in emitDebugInfoForUDTs.
+ TypeLoweringScope S(*this);
+ SmallVector<StringRef, 5> QualifiedNameComponents;
----------------
The actual change is this line.
It seems my previous changes uncovered an issue:
See build log here: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/41191/steps/check-llvm%20msan/logs/stdio
And here: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/17119/steps/check-llvm%20asan/logs/stdio
What happens is that `emitDebugInfoForGlobal` calls `getFullyQualifiedName`, which in turn calls `CodeViewDebug::collectParentScopeNames` and then, `DeferredCompleteTypes.push_back(Ty);`
This leaves deferred types in the vector, but they are only 'applied' later, inadvertently by `emitDebugInfoForUDTs` while calling `getCompleteTypeIndex` which ends up destroying a `TypeLoweringScope` which applies the deferred types, which in turn creates new UDT, which resizes the vector being iterated in the first place in `emitDebugInfoForUDTs`.
I've added an extra `TypeLoweringScope` in `getFullyQualifiedName()` below, which should only fire if there are no other `TypeLoweringScope` in the stack (which is the case for `emitDebugInfoForGlobal`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79512
Files:
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -343,18 +343,6 @@
return FullyQualifiedName;
}
-std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
- StringRef Name) {
- SmallVector<StringRef, 5> QualifiedNameComponents;
- collectParentScopeNames(Scope, QualifiedNameComponents);
- return formatNestedName(QualifiedNameComponents, Name);
-}
-
-std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Ty) {
- const DIScope *Scope = Ty->getScope();
- return getFullyQualifiedName(Scope, getPrettyScopeName(Ty));
-}
-
struct CodeViewDebug::TypeLoweringScope {
TypeLoweringScope(CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel; }
~TypeLoweringScope() {
@@ -367,6 +355,22 @@
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);
+}
+
+std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Ty) {
+ const DIScope *Scope = Ty->getScope();
+ return getFullyQualifiedName(Scope, getPrettyScopeName(Ty));
+}
+
TypeIndex CodeViewDebug::getScopeIndex(const DIScope *Scope) {
// No scope means global scope and that uses the zero index.
if (!Scope || isa<DIFile>(Scope))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79512.262442.patch
Type: text/x-patch
Size: 1858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200506/df3e2e2e/attachment-0001.bin>
More information about the llvm-commits
mailing list