[LLVMdev] Number of instructions executed
Konstantin Tokarev
annulen at yandex.ru
Wed Jan 29 01:37:32 PST 2014
26.01.2014, 23:51, "JF Bastien" <jfb at google.com>:
>> I forget the name now, but there's an emulator which has this capability.
>> There's also performance counters available on some platforms that may give
>> you access to this. PAPI or perfmon2 may have this capability. I guess this
>> may not be exactly what you want, but hopefully it helps.
>
> Pin is probably the most straightforward way to obtain dynamic
> instruction count on x86. Valgrind/QEMU/DynamoRIO all have that
> capability, though I don't remember how easy it is to tease the
> information out of each tool.
Valgrind's tool Callgrind can show number of instructions executed between two
arbitrary points in code using so-called client requests [1].
Example:
#include <valgrind/callgrind.h>
void someFunction()
{
CALLGRIND_START_INSTRUMENTATION;
// code fragment where you'd like to measure instruction count
CALLGRIND_STOP_INSTRUMENTATION;
}
Then compile and run valgrind --tool=callgrind --instr-atstart=no ./yourprogram
to see number of instructions executed between start and stop points.
I have not tried this with JIT, but I guess it should work the same way:
start instrumentation between calling JIT'ed function, and stop it right
after this call.
[1] http://valgrind.org/docs/manual/cl-manual.html#cl-manual.clientrequests
--
Regards,
Konstantin
More information about the llvm-dev
mailing list