[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)

Mingming Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 12 12:34:23 PDT 2024


================
@@ -103,27 +114,226 @@ static cl::opt<bool>
     ICPDUMPAFTER("icp-dumpafter", cl::init(false), cl::Hidden,
                  cl::desc("Dump IR after transformation happens"));
 
+// Indirect call promotion pass will fall back to function-based comparison if
+// vtable-count / function-count is smaller than this threshold.
----------------
minglotus-6 wrote:

> Is this the sum counts of all vtables corresponding to a candidate function?

For hot basic blocks, the counters are on the order of O(100k) or higher, and the diff between vtable value profile counters and function value profile counters is minuscule.

For iFDO, the value profile counters are collected per instruction (as opposed to per basic block) by partially thread-safe function ['instrumentTargetValueImpl'](https://github.com/llvm/llvm-project/blob/31440738bd6b1345ea978914fe01d2e19f4aa373/compiler-rt/lib/profile/InstrProfilingValue.c#L150-L239) , so the code doesn't assume them to be identical.

For SamplePGO type profile (WIP), the total count of one instruction is the same as its basic block. So as long as 'vtable' and indirect call are in the same basic block, the sum would be identical (both are the count of basic block)

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


More information about the cfe-commits mailing list