[LLVMdev] counting branch frequencies

Alastair Murray alastairmurray42 at gmail.com
Wed Sep 19 09:27:16 PDT 2012


Hi Apala,

On 19/09/12 11:58, apala guha wrote:
> Another issue is with ProfileInfo::getExecutionCount(Function* F).
> Looking at the source code and results, I am seeing that it always
> returns the execution count of the entry basic block of the function. If
> the entry basic block is part of a loop, its execution count does not
> match the function invocation count.
>
> Is my assumption wrong, that ProfileInfo::getExecutionCount(Function* F)
> is supposed to return the function invocation count?
> If my assumption is not wrong, is there any way to fix the results?

Your assumption is correct.  It should be returning the execution count 
of the 0->entry edge (it is edges that are being profiled, but obviously 
the counters have to exist in basic blocks).

If entry is also part of a loop then that edge should be getting split. 
  It is possible that you have found a bug.  I will look into it, but 
not until the weekend at the earliest.  (Note: I'm not especially 
interested in fixing -profile-loader, but -profile-metadata-loader works 
is a similar manner, so it could also be affected.)

It is also possible this is still just a pass order issue.  I.e. the CFG 
has the same number of basic blocks so no issue is warned about, but the 
block layout is different so the counters do not match.  The profiling 
code is extremely fragile with respect to the CFG shape.

Regards,
Alastair.



More information about the llvm-dev mailing list