Skip to content

Commit 5163477

Browse files
minor fixes
1 parent 7486f9d commit 5163477

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

llvm/lib/Transforms/IPO/FunctionImport.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,19 @@ static std::unique_ptr<Module> loadFile(const std::string &FileName,
207207
return Result;
208208
}
209209

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) {
213213
// We can import a local from another module if all inputs are compiled
214214
// with full paths or when there is one entry in the list.
215215
if (ImportAssumeUniqueLocal || NumRefs == 1)
216216
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.
223223
return GlobalValue::isLocalLinkage(RefSummary->linkage()) &&
224224
RefSummary->modulePath() != ImporterModule;
225225
}
@@ -256,17 +256,20 @@ static auto qualifyCalleeCandidates(
256256
if (!Summary)
257257
return {FunctionImporter::ImportFailureReason::GlobalVar, GVSummary};
258258

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(),
270273
CallerModulePath))
271274
return {
272275
FunctionImporter::ImportFailureReason::LocalLinkageNotInModule,

0 commit comments

Comments
 (0)