Skip to content

Commit

Permalink
[PGO] Use SourceFileName rather module name in PGOFuncName
Browse files Browse the repository at this point in the history
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
  • Loading branch information
xur-llvm committed Jan 8, 2019
1 parent 7162e16 commit 0162205
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions llvm/lib/ProfileData/InstrProf.cpp
Expand Up @@ -252,11 +252,12 @@ static StringRef stripDirPrefix(StringRef PathNameStr, uint32_t NumPrefix) {
// data, its original linkage must be non-internal.
std::string getPGOFuncName(const Function &F, bool InLTO, uint64_t Version) {
if (!InLTO) {
StringRef FileName = (StaticFuncFullModulePrefix
? F.getParent()->getName()
: sys::path::filename(F.getParent()->getName()));
if (StaticFuncFullModulePrefix && StaticFuncStripDirNamePrefix != 0)
FileName = stripDirPrefix(FileName, StaticFuncStripDirNamePrefix);
StringRef FileName(F.getParent()->getSourceFileName());
uint32_t StripLevel = StaticFuncFullModulePrefix ? 0 : (uint32_t)-1;
if (StripLevel < StaticFuncStripDirNamePrefix)
StripLevel = StaticFuncStripDirNamePrefix;
if (StripLevel)
FileName = stripDirPrefix(FileName, StripLevel);
return getPGOFuncName(F.getName(), F.getLinkage(), FileName, Version);
}

Expand Down

0 comments on commit 0162205

Please sign in to comment.