[llvm-branch-commits] [RFC][Clang] Allow plugins to hook into back-end (PR #165257)

Vassil Vassilev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 27 08:05:45 PDT 2025


vgvassilev wrote:

> > do you use a plugin to swap clang's CodeGen
> 
> We swap LLVM's CodeGen (the machine code generation part), but want to keep Clang's CodeGen (the part that generates LLVM IR and optimizes that). We want the front-end and middle-end optimizations to behave as usual and only replace the back-end with our own back-end.
> 
> > why the standard plugin system does not work well there?
> 
> The standard front-end plugins permit replacing, e.g., the CodeGenAction with something else. But we do want Clang's CodeGen to work normally. CodeGenAction and emitBackendOutput are very inflexible; adding a custom back-end through a PluginASTAction would essentially require us to copy large parts of CodeGenAction.cpp and BackendUtil.cpp, which is not maintainable.

Would it make more sense to make the CodeGenAction and emitBackendOutput more flexible? Maybe checking if the `BackendAction` kind is plugin we can give back the control to the frontend plugin code...

It would be great to enhance the existing clang plugin system rather than adding a new plugin extension point.

cc: @lhames.



https://github.com/llvm/llvm-project/pull/165257


More information about the llvm-branch-commits mailing list