summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorHans Wennborg <hans@chromium.org>2019-11-08 11:30:33 +0100
committerHans Wennborg <hans@chromium.org>2019-11-08 11:30:33 +0100
commitff3b513495c04d87799b3c5a98ddcdb6996af4f3 (patch)
tree7afe0cfe45cf53be4279f5b505d9687c20363cff /llvm/lib/CodeGen/AsmPrinter
parentf649f24d388c745d20fab5573d27b822b92818ed (diff)
downloadbcm5719-llvm-ff3b513495c04d87799b3c5a98ddcdb6996af4f3.tar.gz
bcm5719-llvm-ff3b513495c04d87799b3c5a98ddcdb6996af4f3.zip
Revert d91ed80 "[codeview] Reference types in type parent scopes"
This triggered asserts in the Chromium build, see https://crbug.com/1022729 for details and reproducer. > Without this change, when a nested tag type of any kind (enum, class, > struct, union) is used as a variable type, it is emitted without > emitting the parent type. In CodeView, parent types point to their inner > types, and inner types do not point back to their parents. We already > walk over all of the parent scopes to build the fully qualified name. > This change simply requests their type indices as we go along to enusre > they are all emitted. > > Fixes PR43905 > > Reviewers: akhuang, amccarth > > Differential Revision: https://reviews.llvm.org/D69924
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp36
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h13
2 files changed, 14 insertions, 35 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 3829dd4eff1..62ad356e7f8 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -303,19 +303,12 @@ static StringRef getPrettyScopeName(const DIScope *Scope) {
return StringRef();
}
-const DISubprogram *CodeViewDebug::collectParentScopeNames(
+static const DISubprogram *getQualifiedNameComponents(
const DIScope *Scope, SmallVectorImpl<StringRef> &QualifiedNameComponents) {
const DISubprogram *ClosestSubprogram = nullptr;
while (Scope != nullptr) {
if (ClosestSubprogram == nullptr)
ClosestSubprogram = dyn_cast<DISubprogram>(Scope);
-
- // If a type appears in a scope chain, make sure it gets emitted. The
- // frontend will be responsible for deciding if this should be a forward
- // declaration or a complete type.
- if (const auto *Ty = dyn_cast<DIType>(Scope))
- (void)getTypeIndex(Ty);
-
StringRef ScopeName = getPrettyScopeName(Scope);
if (!ScopeName.empty())
QualifiedNameComponents.push_back(ScopeName);
@@ -324,9 +317,8 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
return ClosestSubprogram;
}
-std::string
-CodeViewDebug::formatNestedName(ArrayRef<StringRef> QualifiedNameComponents,
- StringRef TypeName) {
+static std::string getQualifiedName(ArrayRef<StringRef> QualifiedNameComponents,
+ StringRef TypeName) {
std::string FullyQualifiedName;
for (StringRef QualifiedNameComponent :
llvm::reverse(QualifiedNameComponents)) {
@@ -337,15 +329,10 @@ CodeViewDebug::formatNestedName(ArrayRef<StringRef> QualifiedNameComponents,
return FullyQualifiedName;
}
-std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope, StringRef Name) {
+static std::string 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));
+ getQualifiedNameComponents(Scope, QualifiedNameComponents);
+ return getQualifiedName(QualifiedNameComponents, Name);
}
struct CodeViewDebug::TypeLoweringScope {
@@ -360,6 +347,11 @@ struct CodeViewDebug::TypeLoweringScope {
CodeViewDebug &CVD;
};
+static std::string 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))
@@ -1476,12 +1468,12 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
if (!shouldEmitUdt(Ty))
return;
- SmallVector<StringRef, 5> ParentScopeNames;
+ SmallVector<StringRef, 5> QualifiedNameComponents;
const DISubprogram *ClosestSubprogram =
- collectParentScopeNames(Ty->getScope(), ParentScopeNames);
+ getQualifiedNameComponents(Ty->getScope(), QualifiedNameComponents);
std::string FullyQualifiedName =
- formatNestedName(ParentScopeNames, getPrettyScopeName(Ty));
+ getQualifiedName(QualifiedNameComponents, getPrettyScopeName(Ty));
if (ClosestSubprogram == nullptr) {
GlobalUDTs.emplace_back(std::move(FullyQualifiedName), Ty);
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
index e32d6267430..b56b9047e1a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
@@ -443,19 +443,6 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase {
codeview::TypeIndex TI,
const DIType *ClassTy = nullptr);
- /// Collect the names of parent scopes, innermost to outermost. Return the
- /// innermost subprogram scope if present. Ensure that parent type scopes are
- /// inserted into the type table.
- const DISubprogram *
- collectParentScopeNames(const DIScope *Scope,
- SmallVectorImpl<StringRef> &ParentScopeNames);
-
- std::string formatNestedName(ArrayRef<StringRef> ParentScopeNames,
- StringRef TypeName);
-
- std::string getFullyQualifiedName(const DIScope *Scope, StringRef Name);
- std::string getFullyQualifiedName(const DIScope *Scope);
-
unsigned getPointerSizeInBytes();
protected:
OpenPOWER on IntegriCloud