Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting the number of LLVM instructions executed dynamically using LLI

I wanted to count the number of LLVM instruction executed dynamically in any program, using lli 3.4.

I checked this link, but it's not giving any information related to instruction count.

like image 650
Abhinash Jain Avatar asked May 29 '14 03:05

Abhinash Jain


1 Answers

There's no built-in way in LLVM to do this, AFAIK. However, you have a number of simple options:

  1. You can hack the interpreter (which lli can run) to count how many instructions it executed.
  2. You can instrument the IR before running it by incrementing a counter on entry to each basic block. Then you can run the instrumented IR through either the interpreter or JIT.
like image 92
Eli Bendersky Avatar answered Sep 30 '22 10:09

Eli Bendersky