On Friday 26 November 2004 19:56, Chris Lattner wrote:> On Fri, 26 Nov 2004, Vladimir Prus wrote: > > in the implementation of some analysis, I need to change the program and > > then invoke Mem2Reg pass. That pass, in turn, requires other analysis, so > > I must > > Usually you want to do this at a higher level, why not just use 'opt > -yourpass -mem2reg'?Because my pass must first modify the code, then run mem2reg pass and then do some more work. There's absolutely no way it could work without mem2reg pass. (That's the value analysis path I talked about earlier).> Alternatively, if you don't want to do that, you can build mem2reg into > your pass if it works better. To do this, your pass needs to > 'addRequired' DominatorTree and DominatorFrontier, then use the > interfaces exposed through > include/llvm/Transforms/Utils/PromoteMemToReg.h.This still leaves the question of TargetData parameter -- which is not used by the PromoteMemToReg function, AFAICT. Passing *(TargetData*)0 is dirty. - Volodya
On Mon, 29 Nov 2004, Vladimir Prus wrote:> On Friday 26 November 2004 19:56, Chris Lattner wrote: > > On Fri, 26 Nov 2004, Vladimir Prus wrote: > > > in the implementation of some analysis, I need to change the program and > > > then invoke Mem2Reg pass. That pass, in turn, requires other analysis, so > > > I must > > > > Usually you want to do this at a higher level, why not just use 'opt > > -yourpass -mem2reg'? > > Because my pass must first modify the code, then run mem2reg pass and then do > some more work. There's absolutely no way it could work without mem2reg pass. > (That's the value analysis path I talked about earlier).ok> > Alternatively, if you don't want to do that, you can build mem2reg into > > your pass if it works better. To do this, your pass needs to > > 'addRequired' DominatorTree and DominatorFrontier, then use the > > interfaces exposed through > > include/llvm/Transforms/Utils/PromoteMemToReg.h. > > This still leaves the question of TargetData parameter -- which is not used by > the PromoteMemToReg function, AFAICT. Passing *(TargetData*)0 is dirty.Just addRequired<TargetData>(), and pass in getAnalysis<TargetData>() as appropriate. -Chris -- http://llvm.org/ http://nondot.org/sabre/
On Monday 29 November 2004 19:39, Chris Lattner wrote:> > > Alternatively, if you don't want to do that, you can build mem2reg into > > > your pass if it works better. To do this, your pass needs to > > > 'addRequired' DominatorTree and DominatorFrontier, then use the > > > interfaces exposed through > > > include/llvm/Transforms/Utils/PromoteMemToReg.h. > > > > This still leaves the question of TargetData parameter -- which is not > > used by the PromoteMemToReg function, AFAICT. Passing *(TargetData*)0 is > > dirty. > > Just addRequired<TargetData>(), and pass in getAnalysis<TargetData>() as > appropriate.This did not work for me -- it seems the "analyze" program does not provide any TargetData. Probably, analysis pass which modifies program is not typical, but then it's surely not transformation pass, either. - Volodya