Hello. I'm using these commands to compile the code below in order to collect edge/blocks profiling: clang -emit-llvm -c sort.c -o sort.bc opt -insert-edge-profiling sort.bc -o sort_prof.bc clang sort_prof.bc -lprofile_rt -L/llvms/lib -o sort_prof then I run the program and display the profiling information using llvm-prof sort_prof.bc, and the result is: ===-------------------------------------------------------------------------==Function execution frequencies: ## Frequency 1. 4.3e+05/708539 main 2. 2.8e+05/708539 quickSort NOTE: 2 functions were never executed! ..... My question is regarding the execution frequencies. Does make any sense main executing 4.3e+05 times? Why so? The code I'm compiling is below. ###################### sort.c ######################## #include <stdio.h> #include <stdlib.h> #include <time.h> const int MAX = 1000000; void swap(int* a, int* b) { int tmp; tmp = *a; *a = *b; *b = tmp; } int partition(int vec[], int left, int right) { int i, j; i = left; for (j = left + 1; j <= right; ++j) { if (vec[j] < vec[left]) { ++i; swap(&vec[i], &vec[j]); } } swap(&vec[left], &vec[i]); return i; } void quickSort(int vec[], int left, int right) { int r; if (right > left) { r = partition(vec, left, right); quickSort(vec, left, r - 1); quickSort(vec, r + 1, right); } } int main(void) { int vet[MAX], i=0; srand(time(NULL)); for (i=0; i<MAX; i++) { vet[i] = rand() % 654321; } quickSort(vet, 0, MAX-1); for (i=0; i<MAX; i++) { if ((rand() % 7) > 2) { printf("Num$[%d] = %d\n", i, vet[i]); } else if ((rand() % 4) > 2) { printf("Num@[%d] = %d\n", i, vet[i]); } else if ((rand() % 2) > 1) { printf("Num#[%d] = %d\n", i, vet[i]); } } return 0; }
Hello, See answers below On 31/01/13 00:23, César wrote:> Hello. > > I'm using these commands to compile the code below in order to collect > edge/blocks profiling: > > clang -emit-llvm -c sort.c -o sort.bc > opt -insert-edge-profiling sort.bc -o sort_prof.bc > clang sort_prof.bc -lprofile_rt -L/llvms/lib -o sort_prof > > then I run the program and display the profiling information usingYou can also skip the compilation step and run directly through the interpreter lli -load /llvms/lib/libprofile_rt.so sort_prof.bc> llvm-prof sort_prof.bc, and the result is: >try running llvm-prof on the original (non instrumented) code, that should give you the correct results llvm-prof sort.bc Cheers, Roel
Hi Roel, many thanks, it worked perfectly now! César. 2013/1/31 Roel Jordans <r.jordans at tue.nl>:> Hello, > > See answers below > > > On 31/01/13 00:23, César wrote: >> >> Hello. >> >> I'm using these commands to compile the code below in order to collect >> edge/blocks profiling: >> >> clang -emit-llvm -c sort.c -o sort.bc >> opt -insert-edge-profiling sort.bc -o sort_prof.bc >> clang sort_prof.bc -lprofile_rt -L/llvms/lib -o sort_prof >> >> then I run the program and display the profiling information using > > > You can also skip the compilation step and run directly through the > interpreter > > lli -load /llvms/lib/libprofile_rt.so sort_prof.bc > > >> llvm-prof sort_prof.bc, and the result is: >> > > try running llvm-prof on the original (non instrumented) code, that should > give you the correct results > > llvm-prof sort.bc > > Cheers, > Roel > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev