[LLVMdev] Using Profile Information
ambika
ambika at cse.iitb.ac.in
Fri Feb 26 02:34:39 PST 2010
I have not made a separate pass. I have done it in single pass ie added
ProfileLoaderPass , got information in PI and now I am planning to
perform the analysis here itself.
I was trying to print information using ProfileInfoPrinter pass but was
unable to do it.
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>();
}
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));
PI = &getAnalysis<ProfileInfo>();
}
};
}
char MyAna::ID = 0;
static RegisterPass<MyAna> X("my-ana", "Testing prof info");
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?
Andreas Neustifter wrote:
> Ah BTW...
>
> On 25.02.2010, at 17:33, ambika wrote:
>
>> ProfileInfo *PI;
>> PI = &getAnalysis<ProfileInfo>();
>
> If this _in_ your pass, then you have to register the usage of this in
> the getAnalysisUsage() method:
>
> void getAnalysisUsage(AnalysisUsage &AU) const {
> AU.addRequired<ProfileInfo>();
> }
>
> Also you have to ensure that the pass you are using is executed right
> after the ProfileInfoLoader, currently not all passes are preserving
> the profile information.
>
> If you need intermediate passes I already have a patch that preserves
> (most) of the information, I'm waiting for after 2.7 to put this in...
>
> Andi
More information about the llvm-dev
mailing list