[all-commits] [llvm/llvm-project] 5d960c: [opt][NewPM] Add a --print-passes flag to print al...

aeubanks via All-commits all-commits at lists.llvm.org
Wed Feb 10 11:22:46 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5d960cba34682d0d4e0cd56837131888eb647c62
      https://github.com/llvm/llvm-project/commit/5d960cba34682d0d4e0cd56837131888eb647c62
  Author: Arthur Eubanks <aeubanks at google.com>
  Date:   2021-02-10 (Wed, 10 Feb 2021)

  Changed paths:
    M llvm/include/llvm/Passes/PassBuilder.h
    M llvm/lib/Passes/PassBuilder.cpp
    A llvm/test/Other/print-passes.ll
    M llvm/tools/opt/NewPMDriver.cpp
    M llvm/tools/opt/NewPMDriver.h
    M llvm/tools/opt/opt.cpp

  Log Message:
  -----------
  [opt][NewPM] Add a --print-passes flag to print all available passes

It seems nicer to list passes given a flag rather than displaying all
passes in opt --help.

This is awkwardly structured because a PassBuilder is required, but
reusing the PassBuilder in runPassPipeline() doesn't work because we
read the input IR before getting to runPassPipeline(). So printing the
list of passes needs to happen before reading the input IR. If we remove
the legacy PM code in main() and move everything from NewPMDriver.cpp
into opt.cpp, we can create the PassBuilder before reading IR and check
if we should print the list of passes and exit. But until then this hack
seems fine.

Compared to the legacy PM, the new PM passes are lacking descriptions.
We'll need to figure out a way to add descriptions if we think this is
important.

Also, this only works for passes specified in PassRegistry.def. If we
want to print other custom registered passes, we'll need a different
mechanism.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D96101




More information about the All-commits mailing list