How to get profile information (original) (raw)
Hi all ,
I am studying how different the inputs are. Towards this , I had to generate a profile. LLVM tools provide me with the information of profiles as below:
My goal is to identify how much Profile A and Profile B differ. Are they same , equivalent, or different.
- Can anyone guide me the meaning of Counters in each function?
- Also, how can I get information about branch predictions? Branch predictions will provide me with information about branches taken or not taken.
- Blocks hotness in the CFG
- Call site counts
Any help will be appreciated .
soma_p April 27, 2025, 11:38pm 2
Hi All ,
How can I get all counters for a function :
Function execution counts - I can see from the profile
Basic Block execution counts
Branch probabilities
Callsite counts
Edge counts
Indirect call targets
Can Anyone guide me on how to get all the information from the profile file? I want to make a difference between one profile and another.
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
.
soma_p April 28, 2025, 2:12am 4
Hi Aiden ,
Thank you for your response.
I am currently working with instrumented PGO on benchmark programs. I generate executables for the program using 20 different inputs.
My goal is to analyze how different the 20 collected profiles are. Thus , I need to Extract all available profile information (in as much detail as possible) and Understand what optimizations are being applied based on the collected profile information.
Based on your response, what I have understood:
- If I generate the LLVM IR (
.ll
file) after applying the profile, I can use LLVM’s analysis passes to view the profile data in .ll file BlockFrequencyInfo (basic block hotness estimates).BranchProbabilityInfo (branch taken likelihoods). My question , is there any way to see using OPT tool, or will I just search BlockFrequencyInfo & BranchProbabilityInfo in .ll file? - I also generate final executables and extract the corresponding assembly from the binaries. I learned that it is possible to embed PGO profile information inside the binary’s ELF sections by enabling PGOAnalysisMap. This allows me to view and extract the profile data directly from the binary without needing the separate
.profdata
files - Can you guide me on how to enable PGOAnalysisMap during compilation (what specific flags to use) or in the code?
So that I can embed the full PGO profile information into the ELF binary, and later can see it easily.
On Sun, Apr 27, 2025 at 8:19 PM Aiden Grossman via LLVM Discussion Forums <notifications@llvm.discoursemail.com> wrote:
soma_p:
Can anyone guide me the meaning of Counters in each function?
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.
soma_p:
Also, how can I get information about branch predictions? Branch predictions will provide me with information about branches taken or not taken.
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 theBranchProbabilityInfo
analysis that will give you all that information.
soma_p:
Blocks hotness in the CFG
This can be obtained from the
BlockFrequencyInfo
analysis.
soma_p:
Call site counts
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.
soma_p:
Indirect call targets
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.
soma_p:
Can Anyone guide me on how to get all the information from the profile file? I want to make a difference between one profile and another.
If you’re working with IR, it’s easiest to just load the IR, ingest the profile, and then query
BranchProbabilityInfo
andBlockFrequencyInfo
to get what you need. If you’re looking at assembly, you can also usePGOAnalysisMap
by enabling it. Then you get an easily parseable ELF section containing all the profile data. It can also be read in line byllvm-readobj
andllvm-objdump
.
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
soma_p April 30, 2025, 8:51pm 5
Hi ,
I would appreciate any guidance or documentation on how to enable PGOAnalysisMap
to extract or visualize the parameters it uses to guide PGO-related decisions.
Any help would be greatly appreciated.
Thanks
Soma