Thanks Alastair. Is it possible to associate the branch frequency counts with the basic blocks in the intermediate representation? (e.g. Can I access basic block frequencies in runOnFunction()?) Also, I was able to produce a 'llvmprof.out' file. What is the format of this file? How can I parse it? Thanks. -Apala> > > On 09/07/2012 01:25 PM, Alastair Murray wrote: > > Hi Apala, > > > > Do you mean is it possible to count branch taken/not-taken frequencies? > > > > If so then in the svn version (i.e. not 3.1) there is > > -profile-metadata-loader which sets branch weight metadata based on > > profiling data (compile with -insert-edge-profiling and run your > > program to generate that). > > > > Within 3.1 there is -profile-loader which sets block execution counts > > which can be used to infer branch taken/not-taken frequencies -- but > > the whole interface is not as friendly. > > > > Regards, > > Alastair. > > > > On 07/09/12 10:46, Apala Guha wrote: > >> Hi, > >> > >> Is there a way to count branch frequencies using LLVM infrastructure? > >> > >> Thanks. > >> > >> -Apala > >> > >> Postdoctoral Scholar > >> > >> Department of Computer Science, University of Chicago > >> > >> Computation Institute, Argonne National Laboratory > >> > >> http://sites.google.com/site/apalaguha/home/ > >> > >> > >> > >> _______________________________________________ > >> LLVM Developers mailing list > >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >> > > >
Hi Apala, On 11/09/12 11:20, apala guha wrote:> Is it possible to associate the branch frequency counts with the basic > blocks > in the intermediate representation? (e.g. Can I access basic block > frequencies in runOnFunction()?)Profile data really needs to be loaded at a module level, but once this has been done it can be accessed at any level (including function). In LLVM 3.1 ProfileInfo stores block execution frequencies (use -profile-loader). For LLVM svn you can look at BlockFrequencyInfo, which I generates its data from BranchFrequencyInfo, which in turn uses the branch weight metadata (set by -profile-metadata-loader). I haven't actually tried this though, so I'm not sure how accurately the block frequencies are maintained.> Also, I was able to produce a 'llvmprof.out' file. What is the format of > this file? How can I parse it?Very roughy the format of the file is lots of unsigned integers. -profile-loader or -preofile-metadata-loader will parse it for you. Parsing outside of LLVM is tricky as it relies on exact ordering of basic blocks. Regards, Alastair.
I tried getting profile data from LLVM 3.1, using the method mentioned below. I tried it out on a simple matrix multiplication program. However, I noticed the following problems: 1. There is a warning message: "WARNING: profile information is inconsistent with the current program!" 2. The basic block counts (obtained from ProfileInfo::getExecutionCount(const BasicBlock*)) are correct only if I have compiled with "-disable-opt" or "-O0". When compiled with "-O3", the basic block counts are bogus values. 3. Some of the function counts (obtained from ProfileInfo::getExecutionCount(const Function*)) are incorrect i.e. they do not equal the number of times the function was invoked. Can someone please explain why I am experiencing the above problems? Thanks in advance! -Apala On 09/12/2012 09:20 PM, Alastair Murray wrote:> Hi Apala, > > On 11/09/12 11:20, apala guha wrote: >> Is it possible to associate the branch frequency counts with the basic >> blocks >> in the intermediate representation? (e.g. Can I access basic block >> frequencies in runOnFunction()?) > > > Profile data really needs to be loaded at a module level, but once > this has been done it can be accessed at any level (including function). > > In LLVM 3.1 ProfileInfo stores block execution frequencies (use > -profile-loader). > > For LLVM svn you can look at BlockFrequencyInfo, which I generates its > data from BranchFrequencyInfo, which in turn uses the branch weight > metadata (set by -profile-metadata-loader). I haven't actually tried > this though, so I'm not sure how accurately the block frequencies are > maintained. > > >> Also, I was able to produce a 'llvmprof.out' file. What is the format of >> this file? How can I parse it? > > Very roughy the format of the file is lots of unsigned integers. > -profile-loader or -preofile-metadata-loader will parse it for you. > Parsing outside of LLVM is tricky as it relies on exact ordering of > basic blocks. > > Regards, > Alastair.