[LLVMdev] Controlling the order of a FunctionPass
John Criswell
criswell at illinois.edu
Thu Jul 29 15:24:15 PDT 2010
Trevor Harmon wrote:
> On Jul 23, 2010, at 7:36 AM, John Criswell wrote:
>
>
>> 2) For prerequisite *analysis* passes (like LoopInfo), your ModulePass
>> can declare them as prerequisites and get access to them using the
>> getAnalysis<PassName>(Function *) method.
>>
>
> Yes, I remember trying this before but was unsuccessful. I made a
> second attempt just now and am again running into the same issue:
>
> bool MyModulePass::runOnModule(Module &M) {
> for (Module::iterator i = M.begin(), e = M.end(); i != e; ++i) {
> Function *function = i;
> LoopInfo &loopInfo = getAnalysis<LoopInfo>(function);
> ...
> }
> ...
> }
>
> MyModulePass.cpp: In member function ‘virtual bool
> MyModulePass::runOnModule(llvm::Module&)’:
> MyModulePass.cpp:70: error: no matching function for call to
> ‘MyModulePass::getAnalysis(llvm::Function*&)’
>
> I believe I'm calling getAnalysis the same way as shown in "Writing an
> LLVM Pass", so I don't know what I'm doing wrong. (I thought perhaps I
> needed to call getAnalysis on the module reference, but it has no such
> member function.)
>
This form of getAnalysis takes a reference to a function and not a
pointer to it. The following should work:
LoopInfo &loopInfo = getAnalysis<LoopInfo>(*function);
-- John T.
> Any ideas? Thanks,
>
> Trevor
>
>
More information about the llvm-dev
mailing list