[clang-tools-extra] [clang] [llvm] [compiler-rt] [IRPGO][ValueProfile] Instrument virtual table address that could be used to do virtual table address comparision for indirect-call-promotion. (PR #66825)

Mingming Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 15 14:46:08 PST 2023


================
@@ -490,6 +591,23 @@ Error InstrProfSymtab::addFuncWithName(Function &F, StringRef PGOFuncName) {
   return Error::success();
 }
 
+uint64_t InstrProfSymtab::getVTableHashFromAddress(uint64_t Address) {
+  finalizeSymtab();
+  auto It = lower_bound(
+      VTableAddrRangeToMD5Map, Address,
----------------
minglotus-6 wrote:

New test case added in `value_prof_data_read_write_mapping` (in InstrProfTest.cpp) catches a subtle bug by `VTableRangeAddr.first.second < Addr`. Already fixed by using `VTableRangeAddr.first.second <= Addr`. 

Basically, the profiled address from a vtable should be in the range [VTableStartAddr, VTableEndAddr). In the unit test, each vtable has one function (no offset-to-top, no RTTI). Using `<` would map profiled address to the wrong vtable.

https://github.com/llvm/llvm-project/pull/66825


More information about the cfe-commits mailing list