@@ -525,9 +525,6 @@ Error UsePrecompSource::mergeInPrecompHeaderObj() {
525
525
precompSrc->tpiMap .begin () +
526
526
precompDependency.getTypesCount ());
527
527
528
- if (config->debugGHashes )
529
- funcIdToType = precompSrc->funcIdToType ; // FIXME: Save copy
530
-
531
528
return Error::success ();
532
529
}
533
530
@@ -612,7 +609,7 @@ void TpiSource::fillIsItemIndexFromDebugT() {
612
609
});
613
610
}
614
611
615
- void TpiSource::mergeTypeRecord (CVType ty) {
612
+ void TpiSource::mergeTypeRecord (TypeIndex curIndex, CVType ty) {
616
613
// Decide if the merged type goes into TPI or IPI.
617
614
bool isItem = isIdRecord (ty.kind ());
618
615
MergedInfo &merged = isItem ? mergedIpi : mergedTpi;
@@ -637,6 +634,25 @@ void TpiSource::mergeTypeRecord(CVType ty) {
637
634
uint32_t pdbHash = check (pdb::hashTypeRecord (CVType (newRec)));
638
635
merged.recSizes .push_back (static_cast <uint16_t >(newSize));
639
636
merged.recHashes .push_back (pdbHash);
637
+
638
+ // Retain a mapping from PDB function id to PDB function type. This mapping is
639
+ // used during symbol procesing to rewrite S_GPROC32_ID symbols to S_GPROC32
640
+ // symbols.
641
+ if (ty.kind () == LF_FUNC_ID || ty.kind () == LF_MFUNC_ID) {
642
+ bool success = ty.length () >= 12 ;
643
+ TypeIndex funcId = curIndex;
644
+ if (success)
645
+ success &= remapTypeIndex (funcId, TiRefKind::IndexRef);
646
+ TypeIndex funcType =
647
+ *reinterpret_cast <const TypeIndex *>(&newRec.data ()[8 ]);
648
+ if (success) {
649
+ funcIdToType.push_back ({funcId, funcType});
650
+ } else {
651
+ StringRef fname = file ? file->getName () : " <unknown PDB>" ;
652
+ warn (" corrupt LF_[M]FUNC_ID record 0x" + utohexstr (curIndex.getIndex ()) +
653
+ " in " + fname);
654
+ }
655
+ }
640
656
}
641
657
642
658
void TpiSource::mergeUniqueTypeRecords (ArrayRef<uint8_t > typeRecords,
@@ -655,27 +671,9 @@ void TpiSource::mergeUniqueTypeRecords(ArrayRef<uint8_t> typeRecords,
655
671
forEachTypeChecked (typeRecords, [&](const CVType &ty) {
656
672
if (nextUniqueIndex != uniqueTypes.end () &&
657
673
*nextUniqueIndex == ghashIndex) {
658
- mergeTypeRecord (ty);
674
+ mergeTypeRecord (beginIndex + ghashIndex, ty);
659
675
++nextUniqueIndex;
660
676
}
661
- if (ty.kind () == LF_FUNC_ID || ty.kind () == LF_MFUNC_ID) {
662
- bool success = ty.length () >= 12 ;
663
- TypeIndex srcFuncIdIndex = beginIndex + ghashIndex;
664
- TypeIndex funcId = srcFuncIdIndex;
665
- TypeIndex funcType;
666
- if (success) {
667
- funcType = *reinterpret_cast <const TypeIndex *>(&ty.data ()[8 ]);
668
- success &= remapTypeIndex (funcId, TiRefKind::IndexRef);
669
- success &= remapTypeIndex (funcType, TiRefKind::TypeRef);
670
- }
671
- if (success) {
672
- funcIdToType.insert ({funcId, funcType});
673
- } else {
674
- StringRef fname = file ? file->getName () : " <unknown PDB>" ;
675
- warn (" corrupt LF_[M]FUNC_ID record 0x" +
676
- utohexstr (srcFuncIdIndex.getIndex ()) + " in " + fname);
677
- }
678
- }
679
677
++ghashIndex;
680
678
});
681
679
assert (nextUniqueIndex == uniqueTypes.end () &&
@@ -758,7 +756,6 @@ void TypeServerSource::remapTpiWithGHashes(GHashState *g) {
758
756
ipiSrc->tpiMap = tpiMap;
759
757
ipiSrc->ipiMap = ipiMap;
760
758
ipiSrc->mergeUniqueTypeRecords (typeArrayToBytes (ipi.typeArray ()));
761
- funcIdToType = ipiSrc->funcIdToType ; // FIXME: Save copy
762
759
}
763
760
}
764
761
@@ -775,7 +772,6 @@ void UseTypeServerSource::remapTpiWithGHashes(GHashState *g) {
775
772
TypeServerSource *tsSrc = *maybeTsSrc;
776
773
tpiMap = tsSrc->tpiMap ;
777
774
ipiMap = tsSrc->ipiMap ;
778
- funcIdToType = tsSrc->funcIdToType ; // FIXME: Save copy
779
775
}
780
776
781
777
void PrecompSource::loadGHashes () {
@@ -1102,6 +1098,13 @@ void TypeMerger::mergeTypesWithGHash() {
1102
1098
source->remapTpiWithGHashes (&ghashState);
1103
1099
});
1104
1100
1101
+ // Build a global map of from function ID to function type.
1102
+ for (TpiSource *source : TpiSource::instances) {
1103
+ for (auto idToType : source->funcIdToType )
1104
+ funcIdToType.insert (idToType);
1105
+ source->funcIdToType .clear ();
1106
+ }
1107
+
1105
1108
TpiSource::clearGHashes ();
1106
1109
}
1107
1110
0 commit comments