[LLVMdev] about writing a functionpass requiring a modulepass

Qingan Li ww345ww at gmail.com
Mon May 30 02:15:25 PDT 2011


---------- Forwarded message ----------
From: Qingan Li <ww345ww at gmail.com>
Date: 2011/5/30
Subject:
To: llvmdev at cs.uiuc.edu



Hi,

I wrote an analysis pass, myPass, inherited from both  ModulePass and
ProfileInfo, and this pass requires the CallGraph, i.e.,
*  class myPass : public ModulePass, public ProfileInfo { ...};*
*  void myPass::getAnalysisUsage(AnalysisUsage &AU) const {*
*  AU.addRequired<CallGraph>();*
*  AU.setPreservesAll();*
*}*

Then, I assumes the UnreachableBlockElim (inherited from FunctionPass)
requires myPass, by revising the related function as follows:
 *UnreachableBlockElim::getAnalysisUsage(AnalysisUsage &AU) const { *
*      AU.addPreserved<DominatorTree>();*
*      AU.addPreserved<ProfileInfo>();*
*    AU.addRequired<StaticProfilePass>();*
*  *
*    }*

Then, i built it, it is OK. I went on to run it. It failed with a segment
error.
By debugging, it is found that in the following code from
*PMTopLevelManager::schedulePass(Pass
*P)*,
        *const PassInfo *PI =
PassRegistry::getPassRegistry()->getPassInfo(*I);*
*        AnalysisPass = PI->createPass();*

When this manager search for the CallGraph reqiured by myPass ( in the
failing trace , Pass *P is myPass), the return value of
*PassRegistry::getPassInfo(const
void *TI)* is NULL, thus the following dereference of PI is invalid.
I am using llvm 2.9, which is download from http://llvm.org/releases/.
Could anybody help me?



-- 
Best regards,

Li Qingan




-- 
Best regards,

Li Qingan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110530/30c003b3/attachment.html>


More information about the llvm-dev mailing list