[LLVMdev] profiling basic block frequency in LLVM3.1
patel rajendra
rdpatel55 at yahoo.co.in
Fri Nov 23 23:33:16 PST 2012
Dear All LLVM Users,
I'm new to LLVM environment. I want to perform basic block profiling. I'm using LLVM3.1
I tried it with a simple 'c' code to find Max.No, mentioned below.
-----------------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
int main()
{
unsigned int i,temp;
unsigned int num[50] = {25,35,66,789,999,23,0,1,24,44,100,20,50,1,37,299,400,900,255,1000,21,26,89,877,666,432,55,58,0,90,95,111,888,94,100,32,56,78,987,90,456,1234,95,45,25,97,99,34,56,23};
i = 0;
temp = 0;
while(i<50) { /* FIND THE MAX NUM FROM THE ARRAY*/
if(num[i] > temp){
temp = num[i];
}
i++;
}
printf("Max. Num. is : %d\n", temp);
return 0;
}
------------------------------------------------------------------------------------------------------------------------------------------------
However when I read llvmprof.out it produces following block frequencies.
Top 20 most frequently executed basic blocks:
## %% Frequency
1. 27.1429% 57/210 main() - if.end
2. 24.2857% 51/210 main() - while.cond
3. 23.8095% 50/210 main() - while.body
4. 20.4762% 43/210 main() - while.body.if.end_crit_edge
5. 3.33333% 7/210 main() - if.then
6. 0.47619% 1/210 main() - entry
7. 0.47619% 1/210 main() - while.end
-----------------------------------------------------------------------------------------------------------------------------------------------
The problem is with Basic Block : if.end (first block). Why does it execute 57 times? The i++ is also part of this block.
This shows an inconsistent profiling information.
Please, anyone help me to figure out where I'm doing wrong?
----------------------------------------------------------------------------------------------------------------------------------------------
Following commands are used for this profiling.
rdpatel55 at ubuntu:~/RDPATEL/LLVM3.1/RDSampleCode/test$ clang -O0 -emit-llvm -c -otest1.o test1.c
rdpatel55 at ubuntu:~/RDPATEL/LLVM3.1/RDSampleCode/test$ opt -disable-opt -insert-edge-profiling -o test1.o.inst test1.o
rdpatel55 at ubuntu:~/RDPATEL/LLVM3.1/RDSampleCode/test$ lli -O0 -fake-argv0 'test1.o' -load /home/rdpatel55/RDPATEL/LLVM3.1/LLVM_INSTALL_ROOT/lib/libprofile_rt.so test1.o.inst
Max. Num. is : 1234 (This is the o/p of the program)
rdpatel55 at ubuntu:~/RDPATEL/LLVM3.1/RDSampleCode/test$ llvm-prof --print-all-code test1.o.inst > bb_all.txt
---------------------------------------------------------------------------------------------------------------------------------------------------------
R.D.PATEL
Research Scholar,E.C.E. Department
MANIT, Bhopal
M:(91)8085090402, H:(91)8602677554
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121124/78e4222c/attachment.html>
More information about the llvm-dev
mailing list