This is an archive of the discontinued LLVM Phabricator instance.

[MachineFunctionPass] Support -filter-passes for -print-changed
ClosedPublic

Authored by MaskRay on Aug 31 2022, 2:32 PM.

Details

Summary

[MachineFunctionPass] Support -filter-passes for -print-changed

-filter-passes specifies a PassID (a lower-case dashed-separated pass name,
also used by -print-after, -stop-after, etc) instead of a CamelCasePass.

-filter-passes=CamelCaseNewPMPass seems like a workaround for new PM passes before
we can use lower-case dashed-separated pass names (as used by -passes=).

Example:

# getPassName() is "IRTranslator". PassID is "irtranslator"
llc -mtriple=aarch64 -print-changed -filter-passes=irtranslator < print-changed-machine.ll

Close https://github.com/llvm/llvm-project/issues/57453

Diff Detail

Event Timeline

MaskRay created this revision.Aug 31 2022, 2:32 PM
MaskRay requested review of this revision.Aug 31 2022, 2:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 2:32 PM
MaskRay edited reviewers, added: rahmanl; removed: rlavaee.Aug 31 2022, 2:33 PM
MaskRay updated this revision to Diff 457094.Aug 31 2022, 2:36 PM

remove unneeded comments
fix test

Thanks for implementing this. Why should there be a discrepancy in how passes are named with this option vs. the IR mode option? Wouldn't that make it hard for the user invoking clang with -mllvm?

Thanks for implementing this. Why should there be a discrepancy in how passes are named with this option vs. the IR mode option? Wouldn't that make it hard for the user invoking clang with -mllvm?

The lower-case dash-separated passs id is desired, as implemented in this patch. This matches -print-after=, -stop-after=, etc.

-filter-passes=CamelCasePass is a workaround for new PM passes before there is a better way.

jamieschmeiser added inline comments.Sep 1 2022, 5:57 AM
llvm/lib/Passes/StandardInstrumentations.cpp
64

I don't think you meant to remove this comment...

aeubanks accepted this revision.Sep 1 2022, 9:37 AM

lg with comments resolved

llvm/lib/CodeGen/MachineFunctionPass.cpp
155

isFunctionInPrintList should also use "filtered out"

llvm/test/Other/print-changed-machine.ll
37

perhaps a QUIET-FILTER-NOT: legalizer?

This revision is now accepted and ready to land.Sep 1 2022, 9:37 AM
MaskRay updated this revision to Diff 457326.Sep 1 2022, 10:52 AM
MaskRay marked 3 inline comments as done.

add back two comments (but simplified)

llvm/lib/CodeGen/MachineFunctionPass.cpp
155

There is a difference between MachineFunctionPass and a new PM pass filter: MachineFunctionPass does not print anything for a -filter-print-funcs ignored function while a new PM pass filter prints " filtered out".

Personally I feel the MachineFunctionPass behavior is more reasonable but I will note that there is inconsistency. At any rate this difference probably should be addressed in this patch.

llvm/test/Other/print-changed-machine.ll
37

--implicit-check-not='IR Dump' covers this check :)

MaskRay edited the summary of this revision. (Show Details)Sep 1 2022, 11:00 AM
MaskRay edited the summary of this revision. (Show Details)Sep 1 2022, 11:01 AM
MaskRay edited the summary of this revision. (Show Details)
aeubanks added inline comments.Sep 1 2022, 11:02 AM
llvm/lib/Passes/StandardInstrumentations.cpp
64

comment is still removed

MaskRay marked an inline comment as done.Sep 1 2022, 11:05 AM
MaskRay added inline comments.
llvm/lib/Passes/StandardInstrumentations.cpp
64

Looks like the comment is duplicated.

// An option that supports the -print-changed option.  See
// the description for -print-changed for an explanation of the use
// of this option.  Note that this option has no effect without -print-changed.

I have kept one copy.

This revision was landed with ongoing or failed builds.Sep 1 2022, 11:06 AM
This revision was automatically updated to reflect the committed changes.
MaskRay marked an inline comment as done.
nikic added a subscriber: nikic.Sep 1 2022, 11:41 PM

FYI there was some small but measurable compile-time impact, probably because you are looking up the pass info unconditionally, even if no printing is requested. (http://llvm-compile-time-tracker.com/compare.php?from=c0433f91d3333d8902ae7a53c0e5ee5e98b7586b&to=8d95fd7e56bed7d3a3260bed7117023968f8be3c&stat=instructions)

FYI there was some small but measurable compile-time impact, probably because you are looking up the pass info unconditionally, even if no printing is requested. (http://llvm-compile-time-tracker.com/compare.php?from=c0433f91d3333d8902ae7a53c0e5ee5e98b7586b&to=8d95fd7e56bed7d3a3260bed7117023968f8be3c&stat=instructions)

hopefully fixed with 7e0a52e8e9ef6394bb62e0b56e17fa23e7262411

nikic added a comment.Sep 8 2022, 1:19 AM

FYI there was some small but measurable compile-time impact, probably because you are looking up the pass info unconditionally, even if no printing is requested. (http://llvm-compile-time-tracker.com/compare.php?from=c0433f91d3333d8902ae7a53c0e5ee5e98b7586b&to=8d95fd7e56bed7d3a3260bed7117023968f8be3c&stat=instructions)

hopefully fixed with 7e0a52e8e9ef6394bb62e0b56e17fa23e7262411

Thanks! Unfortunately the build was broken when this landed, so the results also include many other commits, but it does look good :) http://llvm-compile-time-tracker.com/compare.php?from=178554f3c8f983bd192818b6d46e4d95560c4964&to=fd2475049e882e6c70a745cbe0799749ba184910&stat=instructions