[PATCH] D56327: [PGO] Use SourceFileName rather module name in PGOFuncName
Rong Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 4 12:02:19 PST 2019
xur created this revision.
xur added a reviewer: davidxl.
Herald added subscribers: dexonsmith, mehdi_amini.
In LTO or Thin-lto mode (though linker plugin), the module names are of temp file names which are different for different complations. Using SourceFileName avoids the issue.
This should not change any functionality for current PGO as all the current callers of getPGOFuncName() is before LTO.
https://reviews.llvm.org/D56327
Files:
lib/ProfileData/InstrProf.cpp
Index: lib/ProfileData/InstrProf.cpp
===================================================================
--- lib/ProfileData/InstrProf.cpp
+++ lib/ProfileData/InstrProf.cpp
@@ -252,11 +252,12 @@
// 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 : -1;
+ if (StripLevel < StaticFuncStripDirNamePrefix)
+ StripLevel = StaticFuncStripDirNamePrefix;
+ if (StripLevel)
+ FileName = stripDirPrefix(FileName, StripLevel);
return getPGOFuncName(F.getName(), F.getLinkage(), FileName, Version);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56327.180293.patch
Type: text/x-patch
Size: 1072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190104/989aa6e8/attachment.bin>
More information about the llvm-commits
mailing list