[llvm] [compiler-rt] [clang] [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 llvm-commits llvm-commits at lists.llvm.org
Wed Nov 1 16:11:31 PDT 2023


================
@@ -1,7 +1,7 @@
 RUN: %clang_pgogen -O2 -fuse-ld=bfd -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -DSTRESS=1 -o %t.ir.warn  %S/../Inputs/instrprof-value-prof-real.c
 RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255  %run %t.ir.warn 2>&1 |FileCheck --check-prefix=WARNING %s
 #  Test that enough static counters have been allocated
-RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=130  %run %t.ir.warn 2>&1 |FileCheck --check-prefix=NOWARNING --allow-empty %s
+RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=80  %run %t.ir.warn 2>&1 |FileCheck --check-prefix=NOWARNING --allow-empty %s
----------------
minglotus-6 wrote:

The TL,DR is this change is only needed when `enable-vtable-value-profiling` is true. Undo this change since `enable-vtable-value-profiling` is false by default.


This test expects errors like "LLVM Profile Warning: Unable to track new values: Running out of static counters.  Consider using option -mllvm -vp-counters-per-site=<n> to allocate more value profile counters at compile time." when `LLVM_VP_MAX_NUM_VALS_PER_SITE` (the max number of allocated counters per instrumented site) is 255, and expects no such warnings when the env var is set to 130.
- The number of indirect callees in the tested c file is [approximately 255](https://github.com/llvm/llvm-project/blob/ec350ad418a24f70c88758259c774a1e11c06d74/compiler-rt/test/profile/Inputs/instrprof-value-prof-real.c#L75-L328).

With `vp-static-alloc=true`, the number of counters is the `min(10, the number of instrumented sites in the function IR * the value of vp-counters-per-site`,  computed at compile time [here](https://github.com/llvm/llvm-project/blob/ec350ad418a24f70c88758259c774a1e11c06d74/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp#L1402-L1412); and `LLVM_VP_MAX_NUM_VALS_PER_SITE` specifies the max number of collected values per site at runtime; when a site runs out of nodes, the coldest ones are [evicted first](https://github.com/llvm/llvm-project/blob/ec350ad418a24f70c88758259c774a1e11c06d74/compiler-rt/lib/profile/InstrProfilingValue.c#L178-L215). Without the refinement to insert type intrinsics and pick instrumentation points precisely, `enable-vtable-value-profiling` means false positives takes up some counters and thereby the need to reduce `LLVM_VP_MAX_NUM_VALS_PER_SITE` to make the test pass.



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


More information about the llvm-commits mailing list