[PATCH] D87000: Add a new hidden option -print-changes that reports in a patch-like notation when a pass actually changes the IR.

Jamie Schmeiser via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 20:39:17 PDT 2020


jamieschmeiser created this revision.
jamieschmeiser added reviewers: aeubanks, madhur13490, yrouban, ychen.
Herald added subscribers: hiraditya, mgorny.
Herald added a project: LLVM.
jamieschmeiser requested review of this revision.

Add a new hidden option -print-changes that reports in a patch-like notation
when a pass actually changes the IR.

A new hidden option -print-changes is introduced that reports when
a pass changes the IR and only prints a banner when no change is made
by a pass or when the pass or function is filtered out.  The changes
are shown in a form similar to a dump of a function except that the
text which is removed is shown prefixed with a '-' and the text which
is added is shown with a '+' in front.  Filtering of the output can
be controlled with the -filter-print-funcs and -filter-passes options.

The template base classes for these change reporters is moved into a
separate file and the base classes are expanded to allow more complex
methods of reporting changes.  The base classes handle all of the
determination of when a function or pass is "interesting" and should be
reported or filtered out.  The base classes have callbacks in the form
of lambdas or functions required by the instantiations which call out
when a change by a pass has been recognized so the instantiating class
need only provide these callbacks to present the information about the
changing IR.  The new option -print-changes is the first of these
instantiations using these base classes.  A second instantiation
is still to come in a subsequent commit.

This patch is made in relation to https://reviews.llvm.org/D86360 and
takes that as its base.  I will endeavor to update this PR as that one
evolves based on its reviews.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87000

Files:
  llvm/include/llvm/IR/ChangePrinters.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/ChangePrinters.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/change-printer.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87000.289345.patch
Type: text/x-patch
Size: 58886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200902/159c8891/attachment.bin>


More information about the llvm-commits mailing list