[llvm] r255670 - Coverage code refactoring /NFC
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 15 11:44:48 PST 2015
Author: davidxl
Date: Tue Dec 15 13:44:45 2015
New Revision: 255670
URL: http://llvm.org/viewvc/llvm-project?rev=255670&view=rev
Log:
Coverage code refactoring /NFC
Modified:
llvm/trunk/include/llvm/ProfileData/InstrProf.h
llvm/trunk/lib/ProfileData/CoverageMapping.cpp
llvm/trunk/lib/ProfileData/InstrProf.cpp
Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=255670&r1=255669&r2=255670&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Tue Dec 15 13:44:45 2015
@@ -156,6 +156,10 @@ GlobalVariable *createPGOFuncNameVar(Mod
GlobalValue::LinkageTypes Linkage,
StringRef FuncName);
+/// Given a PGO function name, remove the filename prefix and return
+/// the original (static) function name.
+StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName);
+
const std::error_category &instrprof_category();
enum class instrprof_error {
Modified: llvm/trunk/lib/ProfileData/CoverageMapping.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/CoverageMapping.cpp?rev=255670&r1=255669&r2=255670&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/CoverageMapping.cpp (original)
+++ llvm/trunk/lib/ProfileData/CoverageMapping.cpp Tue Dec 15 13:44:45 2015
@@ -181,18 +181,6 @@ void FunctionRecordIterator::skipOtherFi
*this = FunctionRecordIterator();
}
-/// Get the function name from the record, removing the filename prefix if
-/// necessary.
-static StringRef getFuncNameWithoutPrefix(const CoverageMappingRecord &Record) {
- StringRef FunctionName = Record.FunctionName;
- if (Record.Filenames.empty())
- return FunctionName;
- StringRef Filename = sys::path::filename(Record.Filenames[0]);
- if (FunctionName.startswith(Filename))
- FunctionName = FunctionName.drop_front(Filename.size() + 1);
- return FunctionName;
-}
-
ErrorOr<std::unique_ptr<CoverageMapping>>
CoverageMapping::load(CoverageMappingReader &CoverageReader,
IndexedInstrProfReader &ProfileReader) {
@@ -216,7 +204,11 @@ CoverageMapping::load(CoverageMappingRea
assert(!Record.MappingRegions.empty() && "Function has no regions");
- FunctionRecord Function(getFuncNameWithoutPrefix(Record), Record.Filenames);
+ StringRef OrigFuncName = Record.FunctionName;
+ if (!Record.Filenames.empty())
+ OrigFuncName =
+ getFuncNameWithoutPrefix(OrigFuncName, Record.Filenames[0]);
+ FunctionRecord Function(OrigFuncName, Record.Filenames);
for (const auto &Region : Record.MappingRegions) {
ErrorOr<int64_t> ExecutionCount = Ctx.evaluate(Region.Count);
if (!ExecutionCount)
Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=255670&r1=255669&r2=255670&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Tue Dec 15 13:44:45 2015
@@ -102,6 +102,15 @@ std::string getPGOFuncName(const Functio
Version);
}
+StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName) {
+ if (FileName.empty())
+ return PGOFuncName;
+ // Drop the file name including ':'. See also getPGOFuncName.
+ if (PGOFuncName.startswith(FileName))
+ PGOFuncName = PGOFuncName.drop_front(FileName.size() + 1);
+ return PGOFuncName;
+}
+
// \p FuncName is the string used as profile lookup key for the function. A
// symbol is created to hold the name. Return the legalized symbol name.
static std::string getPGOFuncNameVarName(StringRef FuncName,
More information about the llvm-commits
mailing list