[LLVMdev] Using Profile Information
Andreas Neustifter
astifter-llvm at gmx.at
Fri Feb 26 08:14:24 PST 2010
Hi!
On 02/26/2010 11:34 AM, ambika wrote:
>
> I was trying to print information using ProfileInfoPrinter pass but was
> unable to do it.
How did you try that? The ProfileInfoPrinter is local to the llvm-prof
tool, so you can not just use this pass, please try the llvm-prof tool
on your generated llvmprof.out and see if that output is fine.
If this output is not what you expect, please tell me the exact steps on
how you generate the profile...
>
> namespace {
> class MyAna : public ModulePass {
> ProfileInfo *PI;
> public:
> static char ID; // Class identification, replacement for typeinfo
> MyAna() : ModulePass(&ID) {}
>
> virtual void getAnalysisUsage(AnalysisUsage &AU) const {
> AU.setPreservesAll();
> AU.addRequired<ProfileInfo>();
> }
This looks fine to me, haven't tried to compile it tough...
>
> bool runOnModule(Module &M) {
> PassManager PassMgr = PassManager();
> cl::opt<std::string> ProfileDataFile(cl::Positional,
> cl::desc("<llvmprof.out file>"),
> cl::Optional, cl::init("llvmprof.out"));
> PassMgr.add(createProfileLoaderPass(ProfileDataFile));
You do not need to generate a PassManager inside your pass. This is all
handled by LLVM. You just request the analysis as above and fetch the
results with "getAnalysis<ProfileInfo>()".
> PI = &getAnalysis<ProfileInfo>();
Yes, exactly so. But to fully understand this please read carefully the
information provided in
http://llvm.org/docs/WritingAnLLVMPass.html#interaction
> What I basically want is to use block profile information in this pass
> to perform my analysis. Here I created llvmprof.out separately and then
> i am using it. Is there a way so that it is generated itself for the
> program?
I'm not sure if I understand you correctly, I have written quite a
detailed post on how to do profiling, maybe you can work trough this:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-November/026931.html
Attached in this message is also a profile.pl that does this all
automatically.
Andi
More information about the llvm-dev
mailing list