r246231 - CGDebugInfo: Instead of uniquing RetainedTypes, just refrain from retaining

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 27 15:56:46 PDT 2015


Author: adrian
Date: Thu Aug 27 17:56:46 2015
New Revision: 246231

URL: http://llvm.org/viewvc/llvm-project?rev=246231&view=rev
Log:
CGDebugInfo: Instead of uniquing RetainedTypes, just refrain from retaining
them more than once. (NFC)

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=246231&r1=246230&r2=246231&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Aug 27 17:56:46 2015
@@ -1407,6 +1407,12 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
   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;
 }
@@ -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();
 }




More information about the cfe-commits mailing list