This is an archive of the discontinued LLVM Phabricator instance.

[MachineFunctionPass] Support -print-changed and -print-changed=quiet
ClosedPublic

Authored by MaskRay on Jul 23 2022, 8:33 PM.

Details

Summary

-print-changed for new pass manager is handy beside -print-after-all.
Port it to MachineFunctionPass.

Note: lib/Passes/StandardInstrumentations.cpp implements a number of
misc features. If we want to use them for codegen, we may need to lift
some functionality to LLVMIR.

Diff Detail

Event Timeline

MaskRay created this revision.Jul 23 2022, 8:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2022, 8:33 PM
MaskRay requested review of this revision.Jul 23 2022, 8:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2022, 8:33 PM
aeubanks added inline comments.Jul 25 2022, 9:10 AM
llvm/include/llvm/IR/PrintPasses.h
13

I was worried how widespread this include may have been, but looks like only .cpp files include PrintPasses.h

llvm/lib/CodeGen/MachineFunctionPass.cpp
75

add a comment on how this only acts as --print-changed=quiet regardless of what's passed to --print-changed, with perhaps a TODO

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

I'm worried about how brittle this test is

making the input MIR would probably help a little

I'm also not sure which target is the simplest in terms backend passes

I do want to say that I like this, thanks for doing this!

also typo in title: MachineFunctinPass -> MachineFunctionPass

MaskRay updated this revision to Diff 447445.Jul 25 2022, 1:05 PM
MaskRay marked an inline comment as done.

address comments

MaskRay retitled this revision from [MachineFunctinPass] Support -print-changed and -print-changed=quiet to [MachineFunctionPass] Support -print-changed and -print-changed=quiet.Jul 25 2022, 1:09 PM
aeubanks accepted this revision.Jul 25 2022, 6:19 PM
This revision is now accepted and ready to land.Jul 25 2022, 6:19 PM
jamieschmeiser accepted this revision.Jul 26 2022, 6:46 AM

Since you have the before and after versions, I expect you could get -print-changed=diff and cdiff without too much difficulty by calling the diff routine that the opt print-changed options use, if you want to expand this functionality.

llvm/lib/CodeGen/MachineFunctionPass.cpp
78

You may want to also consider allowing filtering with -filter-passes here. Perhaps a TODO?

MaskRay updated this revision to Diff 447748.Jul 26 2022, 10:12 AM
MaskRay marked an inline comment as done.

add a TODO for --filter-passes

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

This should be quite stable. aarch64 -O0 defaults to global isel and -O* will switch too. The IRTranslator/Legalizer lines will likely stay unchanged.

This revision was landed with ongoing or failed builds.Jul 26 2022, 10:16 AM
This revision was automatically updated to reflect the committed changes.