[llvm-dev] How to register a pass as being optional?

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Tue May 10 03:52:45 PDT 2016

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.


-------------- 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>

More information about the llvm-dev mailing list