Hi All, When I use llvm, I encounter a problem like "unable to schedule pass A required by C" I investigated deeper. It's like: I have three passes, say A, B, C(all are on function level) A would modify IR code. (change instruction order) For pass B, I would use the result of pass A, I use addRequired<B>(), and &getAnalysis<B>(), it works. void getAnalysisUsage(AU){ AU.addRequired<A>(); } For pass C, it will use the results of pass A and B. I use the way as used for pass B, but it failed, even for LoopInfo analysis pass(which is the built-in analysis pass). void getAnalysisUsage(AU){ AU.addRequired<A>(); AU.addRequired<B>(); } It seems because A would modify IR code, so for pass C, I need first load pass A then pass B, otherwise it will be invalidated. However, when I change the using order, I still got error "unable to schedule pass A required by C". Does anyone encounter the same problem before and have a solution? Any help is appreciated. Best, Yuxi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160619/974a88e1/attachment.html>
On Sun, Jun 19, 2016 at 05:44:01AM +0000, Yuxi Chen via llvm-dev wrote:> Hi All, > > When I use llvm, I encounter a problem like "unable to schedule pass A required by C" > I investigated deeper. It's like: > I have three passes, say A, B, C(all are on function level) > A would modify IR code. (change instruction order) > > For pass B, > I would use the result of pass A, I use addRequired<B>(), and &getAnalysis<B>(), it works. > > void getAnalysisUsage(AU){ > AU.addRequired<A>(); > } > > > For pass C, it will use the results of pass A and B. > I use the way as used for pass B, but it failed, even for LoopInfo analysis pass(which is the built-in analysis pass). > void getAnalysisUsage(AU){ > AU.addRequired<A>(); > AU.addRequired<B>(); > } > > > It seems because A would modify IR code, so for pass C, I need first load pass A then pass B, otherwise it will be invalidated. > However, when I change the using order, I still got error "unable to schedule pass A required by C". > > Does anyone encounter the same problem before and have a solution? > Any help is appreciated.Hi, It looks like A is not an analyse, as it modifies IR code, while analysis don't modify IR. You cannot specify this kind of dependencies in the getAnalysisUsage method. What you can do though is create a pass ABC that spawns a new Passmanager that calls A, B and C in that order, something like: llvm::legacy::FunctionPassManager FPM(Module); FPM.add(createA()); FPM.add(createB()); FPM.add(createC()); bool modified = false; modified |= FPM.doInitialization(); for (Function &F : Module) modified |= FPM.run(F); modified |= FPM.doFinalization();
> On Jun 18, 2016, at 10:44 PM, Yuxi Chen via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi All, > > When I use llvm, I encounter a problem like "unable to schedule pass A required by C" > I investigated deeper. It's like: > I have three passes, say A, B, C(all are on function level) > A would modify IR code. (change instruction order) > > For pass B, > I would use the result of pass A, I use addRequired<B>(), and &getAnalysis<B>(), it works. > > void getAnalysisUsage(AU){ > AU.addRequired<A>(); > } > > > For pass C, it will use the results of pass A and B. > I use the way as used for pass B, but it failed, even for LoopInfo analysis pass(which is the built-in analysis pass). > void getAnalysisUsage(AU){ > AU.addRequired<A>(); > AU.addRequired<B>(); > } > > > It seems because A would modify IR code, so for pass C, I need first load pass A then pass B, otherwise it will be invalidated. > However, when I change the using order, I still got error "unable to schedule pass A required by C". > > Does anyone encounter the same problem before and have a solution? > Any help is appreciated.Depending on other transformations isn’t recommended, and isn’t supported by the soon-new-passmanager I believe. The expectation is that the passes are added in order to the pass manager by the client. In you case, I expect that it would “work” by removing the dependency from C to A. If C requires B and B requires A, by scheduling C you’ll get A, B, C in sequence. — Mehdi> > Best, > Yuxi > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://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/20160619/ca392317/attachment-0001.html>
> On Jun 19, 2016, at 12:59 AM, serge guelton via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > On Sun, Jun 19, 2016 at 05:44:01AM +0000, Yuxi Chen via llvm-dev wrote: >> Hi All, >> >> When I use llvm, I encounter a problem like "unable to schedule pass A required by C" >> I investigated deeper. It's like: >> I have three passes, say A, B, C(all are on function level) >> A would modify IR code. (change instruction order) >> >> For pass B, >> I would use the result of pass A, I use addRequired<B>(), and &getAnalysis<B>(), it works. >> >> void getAnalysisUsage(AU){ >> AU.addRequired<A>(); >> } >> >> >> For pass C, it will use the results of pass A and B. >> I use the way as used for pass B, but it failed, even for LoopInfo analysis pass(which is the built-in analysis pass). >> void getAnalysisUsage(AU){ >> AU.addRequired<A>(); >> AU.addRequired<B>(); >> } >> >> >> It seems because A would modify IR code, so for pass C, I need first load pass A then pass B, otherwise it will be invalidated. >> However, when I change the using order, I still got error "unable to schedule pass A required by C". >> >> Does anyone encounter the same problem before and have a solution? >> Any help is appreciated. > > Hi, > > It looks like A is not an analyse, as it modifies IR code, while > analysis don't modify IR. You cannot specify this kind of dependencies > in the getAnalysisUsage method. > > What you can do though is create a pass ABC that spawns a new > Passmanager that calls A, B and C in that order, something like: > > llvm::legacy::FunctionPassManager FPM(Module); > FPM.add(createA()); > FPM.add(createB()); > FPM.add(createC()); > > bool modified = false; > modified |= FPM.doInitialization(); > for (Function &F : Module) > modified |= FPM.run(F); > modified |= FPM.doFinalization();Indeed, this would work quite elegantly. However be aware that it prevents from sharing analyses (easily…) with the outer pass-manager, so it can cost some compile time. I think it should be possible to set it up in a nicer way with the new pass manager though. — Mehdi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160619/0c9810e6/attachment.html>
On 6/19/16 4:28 AM, Mehdi Amini via llvm-dev wrote:> >> On Jun 18, 2016, at 10:44 PM, Yuxi Chen via llvm-dev >> <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: >> >> Hi All, >> >> When I use llvm, I encounter a problem like "unable to schedule pass >> A required by C" >> I investigated deeper. It's like: >> I have three passes, say A, B, C(all are on function level) >> A would modify IR code. (change instruction order) >> >> For pass B, >> I would use the result of pass A, I use addRequired<B>(), and >> &getAnalysis<B>(), it works. >> >> void getAnalysisUsage(AU){ >> AU.addRequired<A>(); >> } >> >> >> For pass C, it will use the results of pass A and B. >> I use the way as used for pass B, but it failed, even for LoopInfo >> analysis pass(which is the built-in analysis pass). >> void getAnalysisUsage(AU){ >> AU.addRequired<A>(); >> AU.addRequired<B>(); >> } >> >> >> It seems because A would modify IR code, so for pass C, I need first >> load pass A then pass B, otherwise it will be invalidated. >> However, when I change the using order, I still got error "unable to >> schedule pass A required by C". >> >> Does anyone encounter the same problem before and have a solution? >> Any help is appreciated. > > Depending on other transformations isn’t recommended, and isn’t > supported by the soon-new-passmanager I believe. > The expectation is that the passes are added in order to the pass > manager by the client.Depending on transformation passes isn't supported by the legacy PassManager, either. Occasionally some passes can get away with it, but it often results in unschedule-able pass pipelines as above. If your transform pass does something to the code, other passes should either infer what it did by examining the IR. the IR contains the definitive information about the program (because it is the program). Alternatively, you could create an analysis pass upon which both your transform and analysis passes depend. The transform pass would update this new analysis pass with information on what it transformed; your later analysis passes could then query this information. This approach is fragile, but it could work. Regards, John Criswell> > In you case, I expect that it would “work” by removing the dependency > from C to A. If C requires B and B requires A, by scheduling C you’ll > get A, B, C in sequence. > > — > Mehdi > > > >> >> Best, >> Yuxi >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- John Criswell Assistant Professor Department of Computer Science, University of Rochester http://www.cs.rochester.edu/u/criswell -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160619/4d4e8fa1/attachment.html>
Hi Mehdi, Thanks for your reply. However, when I remove dependency from C to A, the problem is still here. Best, Yuxi ________________________________ From: mehdi.amini at apple.com [mehdi.amini at apple.com] Sent: Sunday, June 19, 2016 4:28 AM To: Yuxi Chen Cc: llvmdev at cs.uiuc.edu; llvm-dev at lists.llvm.org; llvmdev-bounces at cs.uiuc.edu Subject: Re: [llvm-dev] pass invalidation On Jun 18, 2016, at 10:44 PM, Yuxi Chen via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: Hi All, When I use llvm, I encounter a problem like "unable to schedule pass A required by C" I investigated deeper. It's like: I have three passes, say A, B, C(all are on function level) A would modify IR code. (change instruction order) For pass B, I would use the result of pass A, I use addRequired<B>(), and &getAnalysis<B>(), it works. void getAnalysisUsage(AU){ AU.addRequired<A>(); } For pass C, it will use the results of pass A and B. I use the way as used for pass B, but it failed, even for LoopInfo analysis pass(which is the built-in analysis pass). void getAnalysisUsage(AU){ AU.addRequired<A>(); AU.addRequired<B>(); } It seems because A would modify IR code, so for pass C, I need first load pass A then pass B, otherwise it will be invalidated. However, when I change the using order, I still got error "unable to schedule pass A required by C". Does anyone encounter the same problem before and have a solution? Any help is appreciated. Depending on other transformations isn’t recommended, and isn’t supported by the soon-new-passmanager I believe. The expectation is that the passes are added in order to the pass manager by the client. In you case, I expect that it would “work” by removing the dependency from C to A. If C requires B and B requires A, by scheduling C you’ll get A, B, C in sequence. — Mehdi Best, Yuxi _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> http://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/20160620/9874b71f/attachment.html>
Hi, Thanks for your reply. You mean I can write a new Pass to change the FunctionPassManager, but where I need put my analysis pass(A,B,C). I mean I am not clear about the relationship between the new-created pass ABC and A,B,C. As for other built-in passes, like LoopInfo, how need I handle them. Seem I mess all stuff up. Best, Yuxi ________________________________________ From: llvm-dev [llvm-dev-bounces at lists.llvm.org] on behalf of serge guelton via llvm-dev [llvm-dev at lists.llvm.org] Sent: Sunday, June 19, 2016 2:59 AM To: Yuxi Chen via llvm-dev Subject: Re: [llvm-dev] pass invalidation On Sun, Jun 19, 2016 at 05:44:01AM +0000, Yuxi Chen via llvm-dev wrote:> Hi All, > > When I use llvm, I encounter a problem like "unable to schedule pass A required by C" > I investigated deeper. It's like: > I have three passes, say A, B, C(all are on function level) > A would modify IR code. (change instruction order) > > For pass B, > I would use the result of pass A, I use addRequired<B>(), and &getAnalysis<B>(), it works. > > void getAnalysisUsage(AU){ > AU.addRequired<A>(); > } > > > For pass C, it will use the results of pass A and B. > I use the way as used for pass B, but it failed, even for LoopInfo analysis pass(which is the built-in analysis pass). > void getAnalysisUsage(AU){ > AU.addRequired<A>(); > AU.addRequired<B>(); > } > > > It seems because A would modify IR code, so for pass C, I need first load pass A then pass B, otherwise it will be invalidated. > However, when I change the using order, I still got error "unable to schedule pass A required by C". > > Does anyone encounter the same problem before and have a solution? > Any help is appreciated.Hi, It looks like A is not an analyse, as it modifies IR code, while analysis don't modify IR. You cannot specify this kind of dependencies in the getAnalysisUsage method. What you can do though is create a pass ABC that spawns a new Passmanager that calls A, B and C in that order, something like: llvm::legacy::FunctionPassManager FPM(Module); FPM.add(createA()); FPM.add(createB()); FPM.add(createC()); bool modified = false; modified |= FPM.doInitialization(); for (Function &F : Module) modified |= FPM.run(F); modified |= FPM.doFinalization(); _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev