[PATCH] D123185: [LLD][COFF] Follow-up on 98bc304 - make collision case faster

Tobias Hieta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 5 23:22:09 PDT 2022


thieta created this revision.
thieta added reviewers: aganea, saudi, rnk.
Herald added a project: All.
thieta requested review of this revision.
Herald added a project: LLVM.

Instead of erasing the cached entry every time we hit a collision
we insert a nullptr instead and handle that in the lookup case.

This makes it faster if you have a lot of invalid PDB Guid's.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123185

Files:
  lld/COFF/DebugTypes.cpp


Index: lld/COFF/DebugTypes.cpp
===================================================================
--- lld/COFF/DebugTypes.cpp
+++ lld/COFF/DebugTypes.cpp
@@ -63,7 +63,7 @@
       TypeServerSource *tSrc = (TypeServerSource *)it.first->second;
       log("GUID collision between " + file.getFilePath() + " and " +
           tSrc->pdbInputFile->session->getPDBFile().getFilePath());
-      ctx.typeServerSourceMappings.erase(Guid);
+      it.first->second = nullptr;
     }
   }
 
@@ -405,11 +405,14 @@
   const codeview::GUID &tsId = typeServerDependency.getGuid();
   StringRef tsPath = typeServerDependency.getName();
 
-  TypeServerSource *tsSrc;
+  TypeServerSource *tsSrc = nullptr;
   auto it = ctx.typeServerSourceMappings.find(tsId);
   if (it != ctx.typeServerSourceMappings.end()) {
     tsSrc = (TypeServerSource *)it->second;
-  } else {
+  }
+
+  // check for nullptr since we insert nullptr if we encounter a collision
+  if (tsSrc == nullptr) {
     // The file failed to load, lookup by name
     PDBInputFile *pdb = PDBInputFile::findFromRecordPath(ctx, tsPath, file);
     if (!pdb)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123185.420716.patch
Type: text/x-patch
Size: 1101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220406/10121646/attachment.bin>


More information about the llvm-commits mailing list