Currently, I am working with version 3.0. I think it would be useful to make it work with new versions.
What i want to do is to apply edge and path profiling as it is explained in this report: http://llvm.org/pubs/2010-12-Preuss-PathProfiling.html
- naive edge profiling: (with -insert-edge-profiling)
opt -insert-edge-profiling -o matmul.ep.bc matmul.bc
lli -load …/lvm_build/Debug+Asserts/lib/libprofile_rt.so matmul.ep.bc
llvm-prof -annotated-llvm matmul.ep.bc
It seems ok. If you check output, you will see edge annotations are inserted in llvm-ir code. I do not think there is a formatted output for edge profiling ? (even though it says that there is a pass called -dot-edge-numbers (suppose to provide dot graph with edge annotations) in the document, the pass is not in current llvm dist. )
Or alternatively, one can run profile.pl script: profile.pl -annotated-llvm matmul.bc
- optimal edge profiling
opt -insert-optimal-edge-profiling -o matmul.oep.bc matmul.bc
lli -load …/lvm_build/Debug+Asserts/lib/libprofile_rt.so matmul.oep.bc
llvm-prof -annotated-llvm matmul.oep.bc
or alternatively profile.pl -annotated-llvm matmul.bc, but before running script, i modified the pass as
my $ProfilePass = “-insert-optimal-edge-profiling”;
both seems working well.
- Path profiling:
If i try to apply the command as i applied for edge profiling
opt -insert-path-profiling -o matmul.pp.bc matmul.bc
lli -load …/llvm_build/Debug+Asserts/lib/libprofile_rt.so matmul.pp.bc (produces llvmprof.out successfully)
llvm-prof: Unknown packet type #5!
I searched that line in the code, and found out that it is in llvm/lib/Analysis/ProfileInfoLoader.cpp
errs() << ToolName << “: Unknown packet type #” << PacketType << “!\n”;
This is where i stuck!
Furthermore, opt has some passes like:
-path-profile-loader - Load path profile information from file
-path-profile-verifier - Compare the path profile derived edge profile against the edge profile.
I have tried to use them, but, indeed, I am not sure how to use them.
I hope i made it clear enough my problem, your comments are very welcome.