[LLVMdev] Questions !!

Chris Lattner sabre at nondot.org
Thu Apr 7 12:59:04 PDT 2005


On Thu, 7 Apr 2005, Tanu Sharma wrote:

> Thanks for the reply,
>
> Actually I m aiming towards determining two values:
>
> - number of basic blocks in a program For this I have used Statistic 
> facility provided in llvm and increasing the counter for each basic 
> block for each function.but for some reason , I m getting different 
> number everytime !! Is Statistic is the right way to do it ?

That should work fine.  Remember that statistics accumulate across the 
whole execution of the tool though, they are not reset per function. 
Also, you might want to check out the -instcount pass.  It prints BB 
counts among other things.

For a small .ll file, it prints:

$ llvm-as < t.ll | analyze -instcount -stats
Printing analysis 'Counts the various types of Instructions' for function 
'test':
===-------------------------------------------------------------------------===
                           ... Statistics Collected ...
===-------------------------------------------------------------------------===

1 instcount - Number of Cast insts
1 instcount - Number of Store insts
1 instcount - Number of SetLT insts
1 instcount - Number of Ret insts
1 instcount - Number of memory instructions
1 instcount - Number of non-external functions
1 instcount - Number of basic blocks
4 instcount - Number of instructions (of all types)


> - Average basic block size in a program ( in bytes)
> Any suggestions to make it simple and get an accurate result?

What are you trying to measure?  The in-memory footprint of hte LLVM IR? 
The number of bytecode bytes?  The number of machine code bytes for some 
target?

-Chris

>
> Regards,
> Tanu
>
>
> Chris Lattner <sabre at nondot.org> wrote:
> On Tue, 5 Apr 2005, Tanu Sharma wrote:
>
>> There is tool that calculates execution count and total number of blocks
>> , is there anything available to detemine size of basic blocks in a
>> program in bytes?
>
> Are you talking about native code? If you run the 'size' utility in unix,
> the 'tex' value is the number of bytes of program code. If you're talking
> about llvm code, I'm not sure what you mean "size of basic blocks in a
> program in bytes".
>
> -Chris
>
>

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list