counting branch frequencies

Hi,

Is there a way to count branch frequencies using LLVM infrastructure?

Thanks.

-Apala

Postdoctoral Scholar

Department of Computer Science, University of Chicago

Computation Institute, Argonne National Laboratory

http://sites.google.com/site/apalaguha/home/

Hi Apala,

Do you mean is it possible to count branch taken/not-taken frequencies?

If so then in the svn version (i.e. not 3.1) there is -profile-metadata-loader which sets branch weight metadata based on profiling data (compile with -insert-edge-profiling and run your program to generate that).

Within 3.1 there is -profile-loader which sets block execution counts which can be used to infer branch taken/not-taken frequencies -- but the whole interface is not as friendly.

Regards,
Alastair.

Hi, sorry for the late reply.

You may be interested in a particular feature of Intel CPU's called
Branch Trace Store, which causes the CPU to trace branches that it
takes (and optionally filter them according to various criteria). It
is documented in Intel's manuals (Volume 3 IIRC)). One example of what
you can do with this is that you can have it log taken branches into a
buffer and then trigger an interrupt when the buffer is full; a
handler in the kernel can then aggregate the branches and pass that
information down to userland for consumption.

--Sean Silva