[PATCH] D87216: [NewPM] Support --print-before/after in NPM

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 6 18:38:27 PDT 2020


aeubanks created this revision.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, hiraditya, mgorny.
Herald added projects: clang, LLVM.
aeubanks requested review of this revision.

This changes --print-before/after to be a list of strings rather than
legacy passes. (this also has the effect of not showing the entire list
of passes in --help-hidden after --print-before/after, which IMO is
great for making it less verbose).

Currently PrintIRInstrumentation passes the class name rather than pass
name to llvm::shouldPrintBeforePass(), meaning
llvm::shouldPrintBeforePass() never functions as intended.
There is no easy way of converting class names to pass names outside of
within an instance of PassBuilder. When constructing a PassBuilder,
StandardInstrumentation is needed, so we can't pass PassBuilder to the
constructor of StandardInstrumentation. So this patch hackily adds a
translatePassNamesToClassNames() method to StandardInstrumentation which
takes a PassBuilder and asks it to convert the names passed to
--print-before/after to class names, so that later it can match class
names passed via PassInstrumentation.

The other approach is to pass the pass name into StandardInstrumentation
callbacks. This would require storing the pass name somewhere alongside
the pass, which doesn't seem feasible since the PassBuilder allows
directly adding passes to pass managers without using the pass name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87216

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/IR/PrintPasses.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/LegacyPassManager.cpp
  llvm/lib/IR/PrintPasses.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/CodeGen/Generic/print-after.ll
  llvm/test/Other/loop-pass-printer.ll
  llvm/test/Other/print-before-after.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87216.290158.patch
Type: text/x-patch
Size: 22237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200907/d3e0cd0a/attachment.bin>


More information about the llvm-commits mailing list