Page MenuHomePhabricator

Let PassBuilder Expose PassInstrumentationCallbacks
ClosedPublic

Authored by aqjune on Dec 5 2019, 12:18 PM.

Details

Summary

This is an effort to allowing external libraries register their own pass instrumentation during their llvmGetPassPluginInfo() calls.

By exposing this through the added getPIC(), now a pass writer can do something like this:

extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
llvmGetPassPluginInfo() {
  return {
    ..,
    [](llvm::PassBuilder &PB) {
      PB.getPIC()->registerAfterPassCallback(move(f));
    }
  };
}

Diff Detail

Event Timeline

aqjune created this revision.Dec 5 2019, 12:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2019, 12:18 PM

Overall I'm fine with this.
Bikeshedding-wise, getPIC seems to be overly cryptic to me.
Do you believe full name getPassInstrumentationCallbacks is too much?

Also, please, add at least one test.
I would start with llvm/unittests/IR/PassBuilderCallbacksTest.cpp

aqjune updated this revision to Diff 233976.Dec 15 2019, 9:51 AM

Sorry for my delay.
I updated the function name & added a unit test.

fedor.sergeev accepted this revision.Jan 6 2020, 8:34 AM

LGTM.

llvm/include/llvm/Passes/PassBuilder.h
635

nit: "to add pass instrumentation" -> "to register pass instrumentation callbacks."

This revision is now accepted and ready to land.Jan 6 2020, 8:34 AM
aqjune updated this revision to Diff 236505.Jan 6 2020, 9:07 PM
  • Address a comment
This revision was automatically updated to reflect the committed changes.