hi again :) On Tue, Apr 13, 2010 at 8:57 AM, ether zhhb <etherzhhb at gmail.com> wrote:> hi john, > > thanks very much, i will try it out. > > --best regards > ether > > > On Mon, Apr 12, 2010 at 10:03 PM, John Criswell <criswell at uiuc.edu> wrote: > >> ether zhhb wrote: >> >>> hi all, >>> >>> i have some thing not so sure about "scope" of llvm passes: >>> >>> suppose i have a function pass PassF and a BasicBlock analysis pass >>> PassB. if i want to use the analysis result of PassB for a BasicBlock in >>> PassF, i think i can create PassB in runOnFunction of PassF, and call >>> runOnBasicBlock manually to get the result: >>> >>> PassB pb; //create a PassB >>> //we also need consider the analysis usage of PassB >>> pb.runOnBasicBlock(bb); // run PassB on bb manually >>> .... use the result of pb ...... >>> >>> is there any other better way? >>> >> >> I think the correct way to do this is to declare PassB as a prerequisite >> pass in PassF's getAnalysisUsage() method and then to use >> getAnalysis<PassB>(BasicBlock * BB) in PassF. >> >> A ModulePass can use a FunctionPass, so I assume a FunctionPass can use a >> BasicBlockPass in this fashion. >> > that's because FunctionPass implement the "addLowerLevelRequiredPass"function, but others not. so, is there any special reason that only "addLowerLevelRequiredPass" is allow?> >> -- John T. > >--best regards ether -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100413/bdd7ae97/attachment.html>
yes i will :) On Tue, Apr 13, 2010 at 2:16 PM, Devang Patel <devang.patel at gmail.com>wrote:> On Mon, Apr 12, 2010 at 6:41 PM, ether zhhb <etherzhhb at gmail.com> wrote: > > > that's because FunctionPass implement the "addLowerLevelRequiredPass" > > function, but others not. > > > > so, is there any special reason that only "addLowerLevelRequiredPass" is > > allow? > > > > There is no reason to not allow it. It is not done because there was > not any use. If you need this then pl. prepare a patch! > > - > Devang >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100413/cf1306bf/attachment.html>
Devang Patel wrote:> On Mon, Apr 12, 2010 at 6:41 PM, ether zhhb <etherzhhb at gmail.com> wrote: > > >> that's because FunctionPass implement the "addLowerLevelRequiredPass" >> function, but others not. >> >> so, is there any special reason that only "addLowerLevelRequiredPass" is >> allow? >> >> > > There is no reason to not allow it. It is not done because there was > not any use. If you need this then pl. prepare a patch! >Alternatively, if you wrote the BasicBlock analysis pass, you could easily modify it to be a FunctionPass. Currently, I think this is a better alternative because: 1) It doesn't require patching LLVM (meaning that your passes can work with LLVM 2.7) 2) You will get better reusability of the analysis results. When a higher level pass calls a lower level pass (e.g., ModulePass calls FunctionPass), the lower level pass is run again, even if it was run previously and did not have its analysis results invalidated. If the passes are of the same level (e.g., FunctionPass requires FunctionPass), then the PassManager can avoid duplicate runs of the analysis pass if its results are not invalidated. -- John T.> - > Devang >