Skip to content

Commit 0162205

Browse files
committedJan 8, 2019
[PGO] Use SourceFileName rather module name in PGOFuncName
In LTO or Thin-lto mode (though linker plugin), the module names are of temp file names which are different for different compilations. Using SourceFileName avoids the issue. This should not change any functionality for current PGO as all the current callers of getPGOFuncName() is before LTO. Differential Revision: https://reviews.llvm.org/D56327 llvm-svn: 350671
1 parent 7162e16 commit 0162205

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
 

‎llvm/lib/ProfileData/InstrProf.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,12 @@ static StringRef stripDirPrefix(StringRef PathNameStr, uint32_t NumPrefix) {
252252
// data, its original linkage must be non-internal.
253253
std::string getPGOFuncName(const Function &F, bool InLTO, uint64_t Version) {
254254
if (!InLTO) {
255-
StringRef FileName = (StaticFuncFullModulePrefix
256-
? F.getParent()->getName()
257-
: sys::path::filename(F.getParent()->getName()));
258-
if (StaticFuncFullModulePrefix && StaticFuncStripDirNamePrefix != 0)
259-
FileName = stripDirPrefix(FileName, StaticFuncStripDirNamePrefix);
255+
StringRef FileName(F.getParent()->getSourceFileName());
256+
uint32_t StripLevel = StaticFuncFullModulePrefix ? 0 : (uint32_t)-1;
257+
if (StripLevel < StaticFuncStripDirNamePrefix)
258+
StripLevel = StaticFuncStripDirNamePrefix;
259+
if (StripLevel)
260+
FileName = stripDirPrefix(FileName, StripLevel);
260261
return getPGOFuncName(F.getName(), F.getLinkage(), FileName, Version);
261262
}
262263

0 commit comments

Comments
 (0)