[NPM] Customizing PassBuilder with TM-specific optimizations


I’m trying to port over Julia’s pass pipeline from using the legacy pass manager to using the new pass manager, and I’m unable to find a way to grab target-specific optimizations from PassBuilder and insert them into our pipeline. For context, none of the optimization pipelines defined in PassBuilder suit our purposes (passes we don’t need such as inlining/coroutines are common), but we do want to run any passes that are registered by the TargetMachine in registerPassBuilderCallbacks. Is there a way to build a fully custom pipeline that respects these target-specific passes?

1 Like

TargetMachine::registerPassBuilderCallbacks() adds callbacks to PassBuilder::PeepholeEPCallbacks/LateLoopOptimizationsEPCallbacks/etc.

Those are then invoked in the various pipelines via something like

  for (auto &C : PeepholeEPCallbacks)
    C(FPM, Level);

But those member variables are private.

Creating public methods in PassBuilder per *EPCallbacks member variable that invoke the callbacks seems reasonable. For example there’s already a private PassBuilder::invokePeepholeEPCallbacks().


Can you suggest a user manual or something for beginners?