| Issue |
203717
|
| Summary |
[NewPM][CodeGen] The *Correct* Way to Inject Custom CodeGen Passes with the New PM
|
| Labels |
|
| Assignees |
|
| Reporter |
matinraayai
|
Hi,
With the new PM support finally maturing for CodeGen and select backends, I wanted to know how I can inject custom-written Machine Function passes into the CodeGen pipeline. In the old PM, this was feasible with `TargetPassConfig::insertPass`. Now, with the new `TargetMachine::buildCodeGenPipeline` interface, the backends' codegen pass builder is never exposed, so I cannot directly call `insertPass` or `disablePass` on it before the pipeline is built to inject my custom passes.
The only option available for me is to use the `PassInstrumentationCallbacks`, and manually run my pass and perform the tasks the PM is supposed to do (e.g. invalidate the analysis results) inside one of its callbacks at a pre-determined point. But even that is not the cleanest (the post pass instrumentation callback doesn't expect you to modify the preserved analysis, its prototype is `using AfterPassFunc = void(StringRef, Any, const PreservedAnalyses &)`).
This is significantly more cumbersome than modifying the IR pipeline with the `PassBuilder` interface, so I was wondering if there's a better way to do this, or if there is a planned way to support this.
Thanks
cc: @arsenm @aeubanks @paperchalice
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs