[lld] bd7ea86 - [PDB] Avoid calling discoverTypeIndices for a known record kind

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Sat May 2 15:51:16 PDT 2020


Author: Reid Kleckner
Date: 2020-05-02T15:51:08-07:00
New Revision: bd7ea8641e7667b109534ae06b33be7bc9b59821

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

LOG: [PDB] Avoid calling discoverTypeIndices for a known record kind

This particular overload allocates memory, and we do this for every
S_[GL]PROC32_ID record. Instead, hardcode the offset of the typeindex
that we are looking for in the LF_[MEM]FUNC_ID record. We already
assumed that looking up the item index already found a record of this
kind.

Added: 
    

Modified: 
    lld/COFF/PDB.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index a182ed34165d..6ba6f0b5068a 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -726,10 +726,9 @@ static void translateIdSymbols(MutableArrayRef<uint8_t> &recordData,
     // in both cases we just need the second type index.
     if (!ti->isSimple() && !ti->isNoneType()) {
       CVType funcIdData = iDTable.getType(*ti);
-      SmallVector<TypeIndex, 2> indices;
-      discoverTypeIndices(funcIdData, indices);
-      assert(indices.size() == 2);
-      *ti = indices[1];
+      ArrayRef<uint8_t> tiBuf = funcIdData.data().slice(8, 12);
+      assert(tiBuf.size() == 4 && "corruct LF_[MEM]FUNC_ID record");
+      *ti = *reinterpret_cast<const TypeIndex *>(tiBuf.data());
     }
 
     kind = (kind == SymbolKind::S_GPROC32_ID) ? SymbolKind::S_GPROC32


        


More information about the llvm-commits mailing list