[PATCH] D102909: [NPM] Ability to add a pass before a previously registered one

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 11 11:30:42 PDT 2021


aeubanks added a comment.

In D102909#2808270 <https://reviews.llvm.org/D102909#2808270>, @pratlucas wrote:

>> I'd still like to understand exactly what you'd be using this for. As in why does some pass need to run before all other instances of some other pass?
>
> The concrete use case I have is based on two separate plugin passes - one of them is responsible for inserting a few inline assembly instructions into functions according to a specific criteria and the second one's job is to make some adjustments to all the inline asm instructions in the module. The former needs to run before the latter to ensure all inline asm instructions are in place before the adjustments take place.
> Both of those plugin passes are required to run on the last step of the optimizer pipeline, using the `registerOptimizerLastEPCallback` extension point, so there's not enough granularity available to ensure those are run in this specific order.

If you add both in the same callback passed to `registerOptimizerLastEPCallback()` you can control the order they're added, e.g.

  PB.registerOptimizerLastEPCallback(
      [this](ModulePassManager &PM, PassBuilder::OptimizationLevel Level) {
        FunctionPassManager FPM;
        FPM.addPass(BarPass());
        FPM.addPass(FooPass());
        PM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
      });


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102909/new/

https://reviews.llvm.org/D102909



More information about the llvm-commits mailing list