[llvm-branch-commits] [clang] [llvm] [RFC][LLVM][Clang] Add LLVM plugin hook for back-ends (PR #170846)
Alexis Engelke via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Dec 8 04:06:06 PST 2025
================
@@ -49,7 +53,14 @@ struct PassPluginLibraryInfo {
/// The callback for registering plugin passes with a \c PassBuilder
/// instance
- void (*RegisterPassBuilderCallbacks)(PassBuilder &);
+ void (*RegisterPassBuilderCallbacks)(PassBuilder &) = nullptr;
+
+ /// Callback called before running the back-end passes on the module. The
+ /// callback can generate code itself by writing the expected output to OS and
+ /// returning true to prevent the default pipeline and further plugin
+ /// callbacks from running.
+ bool (*PreCodeGenCallback)(Module &, TargetMachine &, CodeGenFileType,
----------------
aengelke wrote:
I would consider this to be out-of-scope for now. Back-end pipelines are, currently, target-specific and any support for plugins modifying these pipelines is likely to need a lot of further discussion (esp. as many back-end passes not really self-contained). There was some discussion on CodeGenPassBuilder to add callbacks for targets earlier this year, but it seems work on that has stalled. Additionally, the proposed plugin API already permits building and running a custom pass manager, so right now there would be no benefit of speculatively building a more generic API.
If there's a desire to add external hooks for CodeGenPassBuilder, I think this should be a separate function similar to the RegisterPassBuilderCallbacks that exists so far.
https://github.com/llvm/llvm-project/pull/170846
More information about the llvm-branch-commits
mailing list