How to get profile information (original) (raw)
If you’re using instrumented PGO, counters are just instrumentation inserted to measure how frequently a piece of code executes. The instrumentation code is smart about where stuff gets inserted to try and reduce the runtime penalty.
The PGO infrastructure doesn’t currently have any information on branch predictions/mispredictions. There was a proposal a while ago to look at adding that information in as it can be useful for some optimizations (like cmov
vs branch decisions), but I don’t think it has gone anywhere. If you want information about what branches were taken or not taken, you can use the BranchProbabilityInfo
analysis that will give you all that information.
This can be obtained from the BlockFrequencyInfo
analysis.
This would just be the same as the block frequency if you’re looking at call instructions? You can additionally query function entry counts if you are interested in those, although they are not context sensitive with the current infrastructure.
This has to be done through instrumentation based value profiling. It should be available through some analysis, but I’m not exactly familiar with the APIs to query it, but they shouldn’t be hard to tease out of the IndirectCallPromotion
pass.
If you’re working with IR, it’s easiest to just load the IR, ingest the profile, and then query BranchProbabilityInfo
and BlockFrequencyInfo
to get what you need. If you’re looking at assembly, you can also use PGOAnalysisMap
by enabling it. Then you get an easily parseable ELF section containing all the profile data. It can also be read in line by llvm-readobj
and llvm-objdump
.