Re-land "[PDB] Avoid calling discoverTypeIndices for a known record kind"
authorReid Kleckner <rnk@google.com>
Sun, 3 May 2020 01:33:27 +0000 (18:33 -0700)
committerReid Kleckner <rnk@google.com>
Sun, 3 May 2020 01:39:33 +0000 (18:39 -0700)
Fixed bad usage of slice API causing assertion failures.

Reverts 810c8e9b495c191f49b162cee3fb8829185a2691
Reinstates bd7ea8641e7667b109534ae06b33be7bc9b59821

lld/COFF/PDB.cpp

index a182ed3..6ec2be3 100644 (file)
@@ -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, 4);
+      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