Hi, all: I wanted to use a FunctionPass (e.g. *MemoryDependenceAnalysis*) in a ModulePass, and then I used the method "getAnalysis<* MemoryDependenceAnalysis*>(llvm::Function *)" described at http://llvm.org/docs/WritingAnLLVMPass.html#ModulePass to get the FunctionPass. But , it still crashed when I invoked this pass in tool 'opt'. However, if I change my pass to inherit from FunctionPass, then everything goes well. But I must use the ModulePass to solve my problem. What can I do now? Following is the project file and crash infomation. --------------------------------------part of my project file-------------------------------------------------------- *struct pFuncName : public ModulePass { ......* * virtual bool runOnModule(Module &M)* * { for(Module::iterator mib=M.begin(), mie=M.end(); mib!=mie; ++mib) { MemoryDependenceAnalysis &mda getAnalysis<MemoryDependenceAnalysis>(*f); // I have noticed * * ...... } return false; }* ** * void getAnalysisUsage(AnalysisUsage &AU) const* * { AU.addRequired<MemoryDependenceAnalysis>(); } };* -----------------------------------------------crash infomation---------------------------------------------------- *$ opt -load /home/****/llvm-2.5/Debug/lib/g_pFuncName.so -g_pFuncName < test.bc > /dev/null opt: /home/****/llvm-2.5/include/llvm/Target/TargetData.h:114: llvm::TargetData::TargetData(): Assertion `0 && "ERROR: Bad TargetData ctor used. " "Tool did not specify a TargetData to use?"' failed. 0 opt 0x08604986 1 opt 0x08604cc8 2 0x003ba400 __kernel_sigreturn + 0 3 libc.so.6 0x009cce28 abort + 392 4 libc.so.6 0x009c440e __assert_fail + 238 5 opt 0x08507bc5 llvm::Pass* llvm::callDefaultCtor<llvm::TargetData>() + 0 6 opt 0x08507be2 llvm::Pass* llvm::callDefaultCtor<llvm::TargetData>() + 29 7 opt 0x08596996 llvm::PassInfo::createPass() const + 126 8 opt 0x0859156a llvm::PMTopLevelManager::schedulePass(llvm::Pass*) + 284 9 opt 0x085915f1 llvm::PMTopLevelManager::schedulePass(llvm::Pass*) + 419 10 opt 0x0859b9ec llvm::FunctionPassManagerImpl::add(llvm::Pass*) + 30 11 opt 0x085917ab llvm::MPPassManager::addLowerLevelRequiredPass(llvm::Pass*, llvm::Pass*) + 315 12 opt 0x08592636 llvm::PMDataManager::add(llvm::Pass*, bool) + 816 13 opt 0x08592a81 llvm::ModulePass::assignPassManager(llvm::PMStack&, llvm::PassManagerType) + 137 14 opt 0x0859b8a9 llvm::PassManagerImpl::addTopLevelPass(llvm::Pass*) + 237 15 opt 0x08591642 llvm::PMTopLevelManager::schedulePass(llvm::Pass*) + 500 16 opt 0x0859b9cc llvm::PassManagerImpl::add(llvm::Pass*) + 30 17 opt 0x08591667 llvm::PassManager::add(llvm::Pass*) + 27 18 opt 0x082d10c2 19 opt 0x082d2f03 main + 3181 20 libc.so.6 0x009b66e5 __libc_start_main + 229 21 opt 0x082c4641 Aborted (core dumped) --------------------------------------------------------------------------------------------------------------- * ** Thanks a lot. gauss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090810/cd9142d0/attachment.html>
On Mon, Aug 10, 2009 at 3:35 AM, gauss<gausszhch at gmail.com> wrote:> Hi, all: > > I wanted to use a FunctionPass (e.g. MemoryDependenceAnalysis) in a > ModulePass, and then I used the method > "getAnalysis<MemoryDependenceAnalysis>(llvm::Function *)" described at > http://llvm.org/docs/WritingAnLLVMPass.html#ModulePass to get the > FunctionPass. But , it still crashed when I invoked this pass in tool 'opt'. > > However, if I change my pass to inherit from FunctionPass, then everything > goes well. But I must use the ModulePass to solve my problem. What can I do > now?As the docs say, the function pass must not require any other module pass (or immutable pass) here. This is a limitation of current implementation. I'll update docs to list "immutable pass" explicitly. - Devang
Hi, Devang. Thank you for your reply. But in my case, my ModulePass requires another FunctionPass (e.g. MemoryDependenceAnalysis) rather than the opposite direction. Is it also limited? - gauss Devang Patel-2 wrote:> > On Mon, Aug 10, 2009 at 3:35 AM, gauss<gausszhch at gmail.com> wrote: >> Hi, all: >> >> I wanted to use a FunctionPass (e.g. MemoryDependenceAnalysis) in a >> ModulePass, and then I used the method >> "getAnalysis<MemoryDependenceAnalysis>(llvm::Function *)" described at >> http://llvm.org/docs/WritingAnLLVMPass.html#ModulePass to get the >> FunctionPass. But , it still crashed when I invoked this pass in tool >> 'opt'. >> >> However, if I change my pass to inherit from FunctionPass, then >> everything >> goes well. But I must use the ModulePass to solve my problem. What can I >> do >> now? > > As the docs say, the function pass must not require any other module > pass (or immutable pass) here. This is a limitation of current > implementation. I'll update docs to list "immutable pass" explicitly. > > - > Devang > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://www.nabble.com/How-to-use-a-FunctionPass-in-a-ModulePass--tp24897593p24910475.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Apparently Analagous Threads
- [LLVMdev] How to use a FunctionPass in a ModulePass?
- [LLVMdev] How to use a FunctionPass in a ModulePass?
- [LLVMdev] pass utilizing MemoryDependenceAnalysis?
- [LLVMdev] pass utilizing MemoryDependenceAnalysis?
- [LLVMdev] pass utilizing MemoryDependenceAnalysis?