Hi, I found an existing pass "CalledValuePropagation" that can solve the problem I raised a few days ago regarding the "callees" metadata ( https://groups.google.com/forum/#!topic/llvm-dev/yjtZVMH_aC4). Now I have difficulty in calling this pass in my own pass. In my own pass, I called "getAnalysis<CalledValuePropagationPass>()" and in the "getAnalysisUsage(AnalysisUsage &AU)" function, I called "AU.addRequired<CalledValuePropagationPass>();" I got compilation errors: ---------------------------------------------------------- ..... include/llvm/PassAnalysisSupport.h:223:38: error: ‘ID’ is not a member of ‘llvm::CalledValuePropagationPass’ return getAnalysisID<AnalysisType>(&AnalysisType::ID);\ ..... install/include/llvm/PassAnalysisSupport.h:67:39: error: ‘ID’ is not a member of ‘llvm::CalledValuePropagationPass’ return addRequiredID(PassClass::ID); ...... ----------------------------------------------------------- Looking at the source code of "CalledValuePropagationPass" ( http://llvm.org/doxygen/CalledValuePropagation_8h_source.html), I found that the class "CalledValuePropagationPass" does not have a public member "ID" as the passes in the "Transforms/Utils" directory. All the passes in the "IPO" directory only have a "run()" function that inherits from the "llvm/IR/PassManager.h". I am not quite sure how to invoke these passes in my own pass. I used "UnifyFunctionExitNodes" in my pass and this one worked fine. It will be a great help if anyone can point out how to call the "CalledValuePropagationPass" in my own pass. Thanks, Zi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190324/93d90de4/attachment.html>
> It will be a great help if anyone can point out how to call the"CalledValuePropagationPass" in my own pass You cant call passes from passes. You can only organize a pipeline, so passes are being run in succession. Just add CVP into pass manager before your own pass and you should be fine. Also, passes are not analyses and doing AU.addRequired on a pass is not a good idea (though sometimes this hack might seem to work). regards, Fedor. On 3/25/19 2:39 AM, Zi Wang via llvm-dev wrote:> Hi, > > I found an existing pass "CalledValuePropagation" that can solve the > problem I raised a few days ago regarding the "callees" metadata > (https://groups.google.com/forum/#!topic/llvm-dev/yjtZVMH_aC4). Now I > have difficulty in calling this pass in my own pass. > > In my own pass, I called > "getAnalysis<CalledValuePropagationPass>()" > > and in the "getAnalysisUsage(AnalysisUsage &AU)" function, I called > "AU.addRequired<CalledValuePropagationPass>();" > > I got compilation errors: > ---------------------------------------------------------- > ..... > include/llvm/PassAnalysisSupport.h:223:38: error: ‘ID’ is not a member > of ‘llvm::CalledValuePropagationPass’ > return getAnalysisID<AnalysisType>(&AnalysisType::ID);\ > ..... > install/include/llvm/PassAnalysisSupport.h:67:39: error: ‘ID’ is not a > member of ‘llvm::CalledValuePropagationPass’ > return addRequiredID(PassClass::ID); > ...... > ----------------------------------------------------------- > > Looking at the source code of "CalledValuePropagationPass" > (http://llvm.org/doxygen/CalledValuePropagation_8h_source.html), I > found that the class "CalledValuePropagationPass" does not have a > public member "ID" as the passes in the "Transforms/Utils" directory. > All the passes in the "IPO" directory only have a "run()" function > that inherits from the "llvm/IR/PassManager.h". I am not quite sure > how to invoke these passes in my own pass. I used > "UnifyFunctionExitNodes" in my pass and this one worked fine. > > It will be a great help if anyone can point out how to call the > "CalledValuePropagationPass" in my own pass. > > Thanks, > > Zi > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
On Mon, Mar 25, 2019 at 3:11 AM Zi Wang <wzahhq9 at gmail.com> wrote:> Thanks Fedor! > > I did not really use PassManager.h in the source code of my pass. I am > wondering when you mention "Just add CVP into pass manager before your own > pass and you should be fine." Do you mean Pass Manager on the pass source > code level, or use "opt" to call CVP first and then call my pass? If it is > at the source code level, do you know any pointer on how to arrange passes > using PassManager at the source code level? > > On Mon, Mar 25, 2019 at 2:46 AM Fedor Sergeev via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> > It will be a great help if anyone can point out how to call the >> "CalledValuePropagationPass" in my own pass >> >> You cant call passes from passes. >> You can only organize a pipeline, so passes are being run in succession. >> Just add CVP into pass manager before your own pass and you should be >> fine. >> >> Also, passes are not analyses and doing AU.addRequired on a pass is not >> a good idea >> (though sometimes this hack might seem to work). >> >> regards, >> Fedor. >> >> On 3/25/19 2:39 AM, Zi Wang via llvm-dev wrote: >> > Hi, >> > >> > I found an existing pass "CalledValuePropagation" that can solve the >> > problem I raised a few days ago regarding the "callees" metadata >> > (https://groups.google.com/forum/#!topic/llvm-dev/yjtZVMH_aC4). Now I >> > have difficulty in calling this pass in my own pass. >> > >> > In my own pass, I called >> > "getAnalysis<CalledValuePropagationPass>()" >> > >> > and in the "getAnalysisUsage(AnalysisUsage &AU)" function, I called >> > "AU.addRequired<CalledValuePropagationPass>();" >> > >> > I got compilation errors: >> > ---------------------------------------------------------- >> > ..... >> > include/llvm/PassAnalysisSupport.h:223:38: error: ‘ID’ is not a member >> > of ‘llvm::CalledValuePropagationPass’ >> > return getAnalysisID<AnalysisType>(&AnalysisType::ID);\ >> > ..... >> > install/include/llvm/PassAnalysisSupport.h:67:39: error: ‘ID’ is not a >> > member of ‘llvm::CalledValuePropagationPass’ >> > return addRequiredID(PassClass::ID); >> > ...... >> > ----------------------------------------------------------- >> > >> > Looking at the source code of "CalledValuePropagationPass" >> > (http://llvm.org/doxygen/CalledValuePropagation_8h_source.html), I >> > found that the class "CalledValuePropagationPass" does not have a >> > public member "ID" as the passes in the "Transforms/Utils" directory. >> > All the passes in the "IPO" directory only have a "run()" function >> > that inherits from the "llvm/IR/PassManager.h". I am not quite sure >> > how to invoke these passes in my own pass. I used >> > "UnifyFunctionExitNodes" in my pass and this one worked fine. >> > >> > It will be a great help if anyone can point out how to call the >> > "CalledValuePropagationPass" in my own pass. >> > >> > Thanks, >> > >> > Zi >> > >> > _______________________________________________ >> > LLVM Developers mailing list >> > llvm-dev at lists.llvm.org >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190325/9974dc38/attachment.html>
Fedor Sergeev via llvm-dev
2019-Mar-25 08:34 UTC
[llvm-dev] Fwd: call an existing IPO pass
Generally, passes are viewed as rather independent transformations of IR, so they can be run in any order w/o breaking correctness of transformations. (there are exceptions to that but they are, well, exceptions). If you need a particular order of passes for correctness of your pass then you better reconsider if ever possible. Yet, as you might imagine, the order of passes matters for the quality of optimizations. And thats where Pass Manager comes into play, as it controls all the aspects of passes execution. So if you need a particular order of passes for the - you set up your Pass Manager appropriately. With "opt" the order in which it adds passes to Pass Manager is determined by the order of command-line pass options: opt -cvp -your-pass will execute first cvp and then your pass. regards, Fedor. On 3/25/19 11:14 AM, Zi Wang via llvm-dev wrote> > On Mon, Mar 25, 2019 at 3:11 AM Zi Wang <wzahhq9 at gmail.com > <mailto:wzahhq9 at gmail.com>> wrote: > > Thanks Fedor! > > I did not really use PassManager.h in the source code of my pass. > I am wondering when you mention "Just add CVP into pass manager > before your own pass and you should be fine." Do you mean Pass > Manager on the pass source code level, or use "opt" to call CVP > first and then call my pass? If it is at the source code level, do > you know any pointer on how to arrange passes using PassManager at > the source code level? > > On Mon, Mar 25, 2019 at 2:46 AM Fedor Sergeev via llvm-dev > <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: > > > It will be a great help if anyone can point out how to call > the > "CalledValuePropagationPass" in my own pass > > You cant call passes from passes. > You can only organize a pipeline, so passes are being run in > succession. > Just add CVP into pass manager before your own pass and you > should be fine. > > Also, passes are not analyses and doing AU.addRequired on a > pass is not > a good idea > (though sometimes this hack might seem to work). > > regards, > Fedor. > > On 3/25/19 2:39 AM, Zi Wang via llvm-dev wrote: > > Hi, > > > > I found an existing pass "CalledValuePropagation" that can > solve the > > problem I raised a few days ago regarding the "callees" > metadata > > > (https://groups.google.com/forum/#!topic/llvm-dev/yjtZVMH_aC4). > Now I > > have difficulty in calling this pass in my own pass. > > > > In my own pass, I called > > "getAnalysis<CalledValuePropagationPass>()" > > > > and in the "getAnalysisUsage(AnalysisUsage &AU)" function, I > called > > "AU.addRequired<CalledValuePropagationPass>();" > > > > I got compilation errors: > > ---------------------------------------------------------- > > ..... > > include/llvm/PassAnalysisSupport.h:223:38: error: ‘ID’ is > not a member > > of ‘llvm::CalledValuePropagationPass’ > > return getAnalysisID<AnalysisType>(&AnalysisType::ID);\ > > ..... > > install/include/llvm/PassAnalysisSupport.h:67:39: error: > ‘ID’ is not a > > member of ‘llvm::CalledValuePropagationPass’ > > return addRequiredID(PassClass::ID); > > ...... > > ----------------------------------------------------------- > > > > Looking at the source code of "CalledValuePropagationPass" > > > (http://llvm.org/doxygen/CalledValuePropagation_8h_source.html), > I > > found that the class "CalledValuePropagationPass" does not > have a > > public member "ID" as the passes in the "Transforms/Utils" > directory. > > All the passes in the "IPO" directory only have a "run()" > function > > that inherits from the "llvm/IR/PassManager.h". I am not > quite sure > > how to invoke these passes in my own pass. I used > > "UnifyFunctionExitNodes" in my pass and this one worked fine. > > > > It will be a great help if anyone can point out how to call the > > "CalledValuePropagationPass" in my own pass. > > > > Thanks, > > > > Zi > > > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190325/c91cac99/attachment.html>