Optimization Remark Emitter API

Hi llvm-dev!

Recently the old Optimization Remark emitter APIs have been replaced with a new API.

Whereas before you would have had to emit a remark using a call like

emitOptimizationRemark(Context, PassName, Function, DLoc, Msg)

(and similar for missed and analysis remarks), there now exists a much more versatile api using

ORE->emit(OptimizationRemark(PassName, OptimizationName, Function) << "inlined " << NV("caller", Caller) << " into " << NV("callee", Callee));

(where ORE is a per-function OptimizationRemarkEmitter object).

The newer API gives developers the ability to emit more complex objects into the optimization remark yaml, in such a way that they will still be printed nicely, and the extra metadata is available to optimization remark tools.

Migrating function passes is relatively easy, as can be seen here https://reviews.llvm.org/rL309497 in migrating PGOMemOPSizeOpt.cpp pass - there’s a function pass that keeps an ORE around. Migrating module passes is slightly harder, as shown here: https://reviews.llvm.org/rL309294

We have now finished migrating the in-tree LLVM passes that use the old API to the new API, and are about to remove the old API. This is a heads up for any out-of-tree passes using the old API that you should also update.