Skip to content

Commit

Permalink
CGDebugInfo: Instead of uniquing RetainedTypes, just refrain from ret…
Browse files Browse the repository at this point in the history
…aining

them more than once. (NFC)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246231 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
adrian-prantl committed Aug 27, 2015
1 parent 992771a commit d2e47e2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,12 @@ llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
assert(!D.isNull() && "null type");
llvm::DIType *T = getOrCreateType(D, getOrCreateFile(Loc));
assert(T && "could not create debug info for type");

// Composite types with UIDs were already retained by DIBuilder
// because they are only referenced by name in the IR.
if (auto *CTy = dyn_cast<llvm::DICompositeType>(T))
if (!CTy->getIdentifier().empty())
return T;
RetainedTypes.push_back(D.getAsOpaquePtr());
return T;
}
Expand Down Expand Up @@ -3367,14 +3373,9 @@ void CGDebugInfo::finalize() {

// We keep our own list of retained types, because we need to look
// up the final type in the type cache.
llvm::DenseSet<void *> UniqueTypes;
UniqueTypes.resize(RetainedTypes.size() * 2);
for (auto &RT : RetainedTypes) {
if (!UniqueTypes.insert(RT).second)
continue;
for (auto &RT : RetainedTypes)
if (auto MD = TypeCache[RT])
DBuilder.retainType(cast<llvm::DIType>(MD));
}

DBuilder.finalize();
}
Expand Down

0 comments on commit d2e47e2

Please sign in to comment.