This is an archive of the discontinued LLVM Phabricator instance.

[LTO] Add the ability to specify a subset of passes to run
ClosedPublic

Authored by davide on May 13 2016, 7:14 PM.

Details

Summary

This commits add a --lto-newpm-passes= option that can specify the set of passes that need to be run (similarly to what opt already does). This makes testing easier (e.g. tuning the LTO pipeline), among others.
runLTOPasses() is growing (maybe) too much. I can split in two separate functions, if you like that better.

Diff Detail

Repository
rL LLVM

Event Timeline

davide updated this revision to Diff 57278.May 13 2016, 7:14 PM
davide retitled this revision from to [LTO] Add the ability to specify a subset of passes to run.
davide updated this object.
davide added reviewers: rafael, pcc, chandlerc.
davide added a subscriber: llvm-commits.
davide updated this revision to Diff 57279.May 13 2016, 7:24 PM

git-clang-formatted.
Also, this doesn't still allow to specify an AliasAnalysis pipeline (a-la opt). I'll introduce another option for that in a subsequent commit.
Ideally we wouldn't need two different options, but the current architecture doesn't allow to get away with a single option, to the best of my knowledge.

chandlerc added inline comments.May 13 2016, 7:48 PM
ELF/LTO.cpp
91–99 ↗(On Diff #57279)

We should really refactor this into a helper in PassBuilder.

davide updated this revision to Diff 57288.May 14 2016, 4:34 PM

Update after refactoring cross registration of Analysis managers in PassBuilder.

davide marked an inline comment as done.May 14 2016, 4:34 PM
chandlerc edited edge metadata.May 14 2016, 7:01 PM

FWIW, this looks good to me, but you should get someone who works on LLD to give the final LGTM.

ruiu added a subscriber: ruiu.May 15 2016, 10:31 AM
ruiu added inline comments.
ELF/LTO.cpp
69–70 ↗(On Diff #57288)

Can you please split the function so that you can do

if (!Config->LtoNewPmPasses.empty())
  runNewLtoPasses(M, TM);
else
  runOldLtoPasses(M, TM);
97–98 ↗(On Diff #57288)

You need to handle the error gracefully (i.e. don't call fatal which exits) as it is a user-supplied command line option. Instead, please call error() here.

Please add a test to verify that it prints out an error message for an unknown --lto-newpm-passes argument.

davide added inline comments.May 15 2016, 10:56 AM
ELF/LTO.cpp
69–70 ↗(On Diff #57288)

I don't want to bikeshed, but.
The name runNewLtoPasses is misleading because it doesn't capture the fact that we're running a custom pipeline. runNewLtoCustomPasses would be more appropriate. Or whatever you want to suggest, I'll take.

ruiu added inline comments.May 15 2016, 10:57 AM
ELF/LTO.cpp
69–70 ↗(On Diff #57288)

Maybe your name is better. :) My point was just to split the function.

davide updated this revision to Diff 57303.May 15 2016, 12:19 PM
davide edited edge metadata.

Addressed comments.

ruiu accepted this revision.May 15 2016, 12:24 PM
ruiu added a reviewer: ruiu.

LGTM with a few nits.

ELF/LTO.cpp
65 ↗(On Diff #57303)

Fix indentation of this code.

90 ↗(On Diff #57303)
error("unable to parse pass pipeline description: " + Config->LtoNewPmPasses);
116 ↗(On Diff #57303)

Remove this line.

This revision is now accepted and ready to land.May 15 2016, 12:24 PM
This revision was automatically updated to reflect the committed changes.

Thanks for your review, Rui/Chandler. I'll let this bake in the tree for a bit and then implement --lto-newpm-aa-pipeline (as opt does).