summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ProfileData/InstrProfTest.cpp
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-12-19 07:44:57 +0000
committerXinliang David Li <davidxl@google.com>2015-12-19 07:44:57 +0000
commit2ee5c4db1b8ba54798c42e9a0ff40695d9e83b17 (patch)
treee81a661af2a87048c8d3a10be7a203553b97a656 /llvm/unittests/ProfileData/InstrProfTest.cpp
parente069c4b6d14d54e1d6e7656316b67ea573a4d48e (diff)
downloadbcm5719-llvm-2ee5c4db1b8ba54798c42e9a0ff40695d9e83b17.tar.gz
bcm5719-llvm-2ee5c4db1b8ba54798c42e9a0ff40695d9e83b17.zip
[PGO] Add hash to name mapping in InstrProfSymtab
Creator and lookup interfaces are added to this symtab class. The new interfaces will be used by InstrProf Readers and writer. A unit test is also added for the new APIs. llvm-svn: 256092
Diffstat (limited to 'llvm/unittests/ProfileData/InstrProfTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/InstrProfTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index ee357053a17..994f75502d9 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -524,4 +524,28 @@ TEST_F(InstrProfTest, get_weighted_function_counts) {
ASSERT_EQ(20U, Counts[1]);
}
+TEST_F(InstrProfTest, instr_prof_symtab_test) {
+ std::vector<StringRef> FuncNames;
+ FuncNames.push_back("func1");
+ FuncNames.push_back("func2");
+ FuncNames.push_back("func3");
+ FuncNames.push_back("bar1");
+ FuncNames.push_back("bar2");
+ FuncNames.push_back("bar3");
+ InstrProfSymtab Symtab;
+ Symtab.create(FuncNames);
+ StringRef R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("func1"));
+ ASSERT_EQ(StringRef("func1"), R);
+ R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("func2"));
+ ASSERT_EQ(StringRef("func2"), R);
+ R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("func3"));
+ ASSERT_EQ(StringRef("func3"), R);
+ R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("bar1"));
+ ASSERT_EQ(StringRef("bar1"), R);
+ R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("bar2"));
+ ASSERT_EQ(StringRef("bar2"), R);
+ R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("bar3"));
+ ASSERT_EQ(StringRef("bar3"), R);
+}
+
} // end anonymous namespace
OpenPOWER on IntegriCloud