Introduction to the Profiling Infrastructure

Dear LLVM Developers:

I am an undergraduate summer research student supervised by José Nelson Amaral at the University of Alberta.

My work will primarily involve value profiling and path profiling. Andreas Neustifter is planning some changes to the profiling related code in LLVM (http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-February/020396.html). Are any of these changes in yet? Which transforms that use profiling information should I pay attention in order to learn the code related to profiling? Based on the overview of analyses and transformations, profile guided basic block placement (http://llvm.org/docs/Passes.html#block-placement) seems to be my best bet.

Hi all!

Slobodan Pejic wrote:

My work will primarily involve value profiling and path profiling. Andreas Neustifter is planning some changes to the profiling related code in LLVM (http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-February/020396.html). Are any of these changes in yet?

I spent some time learning C++ and llvm so there is nothing finished yet.

The only thing that is finished is a patch that bugfixes the profiling code
a little:

The ProfileInfoLoaderPass that feeds back the profiling information recorded
during a profiling run back into llvm only uses the edge count information.
This is fine since from edge counts the other information (block counts,
function counts) can be derived.

Unfortunately for functions with only one block, there are no edges so no
information is recorded or feed back at all.
In include/llvm/Analysis/ProfileInfo.h and lib/Analysis/ProfileInfo.cpp there
is the assumption that a virtual edge (0,<entry block>) exists which counts
the number of executions of the entry block (and consequently of the function).

My patch expands this concept of a (0,<entry block>) edge to the whole
profiling infrastructure: For each entry block an edge counter is generated
and this counter is also feed back into llvm into the appropriate data
structures.

The patch applies cleanly to latest SVN. Since I haven't seen the profiler-loader
used in the llvm-test suite, I tested my patch against the SPECCPU2000
benchmark with the use of a pass that verifies the profiles fed back against
Kirchhoff flow constraints. (Sum of counts of incoming edges equals
node count equals sum of counts of outgoing edges.) I also attach this verifier
as patch.

Which transforms that use profiling information should I pay attention in order to learn the code related to profiling? Based on the overview of analyses and transformations, profile guided basic block placement (http://llvm.org/docs/Passes.html#block-placement) seems to be my best bet.

Yes, as far as I saw this is the only pass that uses profiling information.

The other thing is passes that _destroy_ profiling information due to changes
made in a functions CFG. I will have to address this issue in the next weeks.

-- Andi

llvm-van.edge0.patch (7.18 KB)

llvm-van.profileverifier.patch (11.1 KB)