mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 21:50:40 +00:00
[Coverage] Fix the way we load "<unknown>:func" records
When emitting coverage mappings for functions with local linkage and an unknown filename, we use "<unknown>:func" for the PGO function name. The problem is that we don't strip "<unknown>" from the name when loading coverage data, like we do for other file names. Fix that and add a test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e0157e2632
commit
9c51ac3626
@ -90,7 +90,7 @@ std::string getPGOFuncName(const Function &F, uint64_t Version) {
|
||||
|
||||
StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName) {
|
||||
if (FileName.empty())
|
||||
return PGOFuncName;
|
||||
FileName = "<unknown>";
|
||||
// Drop the file name including ':'. See also getPGOFuncName.
|
||||
if (PGOFuncName.startswith(FileName))
|
||||
PGOFuncName = PGOFuncName.drop_front(FileName.size() + 1);
|
||||
|
@ -304,6 +304,21 @@ TEST_P(MaybeSparseCoverageMappingTest, strip_filename_prefix) {
|
||||
ASSERT_EQ("func", Names[0]);
|
||||
}
|
||||
|
||||
TEST_P(MaybeSparseCoverageMappingTest, strip_unknown_filename_prefix) {
|
||||
InstrProfRecord Record("<unknown>:func", 0x1234, {0});
|
||||
ProfileWriter.addRecord(std::move(Record));
|
||||
readProfCounts();
|
||||
|
||||
addCMR(Counter::getCounter(0), "", 1, 1, 9, 9);
|
||||
loadCoverageMapping("<unknown>:func", 0x1234);
|
||||
|
||||
std::vector<std::string> Names;
|
||||
for (const auto &Func : LoadedCoverage->getCoveredFunctions())
|
||||
Names.push_back(Func.Name);
|
||||
ASSERT_EQ(1U, Names.size());
|
||||
ASSERT_EQ("func", Names[0]);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MaybeSparse, MaybeSparseCoverageMappingTest,
|
||||
::testing::Bool());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user