@@ -207,19 +207,19 @@ static std::unique_ptr<Module> loadFile(const std::string &FileName,
207
207
return Result;
208
208
}
209
209
210
- static shouldSkipLocalInAnotherModule (const GlobalVarSummary *RefSummary,
211
- size_t NumRefs,
212
- StringRef ImporterModule) {
210
+ static bool shouldSkipLocalInAnotherModule (const GlobalVarSummary *RefSummary,
211
+ size_t NumRefs,
212
+ StringRef ImporterModule) {
213
213
// We can import a local from another module if all inputs are compiled
214
214
// with full paths or when there is one entry in the list.
215
215
if (ImportAssumeUniqueLocal || NumRefs == 1 )
216
216
return false ;
217
- // If this is a local variable , make sure we import the copy
218
- // in the caller's module . The only time a local variable can
219
- // share an entry in the index is if there is a local with the same name
220
- // in another module that had the same source file name (in a different
221
- // directory), where each was compiled in their own directory so there
222
- // was not distinguishing path.
217
+ // In other cases , make sure we import the copy in the caller's module if the
218
+ // referenced value has local linkage . The only time a local variable can
219
+ // share an entry in the index is if there is a local with the same name in
220
+ // another module that had the same source file name (in a different
221
+ // directory), where each was compiled in their own directory so there was not
222
+ // distinguishing path.
223
223
return GlobalValue::isLocalLinkage (RefSummary->linkage ()) &&
224
224
RefSummary->modulePath () != ImporterModule;
225
225
}
@@ -256,17 +256,20 @@ static auto qualifyCalleeCandidates(
256
256
if (!Summary)
257
257
return {FunctionImporter::ImportFailureReason::GlobalVar, GVSummary};
258
258
259
- // If this is a local function, make sure we import the copy
260
- // in the caller's module. The only time a local function can
261
- // share an entry in the index is if there is a local with the same name
262
- // in another module that had the same source file name (in a different
263
- // directory), where each was compiled in their own directory so there
264
- // was not distinguishing path.
265
- // However, do the import from another module if there is only one
266
- // entry in the list - in that case this must be a reference due
267
- // to indirect call profile data, since a function pointer can point to
268
- // a local in another module.
269
- if (shouldSkipLocalInAnotherModule (Summary, CalleeSummaryList.size (),
259
+ // If this is a local function, make sure we import the copy in the
260
+ // caller's module. The only time a local function can share an entry in
261
+ // the index is if there is a local with the same name in another module
262
+ // that had the same source file name (in a different directory), where
263
+ // each was compiled in their own directory so there was not
264
+ // distinguishing path.
265
+ // If the local function is from another module, it must be a reference
266
+ // due to indirect call profile data since a function pointer can point
267
+ // to a local in another module. Do the import from another module if
268
+ // there is only one entry in the list or when all files in the program
269
+ // are compiled with full path - in both cases the local function has
270
+ // unique PGO name and GUID.
271
+ if (shouldSkipLocalInAnotherModule (dyn_cast<GlobalVarSummary>(Summary),
272
+ CalleeSummaryList.size (),
270
273
CallerModulePath))
271
274
return {
272
275
FunctionImporter::ImportFailureReason::LocalLinkageNotInModule,
0 commit comments