Phil Tomson via llvm-dev
2016-May-10 00:26 UTC
[llvm-dev] How to register a pass as being optional?
I've created a post-RA pass runOnMachineFunction that gets registed with the pass manager like this: static RegisterPass<RegBankFixUpPass> X("regbankfixup", "Register Bank Conflict FixUp Pass"); And and whenever I run clang or llc now the pass runs. Initially, until I'm sure this pass doesn't break things I'd like it to be opt-in - ie I'd like to have the pass run only when the -regbankfixup commandline option is passed to clang or llc, but this seems doable only from opt. Is there no way to set things up such that the pass gets run when an option is passed to llc or (ideally) clang? Phil -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160509/fbdc4852/attachment.html>
David Chisnall via llvm-dev
2016-May-10 10:52 UTC
[llvm-dev] How to register a pass as being optional?
On 10 May 2016, at 01:26, Phil Tomson via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > I've created a post-RA pass runOnMachineFunction that gets registed with the pass manager like this: > > > static RegisterPass<RegBankFixUpPass> X("regbankfixup", "Register Bank Conflict FixUp Pass"); > > And and whenever I run clang or llc now the pass runs. Initially, until I'm sure this pass doesn't break things I'd like it to be opt-in - ie I'd like to have the pass run only when the -regbankfixup commandline option is passed to clang or llc, but this seems doable only from opt. Is there no way to set things up such that the pass gets run when an option is passed to llc or (ideally) clang?The easiest thing to do is make it run every time, but return immediately if a command-line option is not specified. A number of passes use a similar pattern, skipping execution entirely if some cheap-to-test prerequisite is not met. David -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3719 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160510/c74a534c/attachment.bin>
Mehdi Amini via llvm-dev
2016-May-16 15:30 UTC
[llvm-dev] How to register a pass as being optional?
> On May 10, 2016, at 3:52 AM, David Chisnall via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > On 10 May 2016, at 01:26, Phil Tomson via llvm-dev <llvm-dev at lists.llvm.org> wrote: >> >> I've created a post-RA pass runOnMachineFunction that gets registed with the pass manager like this: >> >> >> static RegisterPass<RegBankFixUpPass> X("regbankfixup", "Register Bank Conflict FixUp Pass"); >> >> And and whenever I run clang or llc now the pass runs. Initially, until I'm sure this pass doesn't break things I'd like it to be opt-in - ie I'd like to have the pass run only when the -regbankfixup commandline option is passed to clang or llc, but this seems doable only from opt. Is there no way to set things up such that the pass gets run when an option is passed to llc or (ideally) clang? > > The easiest thing to do is make it run every time, but return immediately if a command-line option is not specified. A number of passes use a similar pattern, skipping execution entirely if some cheap-to-test prerequisite is not met.I usually see it done differently in clang/llvm: the cl::opt flag is added to the PassManagerBuilder and the pass is added only if the flag is set. For instance: -combine-loads, -use-cfl-aa, -mlsm, ... -- Mehdi