[LLVMdev] Find all backedges of CFG by MachineDominatorTree. please look at my jpg.

任坤 hbrenkun at yahoo.cn
Mon Mar 8 20:17:28 PST 2010


Hi:
   I want to do some optimization on MachineLoop. 
So I want to get MachineLoopInfo from MachineFunction.

I reference MachineLICM.cpp. 
So I try to write a pass in Target/mytarget directory.
I find there is Error.
llvm/include/llvm/PassAnalysisSupport.h:198: AnalysisType& llvm::Pass::getAnalysisID(const llvm::PassInfo*) const [with AnalysisType = llvm::MachineLoopInfo]: Assertion `ResultPass && "getAnalysis*() called on an analysis that was not 'required' by pass!"' failed.

****************************
runOnMachineFunction(MachineFunction &MF) {
   LI = &getAnalysis<MachineLoopInfo>();
   DT = &getAnalysis<MachineDominatorTree>();

   for (MachineLoopInfo::iterator
          I = LI->begin(), E = LI->end(); I != E; ++I) {
    CurLoop = *I;
  }
}
******************************
I copy find from MachineLICM.cpp, and change class name.
What is different ??

Thanks.

Ren Kun




--- 10年1月26日,周二, Benoit Boissinot <bboissin+llvm at gmail.com> 写道:

> 发件人: Benoit Boissinot <bboissin+llvm at gmail.com>
> 主题: Re: [LLVMdev] Find all backedges of CFG by MachineDominatorTree.  please look at my jpg.
> 收件人: "任坤" <hbrenkun at yahoo.cn>
> 抄送: "llvm" <llvmdev at cs.uiuc.edu>
> 日期: 2010年1月26日,周二,下午10:13
> On Tue, Jan 26, 2010 at 10:04:16PM
> +0800, 浠诲潳   wrote:
> > Hi, Dear Boissinot:
> > 
> > 1. When I have irreducible CFG, I travel its nodes by
> DFS.
> >    search backedge for every node. After I
> finish one node,
> >    push it into a stack.
> >    [0, 1, 2, M]     
> <---push.
> >    [0, 1, 2, M,...N] <---push.
> >     
> >    When resolving node M, find a edge from
> node N to node M, 
> >    N is not in stack(M < N), It is a
> backedge.
> >    N is in stack(M > N), It is NOT a
> backedge.
> > 
> >    I treat these backedges as loop-edges. M
> is Loop header node.
> >    If I cut these edges from CFG, CFG can be
> topological sort.
>> >    Am I right??? 
> 
> yes, exactly.
> 
> regards,
> 
> Benoit
> 
> -- 
> :wq
>



      





More information about the llvm-dev mailing list