@@ -736,6 +736,11 @@ class SlotTracker : public AbstractSlotTrackerStorage {
736
736
StringMap<unsigned > TypeIdMap;
737
737
unsigned TypeIdNext = 0 ;
738
738
739
+ // / TypeIdCompatibleVtableMap - The slot map for type compatible vtable ids
740
+ // / used in the summary index.
741
+ StringMap<unsigned > TypeIdCompatibleVtableMap;
742
+ unsigned TypeIdCompatibleVtableNext = 0 ;
743
+
739
744
public:
740
745
// / Construct from a module.
741
746
// /
@@ -779,6 +784,7 @@ class SlotTracker : public AbstractSlotTrackerStorage {
779
784
int getModulePathSlot (StringRef Path);
780
785
int getGUIDSlot (GlobalValue::GUID GUID);
781
786
int getTypeIdSlot (StringRef Id);
787
+ int getTypeIdCompatibleVtableSlot (StringRef Id);
782
788
783
789
// / If you'd like to deal with a function instead of just a module, use
784
790
// / this method to get its data into the SlotTracker.
@@ -834,6 +840,7 @@ class SlotTracker : public AbstractSlotTrackerStorage {
834
840
inline void CreateModulePathSlot (StringRef Path);
835
841
void CreateGUIDSlot (GlobalValue::GUID GUID);
836
842
void CreateTypeIdSlot (StringRef Id);
843
+ void CreateTypeIdCompatibleVtableSlot (StringRef Id);
837
844
838
845
// / Add all of the module level global variables (and their initializers)
839
846
// / and function declarations, but not the contents of those functions.
@@ -1095,11 +1102,13 @@ int SlotTracker::processIndex() {
1095
1102
for (auto &GlobalList : *TheIndex)
1096
1103
CreateGUIDSlot (GlobalList.first );
1097
1104
1105
+ // Start numbering the TypeIdCompatibleVtables after the GUIDs.
1106
+ TypeIdCompatibleVtableNext = GUIDNext;
1098
1107
for (auto &TId : TheIndex->typeIdCompatibleVtableMap ())
1099
- CreateGUIDSlot ( GlobalValue::getGUID ( TId.first ) );
1108
+ CreateTypeIdCompatibleVtableSlot ( TId.first );
1100
1109
1101
- // Start numbering the TypeIds after the GUIDs .
1102
- TypeIdNext = GUIDNext ;
1110
+ // Start numbering the TypeIds after the TypeIdCompatibleVtables .
1111
+ TypeIdNext = TypeIdCompatibleVtableNext ;
1103
1112
for (const auto &TID : TheIndex->typeIds ())
1104
1113
CreateTypeIdSlot (TID.second .first );
1105
1114
@@ -1232,6 +1241,15 @@ int SlotTracker::getTypeIdSlot(StringRef Id) {
1232
1241
return I == TypeIdMap.end () ? -1 : (int )I->second ;
1233
1242
}
1234
1243
1244
+ int SlotTracker::getTypeIdCompatibleVtableSlot (StringRef Id) {
1245
+ // Check for uninitialized state and do lazy initialization.
1246
+ initializeIndexIfNeeded ();
1247
+
1248
+ // Find the TypeIdCompatibleVtable string in the map
1249
+ auto I = TypeIdCompatibleVtableMap.find (Id);
1250
+ return I == TypeIdCompatibleVtableMap.end () ? -1 : (int )I->second ;
1251
+ }
1252
+
1235
1253
// / CreateModuleSlot - Insert the specified GlobalValue* into the slot table.
1236
1254
void SlotTracker::CreateModuleSlot (const GlobalValue *V) {
1237
1255
assert (V && " Can't insert a null Value into SlotTracker!" );
@@ -1307,6 +1325,11 @@ void SlotTracker::CreateTypeIdSlot(StringRef Id) {
1307
1325
TypeIdMap[Id] = TypeIdNext++;
1308
1326
}
1309
1327
1328
+ // / Create a new slot for the specified Id
1329
+ void SlotTracker::CreateTypeIdCompatibleVtableSlot (StringRef Id) {
1330
+ TypeIdCompatibleVtableMap[Id] = TypeIdCompatibleVtableNext++;
1331
+ }
1332
+
1310
1333
namespace {
1311
1334
// / Common instances used by most of the printer functions.
1312
1335
struct AsmWriterContext {
@@ -2955,7 +2978,7 @@ void AssemblyWriter::printModuleSummaryIndex() {
2955
2978
// Print the TypeIdCompatibleVtableMap entries.
2956
2979
for (auto &TId : TheIndex->typeIdCompatibleVtableMap ()) {
2957
2980
auto GUID = GlobalValue::getGUID (TId.first );
2958
- Out << " ^" << Machine.getGUIDSlot (GUID )
2981
+ Out << " ^" << Machine.getTypeIdCompatibleVtableSlot (TId. first )
2959
2982
<< " = typeidCompatibleVTable: (name: \" " << TId.first << " \" " ;
2960
2983
printTypeIdCompatibleVtableSummary (TId.second );
2961
2984
Out << " ) ; guid = " << GUID << " \n " ;
0 commit comments