How to count the number of **LLVM** instructions executed dynamically

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to count the number of **LLVM** instructions executed dynamically

Abhinash Jain
Hi,

I wanted to count the number of "LLVM" instruction executed dynamically in any program.

Have already tried "lli -stats -force-interpreter filename.bc", but it's not giving any information related to instruction count.

lli --version output:-
  LLVM version 3.4svn
  DEBUG build with assertions.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: corei7
Reply | Threaded
Open this post in threaded view
|

Re: How to count the number of **LLVM** instructions executed dynamically

John Criswell-4
Dear Abhinash,

You may need to build an instrumentation pass to do this. Fortunately,
such a pass should be trivial to write.

1) Your pass instruments each basic block to update a counter in a
global variable with the number of instructions found in that basic block.

2) You add a call to a run-time library function at the end of the
main() function of the program that prints the value in the global variable.

This may not work with a program that exits from a signal handler, but
you can make it more sophisticated if you need to do so (e.g., by using
atexit()).

Regards,

John Criswell

On 5/23/14, 8:03 PM, Abhinash Jain wrote:

> Hi,
>
> I wanted to count the number of "*LLVM*" instruction executed dynamically in
> any program.
>
> Have already tried "lli -stats -force-interpreter filename.bc", but it's not
> giving any information related to instruction count.
>
> lli --version output:-
>    LLVM version 3.4svn
>    DEBUG build with assertions.
>    Default target: x86_64-unknown-linux-gnu
>    Host CPU: corei7
>
>
>
>
> --
> View this message in context: http://llvm.1065342.n5.nabble.com/How-to-count-the-number-of-LLVM-instructions-executed-dynamically-tp68837.html
> Sent from the LLVM - Dev mailing list archive at Nabble.com.
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: How to count the number of **LLVM** instructions executed dynamically

Abhinash Jain
Hi John,

Thanks for your suggestion.

I'm just curious to know whether "lli -stats" also does the same thing or not?
Because I found on the internet that this command used to give dynamic instruction count as a output, along with some other details.
Unfortunately, In my version of lli (version 3.4), it gives all detail except instruction counts.
Reply | Threaded
Open this post in threaded view
|

Re: How to count the number of **LLVM** instructions executed dynamically

John Criswell-4
Dear Abhinash,

I do not know if lli -stats prints the dynamic instruction count
anymore; I haven't used lli in years.  Perhaps others on the list know.

Regards,

John Criswell

On 5/25/14, 6:22 AM, Abhinash Jain wrote:

> Hi John,
>
> Thanks for your suggestion.
>
> I'm just curious to know whether "lli -stats" also does the same thing or
> not?
> Because I found on the internet that this command used to give dynamic
> instruction count as a output, along with some other details.
> Unfortunately, In my version of lli (version 3.4), it gives all detail
> except instruction counts.
>
>
>
> --
> View this message in context: http://llvm.1065342.n5.nabble.com/How-to-count-the-number-of-LLVM-instructions-executed-dynamically-tp68837p68854.html
> Sent from the LLVM - Dev mailing list archive at Nabble.com.
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev