mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-04 08:16:49 +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. llvm-svn: 260361
This commit is contained in:
parent
dfe2156f1b
commit
86b4b91e35
@ -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…
x
Reference in New Issue
Block a user