summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-01-22 18:13:34 +0000
committerXinliang David Li <davidxl@google.com>2016-01-22 18:13:34 +0000
commit3865fdc4cc69d630de7ea3de6b22bdf73677b31b (patch)
tree7009ad5a85c498ef27996406a915117f919da70a
parent237b218770d8ca14dd0244f6ab889090ce482aae (diff)
downloadbcm5719-llvm-3865fdc4cc69d630de7ea3de6b22bdf73677b31b.tar.gz
bcm5719-llvm-3865fdc4cc69d630de7ea3de6b22bdf73677b31b.zip
[PGO] add an interface needed by icall promotion
llvm-svn: 258509
-rw-r--r--llvm/include/llvm/ProfileData/InstrProf.h14
-rw-r--r--llvm/unittests/ProfileData/InstrProfTest.cpp4
2 files changed, 17 insertions, 1 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index b8405f79fb2..e4d7d117520 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -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(uint64_t FuncMD5Hash) {
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;
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index bb9f1c7a2f7..77c2e0cebdf 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -642,8 +642,10 @@ TEST_F(InstrProfTest, instr_prof_symtab_module_test) {
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));
}
}
OpenPOWER on IntegriCloud