This is an archive of the discontinued LLVM Phabricator instance.

CodeGenPrepare: add disablebranchopts and addrsinkusinggeps as pass options
Needs ReviewPublic

Authored by escha on Jul 7 2015, 10:23 AM.

Details

Reviewers
resistor
Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

escha updated this revision to Diff 29189.Jul 7 2015, 10:23 AM
escha retitled this revision from to CodeGenPrepare: add disablebranchopts and addrsinkusinggeps as pass options.
escha updated this object.
escha added a reviewer: resistor.
escha set the repository for this revision to rL LLVM.
escha added a subscriber: llvm-commits.

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

escha added a comment.Jul 7 2015, 10:40 AM

The way we use this looks roughly like this:

addPass(createCodeGenPreparePass(TM, true, true));
addPass(createOutOfTreeGPUCodeGenPreparePass(*TM));
addPass(createFMAContractionPass());
addPass(createOutOfTreeGPUSpecificCodeGenPreparePass( /* args */ );
arsenm added a subscriber: arsenm.Jul 7 2015, 10:57 AM

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

escha added a comment.Jul 7 2015, 11:01 AM

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.

escha updated this revision to Diff 29196.Jul 7 2015, 11:21 AM

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