Help regarding profiling information

Hi,

I am trying to obtain basic block profiles for mediabench g721
benchmark. I have successfully built llvm in profile_enabling mode.
Then so as to find out the block execution frequency, I ran the
command, analyze encode.out-cbe. It generated gmon.out which I read
using gprof. However, I did not get the basic block level execution
frequency. Can anybody help me as to how I can extract the basic block
execution frequency using llvm?

Thanks
Murali

Hi,

I am trying to obtain basic block profiles for mediabench g721
benchmark. I have successfully built llvm in profile_enabling mode.

The ENABLE_PROFILE variable to make builds profiling mode for the LLVM
tools, not for the programs you process with those tools.

Then so as to find out the block execution frequency, I ran the
command, analyze encode.out-cbe. It generated gmon.out which I read
using gprof.

The gmon.out file is for the analyze program, not for the program you're
analyzing.

However, I did not get the basic block level execution
frequency. Can anybody help me as to how I can extract the basic block
execution frequency using llvm?

You need to use one of the instrumentation passes. In particular, the
block profiler, which can be found in
lib/Transforms/Instrumentation/BlockProfiling.cpp.

You can use it like this:

opt -insert-function-profiling -insert-block-profiling YourBytecode.bc > ProfiledBytecode.bc

This will insert the necessary instructions to do the profiling at run
time when you execute the program. You can then use llvm-prof to get the
profiling information.

To make all this easier, please review llvm/utils/profile.pl which is a
perl script that runs the necessary LLVM programs correctly to produce
the profiling information.