r248510 - Debug Info: Use the module pointer as key for the module cache.

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 24 09:10:05 PDT 2015


Author: adrian
Date: Thu Sep 24 11:10:04 2015
New Revision: 248510

URL: http://llvm.org/viewvc/llvm-project?rev=248510&view=rev
Log:
Debug Info: Use the module pointer as key for the module cache.
This way we don't need to rebuild the full module name for every decl.

Modified:
    cfe/trunk/include/clang/AST/ExternalASTSource.h
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=248510&r1=248509&r2=248510&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Thu Sep 24 11:10:04 2015
@@ -163,6 +163,7 @@ public:
     StringRef getPath() const { return Path; }
     StringRef getASTFile() const { return ASTFile; }
     uint64_t getSignature() const { return Signature; }
+    const Module *getModuleOrNull() const { return ClangModule; }
   };
 
   /// Return a descriptor for the corresponding module, if one exists.

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248510&r1=248509&r2=248510&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 24 11:10:04 2015
@@ -1676,8 +1676,11 @@ llvm::DIType *CGDebugInfo::CreateType(co
 llvm::DIModule *
 CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
                                   bool CreateSkeletonCU) {
-  std::string FullModuleName = Mod.getFullModuleName();
-  auto &ModRef = ModuleRefCache[FullModuleName];
+  // Use the Module pointer as the key into the cache. This is a
+  // nullptr if the "Module" is a PCH, which is safe because we don't
+  // support chained PCH debug info, so there can only be a single PCH.
+  const Module *M = Mod.getModuleOrNull();
+  auto &ModRef = ModuleCache[M];
   if (ModRef)
     return cast<llvm::DIModule>(ModRef);
 
@@ -1704,6 +1707,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
     }
   }
 
+  std::string FullModuleName = Mod.getFullModuleName();
   if (CreateSkeletonCU) {
     llvm::DIBuilder DIB(CGM.getModule());
     DIB.createCompileUnit(TheCU->getSourceLanguage(), FullModuleName,
@@ -1712,11 +1716,11 @@ CGDebugInfo::getOrCreateModuleRef(Extern
                           llvm::DIBuilder::FullDebug, Mod.getSignature());
     DIB.finalize();
   }
-  llvm::DIModule *M =
+  llvm::DIModule *DIMod =
       DBuilder.createModule(TheCU, FullModuleName, ConfigMacros, Mod.getPath(),
                             CGM.getHeaderSearchOpts().Sysroot);
-  ModRef.reset(M);
-  return M;
+  ModRef.reset(DIMod);
+  return DIMod;
 }
 
 llvm::DIType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=248510&r1=248509&r2=248510&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Sep 24 11:10:04 2015
@@ -96,7 +96,7 @@ class CGDebugInfo {
   llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
 
   /// Cache of references to clang modules and precompiled headers.
-  llvm::StringMap<llvm::TrackingMDRef> ModuleRefCache;
+  llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
 
   /// List of interfaces we want to keep even if orphaned.
   std::vector<void *> RetainedTypes;




More information about the cfe-commits mailing list