[llvm] r260361 - [PGO] fix prof symbol lookup bug

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 9 22:36:56 PST 2016


Author: davidxl
Date: Wed Feb 10 00:36:55 2016
New Revision: 260361

URL: http://llvm.org/viewvc/llvm-project?rev=260361&view=rev
Log:
[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.
 




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=260361&r1=260360&r2=260361&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Wed Feb 10 00:36:55 2016
@@ -379,7 +379,7 @@ StringRef InstrProfSymtab::getFuncName(u
       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();
 }

Modified: llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/InstrProfTest.cpp?rev=260361&r1=260360&r2=260361&view=diff
==============================================================================
--- llvm/trunk/unittests/ProfileData/InstrProfTest.cpp (original)
+++ llvm/trunk/unittests/ProfileData/InstrProfTest.cpp Wed Feb 10 00:36:55 2016
@@ -746,6 +746,12 @@ TEST_P(MaybeSparseInstrProfTest, instr_p
   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");




More information about the llvm-commits mailing list