mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-13 23:18:51 +00:00
[PGO] fix prof symbol lookup bug
Patch by Rong Xu The problem is exposed by intra-module indirect call promotion where prof symtab is created from module which does not contain all symbols from the program. With partial symtab, the result needs to be checked more strictly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260361 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fd0c395b22
commit
ebbb19e4e2
@ -379,7 +379,7 @@ StringRef InstrProfSymtab::getFuncName(uint64_t FuncMD5Hash) {
|
||||
std::lower_bound(MD5NameMap.begin(), MD5NameMap.end(), FuncMD5Hash,
|
||||
[](const std::pair<uint64_t, std::string> &LHS,
|
||||
uint64_t RHS) { return LHS.first < RHS; });
|
||||
if (Result != MD5NameMap.end())
|
||||
if (Result != MD5NameMap.end() && Result->first == FuncMD5Hash)
|
||||
return Result->second;
|
||||
return StringRef();
|
||||
}
|
||||
|
@ -746,6 +746,12 @@ TEST_P(MaybeSparseInstrProfTest, instr_prof_symtab_test) {
|
||||
R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("bar3"));
|
||||
ASSERT_EQ(StringRef("bar3"), R);
|
||||
|
||||
// negative tests
|
||||
R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("bar4"));
|
||||
ASSERT_EQ(StringRef(), R);
|
||||
R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("foo4"));
|
||||
ASSERT_EQ(StringRef(), R);
|
||||
|
||||
// Now incrementally update the symtab
|
||||
Symtab.addFuncName("blah_1");
|
||||
Symtab.addFuncName("blah_2");
|
||||
|
Loading…
Reference in New Issue
Block a user