/// Given a PGO function name, remove the filename prefix and return
/// the original (static) function name.
-StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName);
+StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName,
+ StringRef FileName = "<unknown>");
/// Given a vector of strings (function PGO names) \c NameStrs, the
/// method generates a combined string \c Result thatis ready to be
assert(!Record.MappingRegions.empty() && "Function has no regions");
StringRef OrigFuncName = Record.FunctionName;
- if (!Record.Filenames.empty())
+ if (Record.Filenames.empty())
+ OrigFuncName = getFuncNameWithoutPrefix(OrigFuncName);
+ else
OrigFuncName =
getFuncNameWithoutPrefix(OrigFuncName, Record.Filenames[0]);
FunctionRecord Function(OrigFuncName, Record.Filenames);
StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName) {
if (FileName.empty())
- FileName = "<unknown>";
+ return PGOFuncName;
// Drop the file name including ':'. See also getPGOFuncName.
if (PGOFuncName.startswith(FileName))
PGOFuncName = PGOFuncName.drop_front(FileName.size() + 1);
ProfileReader = std::move(ReaderOrErr.get());
}
- void loadCoverageMapping(StringRef FuncName, uint64_t Hash) {
+ void loadCoverageMapping(StringRef FuncName, uint64_t Hash,
+ bool EmitFilenames = true) {
std::string Regions = writeCoverageRegions();
readCoverageRegions(Regions);
SmallVector<StringRef, 8> Filenames;
- for (const auto &E : Files)
- Filenames.push_back(E.getKey());
+ if (EmitFilenames)
+ for (const auto &E : Files)
+ Filenames.push_back(E.getKey());
OneFunctionCoverageReader CovReader(FuncName, Hash, Filenames, OutputCMRs);
auto CoverageOrErr = CoverageMapping::load(CovReader, *ProfileReader);
ASSERT_TRUE(NoError(CoverageOrErr.getError()));
readProfCounts();
addCMR(Counter::getCounter(0), "", 1, 1, 9, 9);
- loadCoverageMapping("<unknown>:func", 0x1234);
+ loadCoverageMapping("<unknown>:func", 0x1234, /*EmitFilenames=*/false);
std::vector<std::string> Names;
for (const auto &Func : LoadedCoverage->getCoveredFunctions())