[PM] Enable registration of out-of-tree passes with PassBuilder
authorPhilip Pfaffe <philip.pfaffe@gmail.com>
Mon, 10 Jul 2017 10:57:55 +0000 (10:57 +0000)
committerPhilip Pfaffe <philip.pfaffe@gmail.com>
Mon, 10 Jul 2017 10:57:55 +0000 (10:57 +0000)
commit730f2f9bb622a4b72231628239fe607d26224a07
treea7c21e1550bda5b1293f5454daca7ac2d321fd37
parentfb3210aa057fb3f396289fdb110b9f80625c9eef
[PM] Enable registration of out-of-tree passes with PassBuilder

Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.

Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.

Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.

Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.

Reviewers: chandlerc

Reviewed By: chandlerc

Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny

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

llvm-svn: 307532
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/tools/opt/NewPMDriver.cpp
llvm/unittests/IR/CMakeLists.txt
llvm/unittests/IR/PassBuilderCallbacksTest.cpp [new file with mode: 0644]