I'm having trouble with using getAnalysis() to access the results of one pass from within another. I require the pass to be previously executed as follows: void MyPass::getAnalysisUsage(AnalysisUsage &Info) const { Info.addRequired<TDDataStructures>(); } Then I try to use it as follows: bool MyPass::doInitialization(Module &M) { TDDataStructures &dsgraph = getAnalysis<TDDataStructures>(); return false; } When I run my pass via opt, I get the following assertion error: Assertion failed: i != AnalysisImpls.size() && "getAnalysis*() called on an analysis that we not " "'required' by pass!", file ../../include/llvm/Pass.h, line 170 Any idea what I am doing wrong? Thanks, Scott Mikula
On Sun, 3 Nov 2002, Scott Mikula wrote:> I'm having trouble with using getAnalysis() to access the results of one > pass from within another. I require the pass to be previously executed > as follows: > > void MyPass::getAnalysisUsage(AnalysisUsage &Info) const { > Info.addRequired<TDDataStructures>(); > }Is that the only line you have? There may be some trouble if you also include a pass that invalidates TDDS before your pass can get to it. Unfortunately we don't have good diagnostics for this case yet.> Then I try to use it as follows: > bool MyPass::doInitialization(Module &M) { > TDDataStructures &dsgraph = getAnalysis<TDDataStructures>(); > return false; > }Hrm, with these two lines I don't see anything that could be wrong. If you're using doInitialization, I assume that you're using a FunctionPass. Although FunctionPass's should be able to require interprocedural Pass's, maybe it's causing a problem here. Try changing your pass to subclass Pass directly (and use run), and see if you can still reproduce it.> Any idea what I am doing wrong? Thanks,As far as I can tell, you aren't doing anything wrong. If the above doesn't help, please email me (privately) your pass code (whatever state it is in) so I can debug the situation. Thanks! -Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
Chris Lattner wrote:> On Sun, 3 Nov 2002, Scott Mikula wrote: > > I'm having trouble with using getAnalysis() to access the results of one > > pass from within another. I require the pass to be previously executed > > as follows: > > > > void MyPass::getAnalysisUsage(AnalysisUsage &Info) const { > > Info.addRequired<TDDataStructures>(); > > } > > Is that the only line you have? There may be some trouble if you also > include a pass that invalidates TDDS before your pass can get to it. > Unfortunately we don't have good diagnostics for this case yet. > > > Then I try to use it as follows: > > bool MyPass::doInitialization(Module &M) { > > TDDataStructures &dsgraph = getAnalysis<TDDataStructures>(); > > return false; > > } > > Hrm, with these two lines I don't see anything that could be wrong. If > you're using doInitialization, I assume that you're using a FunctionPass. > Although FunctionPass's should be able to require interprocedural Pass's, > maybe it's causing a problem here. Try changing your pass to subclass > Pass directly (and use run), and see if you can still reproduce it.Using a normal Pass instead of a FunctionPass seems to solve the problem. Should I just go ahead and implement my pass that way, or is there likely to be a solution to make it work with a FunctionPass? Scott Mikula