diff --git a/clang/docs/ClangPlugins.rst b/clang/docs/ClangPlugins.rst --- a/clang/docs/ClangPlugins.rst +++ b/clang/docs/ClangPlugins.rst @@ -200,3 +200,14 @@ PluginASTAction::ActionType getActionType() override { return AddAfterMainAction; } + +Interaction with ``-clear-ast-before-backend`` +---------------------------------------------- + +If the main AST action is codegen, having any plugins that run after the +codegen action automatically turns off ``-clear-ast-before-backend``, which +saves peak memory by clearing the Clang AST after generating IR and before +running IR optimizations. Use ``CmdlineBeforeMainAction`` or +``AddBeforeMainAction`` as ``getActionType`` to run plugins before the codegen +action and still have access to peak memory savings from +``-clear-ast-before-backend``.