I have no idea if this is formatted/designed correctly; this is a direct patch from an out-of-tree target (I'm happy to patch it up as necessary). We needed the ability to disable these two options when calling codegenprepare from the TargetMachine, so we added them to the pass initializer, and we'd prefer if the change was upstreamed if possible.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Yeah, the underscore thing is funky. Let's not do that.
What's the PassManager setup look like from your backend? (Suitably sanitized etc)
-eric
The way we use this looks roughly like this:
addPass(createCodeGenPreparePass(TM, true, true)); addPass(createOutOfTreeGPUCodeGenPreparePass(*TM)); addPass(createFMAContractionPass()); addPass(createOutOfTreeGPUSpecificCodeGenPreparePass( /* args */ );
What does this option get you over the TLI hooks that disable the same transforms?
if (!DisableBranchOpts) { EverMadeChange |= sinkAndCmp(F); EverMadeChange |= splitBranchCondition(F); }
Both of these check TLI hooks already, e.g. splitBranchConditon does nothing if TLI->isJumpExpensive()
It's possible the disablebranchopts is no longer necessary; it's 3 years old in our tree so it's quite possible it's been made obsolete by target hooks in the meantime.
I don't think there's a target hook for the GEP splitting though.
Okay, stripped out the rest of the patch so I can just get in the relevant change to branch optimizations.
As discussed on IRC, this option was added to our backend because we needed the CLI parameter (disabling branch opts) to disable all things that modify the CFG, which sounds pretty reasonable for something that disables branch opts. This is useful for writing CFG tests, e.g. for things like switch lowering, that need to ensure CGP doesn't mangle the CFG on the way there.
I'll make a separate revision for a TLI hook to disable address GEP splitting.
Hi,
I would rather go with new target hook for the missing optimization to keep it consistent with what we have.
Cheers,
-Quentin