LLVM Profiler uses 32-bit counters for Basic Blocks?

Hi all,

I’m doing some simple profiling with LLVM’s profile.pl script in the llvm/utils/ directory. Some of the applications that I’m profiling are potentially very large, which in turn leads to some basic blocks being executed more than ~4 Billion (i.e. 2^32) times. Apparently the internal counters used within this profiler have only 32 bits as evidenced by the following simple example:

//test.c
#include “stdio.h”
#include “stdlib.h”

int main(int argc, char **argv)
{
unsigned long i;
unsigned long bb_count=0;
for(i=0;i<4294967296;i++)
{
bb_count++;
}

fprintf(stdout,“BB count: %ld\n”,bb_count);

return 0;
}

$ clang -O0 -mllvm -disable-llvm-optzns test.c -emit-llvm -c -o test.bc
$ profile.pl test.bc
BB count: 4294967296