[lld] 0dfa8a0 - [LLD][COFF] Fix TypeServerSource matcher with more than one collision

Tobias Hieta via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 7 00:33:52 PDT 2022


Author: Tobias Hieta
Date: 2022-04-07T09:33:46+02:00
New Revision: 0dfa8a019d9a64d7706eb82bdb083fd9b815e088

URL: https://github.com/llvm/llvm-project/commit/0dfa8a019d9a64d7706eb82bdb083fd9b815e088
DIFF: https://github.com/llvm/llvm-project/commit/0dfa8a019d9a64d7706eb82bdb083fd9b815e088.diff

LOG: [LLD][COFF] Fix TypeServerSource matcher with more than one collision

Follow-up from 98bc304e9faded44f1d8988ffa4c5d8b50c759ec - while that
commit fixed when you had two PDBs colliding on the same Guid it didn't
fix the case where you had more than two PDBs using the same Guid.

This commit fixes that and also tests much more carefully that all
the types are correct no matter the order.

Reviewed By: aganea, saudi

Differential Revision: https://reviews.llvm.org/D123185

Added: 
    

Modified: 
    lld/COFF/DebugTypes.cpp
    lld/test/COFF/pdb-type-server-guid-collision-invalid.test
    lld/test/COFF/pdb-type-server-guid-collision-valid.test

Removed: 
    


################################################################################
diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 3b3f43f1bf15b..aa2ce3bd9bbbf 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -60,10 +60,7 @@ class TypeServerSource : public TpiSource {
       // If we hit here we have collision on Guid's in two PDB files.
       // This can happen if the PDB Guid is invalid or if we are really
       // unlucky. This should fall back on stright file-system lookup.
-      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 +402,12 @@ Expected<TypeServerSource *> UseTypeServerSource::getTypeServerSource() {
   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 {
+  }
+  if (tsSrc == nullptr) {
     // The file failed to load, lookup by name
     PDBInputFile *pdb = PDBInputFile::findFromRecordPath(ctx, tsPath, file);
     if (!pdb)

diff  --git a/lld/test/COFF/pdb-type-server-guid-collision-invalid.test b/lld/test/COFF/pdb-type-server-guid-collision-invalid.test
index d73695577de81..2418924df4ae5 100644
--- a/lld/test/COFF/pdb-type-server-guid-collision-invalid.test
+++ b/lld/test/COFF/pdb-type-server-guid-collision-invalid.test
@@ -6,15 +6,21 @@ that was set to FFFFFF...
 RUN: rm -rf %t && mkdir -p %t && cd %t
 RUN: yaml2obj %p/Inputs/pdb-type-server-guid-collision-a.yaml -o a.obj
 RUN: yaml2obj %p/Inputs/pdb-type-server-guid-collision-b.yaml -o b.obj
+RUN: sed s/b.pdb/c.pdb/ %S/Inputs/pdb-type-server-guid-collision-b.yaml | sed s/b.obj/c.obj/ | sed s/bar_gv/rab_gv/ | sed s/Bar/Rab/ | yaml2obj > c.obj
 RUN: llvm-pdbutil yaml2pdb %S/Inputs/pdb-type-server-guid-collision-a-pdb.yaml -pdb a.pdb
 RUN: llvm-pdbutil yaml2pdb %S/Inputs/pdb-type-server-guid-collision-b-pdb.yaml -pdb b.pdb
-RUN: lld-link a.obj b.obj -out:collision.dll /debug:ghash -pdb:collision.pdb -nodefaultlib /noentry /dll
-RUN: lld-link a.obj b.obj -out:collision.dll /debug:noghash -pdb:collision_noghash.pdb -nodefaultlib /noentry /dll
+RUN: sed s/b.pdb/c.pdb/ %S/Inputs/pdb-type-server-guid-collision-b-pdb.yaml | sed s/bar_gv/rab_gv/ | sed s/Bar/Rab/ | llvm-pdbutil yaml2pdb - -pdb c.pdb
+RUN: lld-link b.obj a.obj c.obj -out:collision.dll /debug:ghash -pdb:collision.pdb -nodefaultlib /noentry /dll
+RUN: lld-link a.obj b.obj c.obj -out:collision.dll /debug:noghash -pdb:collision_noghash.pdb -nodefaultlib /noentry /dll
 RUN: llvm-pdbutil dump -globals collision.pdb | FileCheck %s
 RUN: llvm-pdbutil dump -globals collision_noghash.pdb | FileCheck %s
 
 CHECK-LABEL:                       Global Symbols
 CHECK:       ============================================================
 
-CHECK:     100 | S_GDATA32 [size = 24] `bar_gv`
-CHECK-NEXT:           type = 0x104E (Bar), addr = 0002:0004
+CHECK-DAG:     {{[0-9]+}} | S_GDATA32 [size = 24] `rab_gv`
+CHECK-NEXT:           type = {{[^\s]+}} (Rab), addr = 0002:{{[0-9]+}}
+CHECK-DAG:     {{[0-9]+}} | S_GDATA32 [size = 24] `bar_gv`
+CHECK-NEXT:           type = {{[^\s]+}} (Bar), addr = 0002:{{[0-9]+}}
+CHECK-DAG:     {{[0-9]+}} | S_GDATA32 [size = 24] `foo_gv`
+CHECK-NEXT:           type = {{[^\s]+}} (Foo), addr = 0002:{{[0-9]+}}

diff  --git a/lld/test/COFF/pdb-type-server-guid-collision-valid.test b/lld/test/COFF/pdb-type-server-guid-collision-valid.test
index 115168c4cf79b..a3819eb278860 100644
--- a/lld/test/COFF/pdb-type-server-guid-collision-valid.test
+++ b/lld/test/COFF/pdb-type-server-guid-collision-valid.test
@@ -7,11 +7,9 @@ RUN: sed s/{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}/{6C633EB7-46FE-4609-BA83-EB820
 RUN: sed s/{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}/{6C633EB7-46FE-4609-BA83-EB820E6F5683}/ %S/Inputs/pdb-type-server-guid-collision-b.yaml | yaml2obj > b.obj
 RUN: sed s/{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}/{6C633EB7-46FE-4609-BA83-EB820E6F5683}/ %S/Inputs/pdb-type-server-guid-collision-a-pdb.yaml | llvm-pdbutil yaml2pdb - -pdb a.pdb
 RUN: sed s/{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}/{6C633EB7-46FE-4609-BA83-EB820E6F5683}/ %S/Inputs/pdb-type-server-guid-collision-b-pdb.yaml | llvm-pdbutil yaml2pdb - -pdb b.pdb
-RUN: lld-link a.obj b.obj -out:collision.dll -debug -pdb:collision.pdb -nodefaultlib /noentry /dll -verbose 2>&1 | FileCheck %s -check-prefix LOG
+RUN: lld-link a.obj b.obj -out:collision.dll -debug -pdb:collision.pdb -nodefaultlib /noentry /dll
 RUN: llvm-pdbutil dump -globals collision.pdb | FileCheck %s -check-prefix DUMP
 
-LOG: lld-link: GUID collision between b.pdb and a.pdb
-
 DUMP-LABEL:                       Global Symbols
 DUMP:       ============================================================
 


        


More information about the llvm-commits mailing list