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); }