This is an archive of the discontinued LLVM Phabricator instance.

[NewPM] Attempt to run opt passes specified via -foo-pass under NPM
ClosedPublic

Authored by aeubanks on Jun 22 2020, 10:49 AM.

Details

Summary

In order to enable mass testing of opt under NPM, specifically passes
specified via -foo-pass.

This is gated under a new opt flag -enable-new-pm. Currently
the pass flag parser looks for legacy PM passes with the name "foo" (for
opt arg "-foo") and creates a PassInfo for each one. Here we take the
(legacy PM) pass name and try to match it with one defined in (NPM)
PassRegistry.def. Ultimately if we want all tests to pass like this,
we'll need to port all passes to NPM and register them in
PassRegistry.def under the same name as they were reigstered in the
legacy PM.

Maybe at some point we'll migrate all -foo to --passes=foo, but that
would be after the NPM switch.

Flipping on the flag causes 2XXX failures under check-llvm. By far most
of them are passes either not ported to NPM or don't have the same name
in PassRegistry.def as their old name.

Diff Detail

Event Timeline

aeubanks created this revision.Jun 22 2020, 10:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2020, 10:49 AM
ychen added a subscriber: ychen.Jun 22 2020, 4:02 PM

This is great! What are these failures look like? Do they look straightforward to fix?

llvm/tools/opt/opt.cpp
75

This is a bit verbose to me. Maybe enable-new-pm. It is fine either way.

742

PassPipeline.getNumOccurrences() > 0 is more intuitive?

aeubanks updated this revision to Diff 272567.Jun 22 2020, 4:39 PM
aeubanks marked 4 inline comments as done.

Add test
Address review comments

aeubanks edited the summary of this revision. (Show Details)Jun 22 2020, 4:41 PM
aeubanks updated this revision to Diff 272569.Jun 22 2020, 4:42 PM

Add trailing newline in test

This is great! What are these failures look like? Do they look straightforward to fix?

Updated the description.
Most of them are passes either not ported to NPM or don't have the same name in PassRegistry.def as their old name.
I was thinking about potentially creating some wrapper class around old PM passes but I don't think that would work.

llvm/tools/opt/opt.cpp
75

Done, matches another option in NewPMDriver.cpp

742

That's definitely better, done.

ychen accepted this revision.Jun 22 2020, 5:52 PM

This is great! What are these failures look like? Do they look straightforward to fix?

Updated the description.
Most of them are passes either not ported to NPM

I would assume most of these are passes for codegen pipeline?

or don't have the same name in PassRegistry.def as their old name.

I was thinking about potentially creating some wrapper class around old PM passes but I don't think that would work.

Not for this patch, how about adding the old name in the PassRegistry.def as an alternative name?

This revision is now accepted and ready to land.Jun 22 2020, 5:52 PM

This is great! What are these failures look like? Do they look straightforward to fix?

Updated the description.
Most of them are passes either not ported to NPM

I would assume most of these are passes for codegen pipeline?

No, codegen hasn't really been updated to work with NPM at all. For example we don't even have some sort of MachineFunctionPassManager yet (I found your older https://reviews.llvm.org/D67687 which hasn't been submitted yet).
Under clang if NPM is enabled, it runs the pre-codegen passes under NPM, but then just runs the codegen passes separately under legacy PM.
For tests, almost all codegen passes use llc instead of opt. The one odd pass I've run into was CodeGenPrepare, which is pre-codegen, but requires some codegen analysis (MachineModuleAnalysis I believe), which was part of https://reviews.llvm.org/D67687.

or don't have the same name in PassRegistry.def as their old name.

I was thinking about potentially creating some wrapper class around old PM passes but I don't think that would work.

Not for this patch, how about adding the old name in the PassRegistry.def as an alternative name?

Yes that works for some cases where the pass has been ported to NPM.

ychen added a comment.Jun 22 2020, 6:59 PM

This is great! What are these failures look like? Do they look straightforward to fix?

Updated the description.
Most of them are passes either not ported to NPM

I would assume most of these are passes for codegen pipeline?

No, codegen hasn't really been updated to work with NPM at all. For example we don't even have some sort of MachineFunctionPassManager yet (I found your older https://reviews.llvm.org/D67687 which hasn't been submitted yet).
Under clang if NPM is enabled, it runs the pre-codegen passes under NPM, but then just runs the codegen passes separately under legacy PM.
For tests, almost all codegen passes use llc instead of opt. The one odd pass I've run into was CodeGenPrepare, which is pre-codegen, but requires some codegen analysis (MachineModuleAnalysis I believe), which was part of https://reviews.llvm.org/D67687.

Thanks. I'm asking because I have vague memory that there are some codegen IR passes that are driven by opt instead of llc. But as you said, they are not. I guess @leonardchan got a better idea about our situation on passes (ported/not ported).

or don't have the same name in PassRegistry.def as their old name.

I was thinking about potentially creating some wrapper class around old PM passes but I don't think that would work.

Not for this patch, how about adding the old name in the PassRegistry.def as an alternative name?

Yes that works for some cases where the pass has been ported to NPM.

hans added a comment.Jun 23 2020, 4:47 AM

Cool!

Maybe expand the commit description to be more explicit about the motivation. I assume this is to enable mass testing of current tests with the new pm?

aeubanks retitled this revision from [NPM] Attempt to run opt passes specified via -foo-pass under NPM to [NewPM] Attempt to run opt passes specified via -foo-pass under NPM.Jun 23 2020, 9:16 AM
aeubanks edited the summary of this revision. (Show Details)
aeubanks edited the summary of this revision. (Show Details)

Cool!

Maybe expand the commit description to be more explicit about the motivation. I assume this is to enable mass testing of current tests with the new pm?

Yup, done.

This revision was automatically updated to reflect the committed changes.
asbirlea added inline comments.Jun 24 2020, 3:31 PM
llvm/tools/opt/NewPMDriver.cpp
340

Add an assert that Passes is empty? This should match the callsite assert from opt.cpp