John Criswell
2009-Oct-05 15:21 UTC
[LLVMdev] [Fwd: Re: problem with multiple LLVM passes]
Rakesh Komuravelli wrote:> Hi John, > > I am having the exact same problem. Let me answer the four questions > that you have asked.. > > 1) Are both passes included in the same dynamic library? If not, are > you loading their respective libraries with multiple -load options? > > Yes. I load both the libraries with two -load options. I see both the > passes listed when run opt with --help flagOkay. This means that both passes are loading successfully.> > 2) Do both passes have a static <Passname>::ID variable defined in their > respective .cpp files? > > Yes. I also tried initializing them with different values.Just to be paranoid: each pass is using its own ID varibles, correct?> > 3) Is LiveVars an analysis pass? Does it say that it preserves all > other passes in its getAnalysisUsage() method? If not, you could have a > dependency chain that never gets resolved. > > I inserted AU.setPreservesAll() in getAnalysisUsage of the first passI assume the first pass is an analysis pass that call AU.setPreservesAll(), and the second pass is a transform pass that preserves nothing. Is this correct?> > 4) Does opt print any error messages when loading the dynamic > library/libraries implementing your two passes? > > opt prints the following error message: > > opt: /home/sadve/komurav1/llvm/include/llvm/PassAnalysisSupport.h:53: > llvm::AnalysisUsage& llvm::AnalysisUsage::addRequiredID(const > llvm::PassInfo*): Assertion `ID && "Pass class not registered!"' failed. > > Any insight on what might be going wrong?So, my purpose in asking the above questions was to eliminate several possible causes. It looks like your passes are loading properly. I am assuming that each pass is using a separate ID variable, so that shouldn't the problem either. My only guess at this point is that it may be possible for there to be an unsolvable dependency in your passes. An example of this can occur when a transform pass doubles as an analysis pass: if the transform pass T invalidates an analysis pass A, and then another pass P requires both T and A, the pass manager hits a similar assertion because it can't schedule both T and A such that they are available simultaneously for pass P. A quick test to see if this is the problem is to make the transform pass preserve all other passes and then try running both the analysis pass and the transform pass. If it works, then there's a scheduling dependency problem. I'm forwarding this email to llvmdev in hopes that someone else has other ideas on how to debug this problem without diving into the pass manager internals. I can help you with that if necessary (I've done it before), but I'd like to avoid it if possible. -- John T.> Thanks, > Rakesh > > On Fri, Sep 11, 2009 at 2:36 PM, John Criswell <criswell at cs.uiuc.edu > <mailto:criswell at cs.uiuc.edu>> wrote: > > My reply button isn't working like it used to... > :) > > -- John T. > > > Susan Horwitz wrote: > > I'm trying to write two LLVM passes, one of which uses the > results of the > > other. The first is LiveVars and the second is RemoveUseless. > In the > > RemoveUseless class I have: > > > There's a number of things that could be going wrong. Here are some > questions to try to narrow down what might be the problem: > > 1) Are both passes included in the same dynamic library? If not, are > you loading their respective libraries with multiple -load options? > > 2) Do both passes have a static <Passname>::ID variable defined in > their > respective .cpp files? > > 3) Is LiveVars an analysis pass? Does it say that it preserves all > other passes in its getAnalysisUsage() method? If not, you could > have a > dependency chain that never gets resolved. > > 4) Does opt print any error messages when loading the dynamic > library/libraries implementing your two passes? > > -- John T. > > > virtual void getAnalysisUsage(AnalysisUsage &AU) const { > > AU.addRequired<LiveVars>(); > > } > > > > This compiles fine, but when I try to run it I get an error: > > Pass class not registered! > > > > The error goes away if I take out that "addRequired". > > > > The code for the LiveVars pass includes > > RegisterPass<LiveVars> X("liveVars", "Live vars analysis", > true, > > true); > > > > and I can run the LiveVars pass like this: > > opt -load Debug/lib/dataflowAnalysis.so -f -analyze > -liveVars ... > > > > I've tried running the RemoveUseless pass with various > combinations of flags > > (just -removeUseless, both -liveVars and -removeUseles, with and > without > > -analyze), but I always get the same error. > > > > > > Any help will be much appreciated! > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >