[llvm] r264586 - [Coverage] Strip <unknown> from PGO names if no filenames are available
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 28 08:49:08 PDT 2016
Author: vedantk
Date: Mon Mar 28 10:49:08 2016
New Revision: 264586
URL: http://llvm.org/viewvc/llvm-project?rev=264586&view=rev
Log:
[Coverage] Strip <unknown> from PGO names if no filenames are available
Patch suggested by David Li!
Modified:
llvm/trunk/include/llvm/ProfileData/InstrProf.h
llvm/trunk/lib/ProfileData/CoverageMapping.cpp
llvm/trunk/lib/ProfileData/InstrProf.cpp
llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp
Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=264586&r1=264585&r2=264586&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Mon Mar 28 10:49:08 2016
@@ -188,7 +188,8 @@ StringRef getPGOFuncNameVarInitializer(G
/// 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
Modified: llvm/trunk/lib/ProfileData/CoverageMapping.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/CoverageMapping.cpp?rev=264586&r1=264585&r2=264586&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/CoverageMapping.cpp (original)
+++ llvm/trunk/lib/ProfileData/CoverageMapping.cpp Mon Mar 28 10:49:08 2016
@@ -205,7 +205,9 @@ CoverageMapping::load(CoverageMappingRea
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);
Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=264586&r1=264585&r2=264586&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Mon Mar 28 10:49:08 2016
@@ -90,7 +90,7 @@ std::string getPGOFuncName(const Functio
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);
Modified: llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp?rev=264586&r1=264585&r2=264586&view=diff
==============================================================================
--- llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp (original)
+++ llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp Mon Mar 28 10:49:08 2016
@@ -141,13 +141,15 @@ struct CoverageMappingTest : ::testing::
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()));
@@ -310,7 +312,7 @@ TEST_P(MaybeSparseCoverageMappingTest, s
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())
More information about the llvm-commits
mailing list