@@ -491,11 +491,6 @@ class ModuleSummaryIndexBitcodeReader {
491
491
DenseMap<unsigned , std::pair<GlobalValue::GUID, GlobalValue::GUID>>
492
492
ValueIdToCallGraphGUIDMap;
493
493
494
- // / Map to save the association between summary offset in the VST to the
495
- // / GUID created when parsing it. Used to add newly parsed summaries to
496
- // / the index.
497
- DenseMap<uint64_t , GlobalValue::GUID> SummaryOffsetToGUIDMap;
498
-
499
494
// / Map populated during module path string table parsing, from the
500
495
// / module ID to a string reference owned by the index's module
501
496
// / path string table, used to correlate with combined index
@@ -547,7 +542,6 @@ class ModuleSummaryIndexBitcodeReader {
547
542
std::error_code initLazyStream (std::unique_ptr<DataStreamer> Streamer);
548
543
std::pair<GlobalValue::GUID, GlobalValue::GUID>
549
544
getGUIDFromValueId (unsigned ValueId);
550
- GlobalValue::GUID getGUIDFromOffset (uint64_t Offset);
551
545
};
552
546
} // namespace
553
547
@@ -5738,13 +5732,6 @@ ModuleSummaryIndexBitcodeReader::getGUIDFromValueId(unsigned ValueId) {
5738
5732
return VGI->second ;
5739
5733
}
5740
5734
5741
- GlobalValue::GUID
5742
- ModuleSummaryIndexBitcodeReader::getGUIDFromOffset (uint64_t Offset) {
5743
- auto I = SummaryOffsetToGUIDMap.find (Offset);
5744
- assert (I != SummaryOffsetToGUIDMap.end ());
5745
- return I->second ;
5746
- }
5747
-
5748
5735
// Specialized value symbol table parser used when reading module index
5749
5736
// blocks where we don't actually create global values. The parsed information
5750
5737
// is saved in the bitcode reader for use when later parsing summaries.
@@ -5830,18 +5817,6 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseValueSymbolTable(
5830
5817
ValueName.clear ();
5831
5818
break ;
5832
5819
}
5833
- case bitc::VST_CODE_COMBINED_GVDEFENTRY: {
5834
- // VST_CODE_COMBINED_GVDEFENTRY: [valueid, offset, guid]
5835
- unsigned ValueID = Record[0 ];
5836
- uint64_t GlobalValSummaryOffset = Record[1 ];
5837
- GlobalValue::GUID GlobalValGUID = Record[2 ];
5838
- SummaryOffsetToGUIDMap[GlobalValSummaryOffset] = GlobalValGUID;
5839
- // The "original name", which is the second value of the pair will be
5840
- // overriden later by a FS_COMBINED_ORIGINAL_NAME in the combined index.
5841
- ValueIdToCallGraphGUIDMap[ValueID] =
5842
- std::make_pair (GlobalValGUID, GlobalValGUID);
5843
- break ;
5844
- }
5845
5820
case bitc::VST_CODE_COMBINED_ENTRY: {
5846
5821
// VST_CODE_COMBINED_ENTRY: [valueid, refguid]
5847
5822
unsigned ValueID = Record[0 ];
@@ -6028,11 +6003,6 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
6028
6003
// "OriginalName" attachement.
6029
6004
GlobalValueSummary *LastSeenSummary = nullptr ;
6030
6005
bool Combined = false ;
6031
- // For aliases in the combined summary, we need to know which summary
6032
- // corresponds to the aliasee offset saved in the alias summary. It isn't
6033
- // sufficient to just map to the aliasee GUID, since in the combined summary
6034
- // there may be multiple values with the same GUID.
6035
- DenseMap<uint64_t , GlobalValueSummary *> OffsetToSummaryMap;
6036
6006
while (1 ) {
6037
6007
BitstreamEntry Entry = Stream.advanceSkippingSubblocks ();
6038
6008
@@ -6065,7 +6035,6 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
6065
6035
// in the combined index VST entries). The records also contain
6066
6036
// information used for ThinLTO renaming and importing.
6067
6037
Record.clear ();
6068
- uint64_t CurRecordBit = Stream.GetCurrentBitNo ();
6069
6038
auto BitCode = Stream.readRecord (Entry.ID , Record);
6070
6039
switch (BitCode) {
6071
6040
default : // Default behavior: ignore.
@@ -6162,27 +6131,29 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
6162
6131
TheIndex->addGlobalValueSummary (GUID.first , std::move (FS));
6163
6132
break ;
6164
6133
}
6165
- // FS_COMBINED: [modid, flags, instcount, numrefs, numrefs x valueid ,
6166
- // n x (valueid, callsitecount)]
6167
- // FS_COMBINED_PROFILE: [modid, flags, instcount, numrefs,
6134
+ // FS_COMBINED: [valueid, modid, flags, instcount, numrefs,
6135
+ // numrefs x valueid, n x (valueid, callsitecount)]
6136
+ // FS_COMBINED_PROFILE: [valueid, modid, flags, instcount, numrefs,
6168
6137
// numrefs x valueid,
6169
6138
// n x (valueid, callsitecount, profilecount)]
6170
6139
case bitc::FS_COMBINED:
6171
6140
case bitc::FS_COMBINED_PROFILE: {
6172
- uint64_t ModuleId = Record[0 ];
6173
- uint64_t RawFlags = Record[1 ];
6174
- unsigned InstCount = Record[2 ];
6175
- unsigned NumRefs = Record[3 ];
6141
+ unsigned ValueID = Record[0 ];
6142
+ uint64_t ModuleId = Record[1 ];
6143
+ uint64_t RawFlags = Record[2 ];
6144
+ unsigned InstCount = Record[3 ];
6145
+ unsigned NumRefs = Record[4 ];
6176
6146
auto Flags = getDecodedGVSummaryFlags (RawFlags, Version);
6177
6147
std::unique_ptr<FunctionSummary> FS =
6178
6148
llvm::make_unique<FunctionSummary>(Flags, InstCount);
6179
6149
LastSeenSummary = FS.get ();
6180
6150
FS->setModulePath (ModuleIdMap[ModuleId]);
6181
- static int RefListStartIndex = 4 ;
6151
+ static int RefListStartIndex = 5 ;
6182
6152
int CallGraphEdgeStartIndex = RefListStartIndex + NumRefs;
6183
6153
assert (Record.size () >= RefListStartIndex + NumRefs &&
6184
6154
" Record size inconsistent with number of references" );
6185
- for (unsigned I = 4 , E = CallGraphEdgeStartIndex; I != E; ++I) {
6155
+ for (unsigned I = RefListStartIndex, E = CallGraphEdgeStartIndex; I != E;
6156
+ ++I) {
6186
6157
unsigned RefValueId = Record[I];
6187
6158
GlobalValue::GUID RefGUID = getGUIDFromValueId (RefValueId).first ;
6188
6159
FS->addRefEdge (RefGUID);
@@ -6197,50 +6168,52 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
6197
6168
FS->addCallGraphEdge (CalleeGUID,
6198
6169
CalleeInfo (CallsiteCount, ProfileCount));
6199
6170
}
6200
- GlobalValue::GUID GUID = getGUIDFromOffset (CurRecordBit);
6201
- OffsetToSummaryMap[CurRecordBit] = FS.get ();
6171
+ GlobalValue::GUID GUID = getGUIDFromValueId (ValueID).first ;
6202
6172
TheIndex->addGlobalValueSummary (GUID, std::move (FS));
6203
6173
Combined = true ;
6204
6174
break ;
6205
6175
}
6206
- // FS_COMBINED_ALIAS: [modid, flags, offset ]
6176
+ // FS_COMBINED_ALIAS: [valueid, modid, flags, valueid ]
6207
6177
// Aliases must be emitted (and parsed) after all FS_COMBINED entries, as
6208
6178
// they expect all aliasee summaries to be available.
6209
6179
case bitc::FS_COMBINED_ALIAS: {
6210
- uint64_t ModuleId = Record[0 ];
6211
- uint64_t RawFlags = Record[1 ];
6212
- uint64_t AliaseeSummaryOffset = Record[2 ];
6180
+ unsigned ValueID = Record[0 ];
6181
+ uint64_t ModuleId = Record[1 ];
6182
+ uint64_t RawFlags = Record[2 ];
6183
+ unsigned AliaseeValueId = Record[3 ];
6213
6184
auto Flags = getDecodedGVSummaryFlags (RawFlags, Version);
6214
6185
std::unique_ptr<AliasSummary> AS = llvm::make_unique<AliasSummary>(Flags);
6215
6186
LastSeenSummary = AS.get ();
6216
6187
AS->setModulePath (ModuleIdMap[ModuleId]);
6217
6188
6218
- auto *AliaseeSummary = OffsetToSummaryMap[AliaseeSummaryOffset];
6219
- if (!AliaseeSummary)
6189
+ auto AliaseeGUID = getGUIDFromValueId (AliaseeValueId).first ;
6190
+ auto AliaseeInModule =
6191
+ TheIndex->findSummaryInModule (AliaseeGUID, AS->modulePath ());
6192
+ if (!AliaseeInModule)
6220
6193
return error (" Alias expects aliasee summary to be parsed" );
6221
- AS->setAliasee (AliaseeSummary );
6194
+ AS->setAliasee (AliaseeInModule );
6222
6195
6223
- GlobalValue::GUID GUID = getGUIDFromOffset (CurRecordBit) ;
6196
+ GlobalValue::GUID GUID = getGUIDFromValueId (ValueID). first ;
6224
6197
TheIndex->addGlobalValueSummary (GUID, std::move (AS));
6225
6198
Combined = true ;
6226
6199
break ;
6227
6200
}
6228
- // FS_COMBINED_GLOBALVAR_INIT_REFS: [modid, flags, n x valueid]
6201
+ // FS_COMBINED_GLOBALVAR_INIT_REFS: [valueid, modid, flags, n x valueid]
6229
6202
case bitc::FS_COMBINED_GLOBALVAR_INIT_REFS: {
6230
- uint64_t ModuleId = Record[0 ];
6231
- uint64_t RawFlags = Record[1 ];
6203
+ unsigned ValueID = Record[0 ];
6204
+ uint64_t ModuleId = Record[1 ];
6205
+ uint64_t RawFlags = Record[2 ];
6232
6206
auto Flags = getDecodedGVSummaryFlags (RawFlags, Version);
6233
6207
std::unique_ptr<GlobalVarSummary> FS =
6234
6208
llvm::make_unique<GlobalVarSummary>(Flags);
6235
6209
LastSeenSummary = FS.get ();
6236
6210
FS->setModulePath (ModuleIdMap[ModuleId]);
6237
- for (unsigned I = 2 , E = Record.size (); I != E; ++I) {
6211
+ for (unsigned I = 3 , E = Record.size (); I != E; ++I) {
6238
6212
unsigned RefValueId = Record[I];
6239
6213
GlobalValue::GUID RefGUID = getGUIDFromValueId (RefValueId).first ;
6240
6214
FS->addRefEdge (RefGUID);
6241
6215
}
6242
- GlobalValue::GUID GUID = getGUIDFromOffset (CurRecordBit);
6243
- OffsetToSummaryMap[CurRecordBit] = FS.get ();
6216
+ GlobalValue::GUID GUID = getGUIDFromValueId (ValueID).first ;
6244
6217
TheIndex->addGlobalValueSummary (GUID, std::move (FS));
6245
6218
Combined = true ;
6246
6219
break ;
0 commit comments