Search code examples
cprofilingintel-pin

Why does the total number of instructions executed change in an empty C program?


I've been counting the instructions executed by an empty C program using Intel's Pin. Most of the time I get a total instruction count of 118724, but now and then the count goes up to 118770. What can be the reason for this change?

Code run: int main() {}


Solution

  • I feel like @Neitsa answered my question in their comment to the original post. I'll quote it here.

    But be wary that PIN starts very early in the process life, so it starts instrumenting everything the system loader is doing (basically in the libc). The fact that you have two different instruction count is probably due to a if / else branch somewhere in the ELF loading code (depending of the system state at a 't' time). If this bothers you you can restrict the instrumentation code to your own binary if you wish.