Joseph Reddington
2012-Sep-10 08:01 UTC
[LLVMdev] Profiling - execution count of basic blocks...
Hi gang, time for my weekly confusion... (I'm trying not to bombard the board with questions) The thing that's on my mind at the moment (there's some backend-stuff that I'm just working my way though) is that I'm not getting very far when trying to get LLVM to profile code - I'm looking for nothing more special than list of how many times each basic block has been called - but when wading though the docs I get lots of command line fragments that don't work and the distint impression that the method for profiling has changed three times in the last three release - I don't suppose that you have any insight into what's going on with profiling for llvm...? I'm starting to get the feeling that I've missed something obvious... My setup is: LLVM (http://llvm.org/): LLVM version 3.2svn DEBUG build with assertions. Built Jul 27 2012 (18:29:09). Default target: x86_64-apple-darwin11.4.0 Host CPU: corei7-avx Any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120910/0415d35f/attachment.html>
Das, Dibyendu
2012-Sep-10 08:52 UTC
[LLVMdev] Profiling - execution count of basic blocks...
We recently got some profiling going with llvm 3.1. (Alastair has got some code in for metadata generation after reading the profiled data(post 3.1) which you can follow in some of the earlier mail chains). I will describe the (earlier) 3.1 method which has worked for us. Note this is just a way of doing it. Not *the* way. Assume you are using clang/clang++ and have a set of C/C++ files: a) Run individual C/C++ files with : clang/clang++ -mllvm -emit-llvm -S -o x.o x.c/x.cpp b) Link all the .o s using llvm-link: llvm-link *.o -o X.o // new single X.o created c) Insert edge profiling: opt -O3 -insert-edge-profiling X.o -o X_prof.o d) llc X_prof.o // creates X_prof.o.s e) as X_prof.o.s // creates a.out f) clang/clang++ -o X_prof.exe a.out -lprofile_rt -L<path of your installed lib where libprofile_rt resides> //creates the instrumented binary X_prof.exe Now run the instrumented executable "X_prof.exe" using whatever input test data you have. This will create the llvmprof.out file. Create the new optimized executable after reading llvmprof.out: g) opt -O3 -profile-loader X.o -o X_opt.o // you can replace this with Alastair's profile loading step -profile-metadata-loader h) llc X_opt.o // creates X_opt.o.s i) as X_opt.o.s // creates a.out j) clang/clang++ -o X_opt.exe a.out -lprofile_rt -L<path of your installed lib where libprofile_rt resides> //creates the final optimized binary X_opt.exe Hope this helps. -Dibyendu From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Joseph Reddington Sent: Monday, September 10, 2012 1:32 PM To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] Profiling - execution count of basic blocks... Hi gang, time for my weekly confusion... (I'm trying not to bombard the board with questions) The thing that's on my mind at the moment (there's some backend-stuff that I'm just working my way though) is that I'm not getting very far when trying to get LLVM to profile code - I'm looking for nothing more special than list of how many times each basic block has been called - but when wading though the docs I get lots of command line fragments that don't work and the distint impression that the method for profiling has changed three times in the last three release - I don't suppose that you have any insight into what's going on with profiling for llvm...? I'm starting to get the feeling that I've missed something obvious... My setup is: LLVM (http://llvm.org/): LLVM version 3.2svn DEBUG build with assertions. Built Jul 27 2012 (18:29:09). Default target: x86_64-apple-darwin11.4.0 Host CPU: corei7-avx Any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120910/00c7f6e7/attachment.html>