[llvm] r258509 - [PGO] add an interface needed by icall promotion
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 22 10:13:34 PST 2016
Author: davidxl
Date: Fri Jan 22 12:13:34 2016
New Revision: 258509
URL: http://llvm.org/viewvc/llvm-project?rev=258509&view=rev
Log:
[PGO] add an interface needed by icall promotion
Modified:
llvm/trunk/include/llvm/ProfileData/InstrProf.h
llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=258509&r1=258508&r2=258509&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Fri Jan 22 12:13:34 2016
@@ -305,6 +305,10 @@ public:
/// Return function's PGO name from the name's md5 hash value.
/// If not found, return an empty string.
inline StringRef getFuncName(uint64_t FuncMD5Hash);
+ /// Return the function's original assembly name by stripping off
+ /// the prefix attached (to symbols with priviate linkage). For
+ /// global functions, it returns the same string as getFuncName.
+ inline StringRef getOrigFuncName(uint64_t FuncMD5Hash);
/// Return the name section data.
inline StringRef getNameData() const { return Data; }
};
@@ -348,6 +352,16 @@ StringRef InstrProfSymtab::getFuncName(u
return StringRef();
}
+// See also getPGOFuncName implementation. These two need to be
+// matched.
+StringRef InstrProfSymtab::getOrigFuncName(uint64_t FuncMD5Hash) {
+ StringRef PGOName = getFuncName(FuncMD5Hash);
+ size_t S = PGOName.find_first_of(':');
+ if (S == StringRef::npos)
+ return PGOName;
+ return PGOName.drop_front(S + 1);
+}
+
struct InstrProfValueSiteRecord {
/// Value profiling data pairs at a given value site.
std::list<InstrProfValueData> ValueData;
Modified: llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/InstrProfTest.cpp?rev=258509&r1=258508&r2=258509&view=diff
==============================================================================
--- llvm/trunk/unittests/ProfileData/InstrProfTest.cpp (original)
+++ llvm/trunk/unittests/ProfileData/InstrProfTest.cpp Fri Jan 22 12:13:34 2016
@@ -642,8 +642,10 @@ TEST_F(InstrProfTest, instr_prof_symtab_
Function *F = M->getFunction(Funcs[I]);
ASSERT_TRUE(F != NULL);
std::string PGOName = getPGOFuncName(*F);
+ uint64_t Key = IndexedInstrProf::ComputeHash(PGOName);
ASSERT_EQ(StringRef(PGOName),
- ProfSymtab.getFuncName(IndexedInstrProf::ComputeHash(PGOName)));
+ ProfSymtab.getFuncName(Key));
+ ASSERT_EQ(StringRef(Funcs[I]), ProfSymtab.getOrigFuncName(Key));
}
}
More information about the llvm-commits
mailing list