This is an archive of the discontinued LLVM Phabricator instance.

[opt] Directly translate -O# to -passes='default<O#>'
ClosedPublic

Authored by aeubanks on Oct 18 2021, 3:49 PM.

Details

Summary

Right now when we see -O# we add the corresponding 'default<O#>' into
the list of passes to run when translating legacy -pass-name. This has
the side effect of not using the default AA pipeline.

Instead, treat -O# as -passes='default<O#>', but don't allow any other
-passes or -pass-name. I think we can keep opt -O# as shorthand for
opt -passes='default<O#> but disallow anything more than just -O#.

Tests need to be updated to not use opt -O# -pass-name.

Diff Detail

Event Timeline

aeubanks created this revision.Oct 18 2021, 3:49 PM
aeubanks requested review of this revision.Oct 18 2021, 3:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 18 2021, 3:49 PM
aeubanks added inline comments.Oct 18 2021, 3:51 PM
llvm/test/CodeGen/NVPTX/nvvm-reflect-arch.ll
4

we run this as part of the -O2 pipeline due to -mtriple, no need to specify it again
also, it's very confusing because it actually runs after -O2, which took me a while to figure out why the test was failing with -passes=function(nvvm-reflect),default<O2>, since we actually need some passes to run before nvvm-reflect for some reason

tra added a subscriber: tra.Oct 18 2021, 4:27 PM
tra added inline comments.
llvm/tools/opt/opt.cpp
790

A drive-by usability nit, probably for a different/separate patch:

I may be revisiting an old bike-shed, but it would be nice to avoid using characters that require quoting. IMO --passes=O3 would be as easy to understand as --passes=default<O3>, would require a bit less typing for a very common use case, and would not need to have everything quoted in many cases that would need it now (though quoting in general seems unavoidable as we have things like function(....)).

asbirlea accepted this revision.Oct 18 2021, 4:39 PM

lgtm, thank you for addressing this.

This revision is now accepted and ready to land.Oct 18 2021, 4:39 PM
aeubanks added inline comments.Oct 18 2021, 4:47 PM
llvm/tools/opt/opt.cpp
790

If I had to guess why that wasn't added, it'd probably be that we want to distinguish the default pipelines and the (Thin)LTO pipelines, since they all take an optimization level parameter, e.g. thinlto<O3> or lto-pre-link<Oz>.
But actually testing the non-default pipelines is rare and I agree that -passes=O3 should be fine in most cases.

This revision was landed with ongoing or failed builds.Oct 18 2021, 4:51 PM
This revision was automatically updated to reflect the committed changes.