From c3821b8d2aacd1d7c0281db1b8db011e1158cf4d Mon Sep 17 00:00:00 2001 From: Tarun Prabhu Date: Thu, 10 Nov 2022 07:56:03 -0700 Subject: [flang] Add -fpass-plugin option to flang This patch adds the -fpass-plugin option to flang which dynamically loads LLVM passes from the shared object passed as the argument to the flag. The behavior of the option is designed to replicate that of the same option in clang and thus has the same capabilities and limitations. Features: Multiple instances of -fpass-plugin=path-to-file can be specified and each of the files will be loaded in that order. The flag can be passed to both flang-new and flang-new -fc1. The flag will be listed when the -help flag is passed to both flang-new and flang-new -fc1. It will also be listed when the --help-hidden flag is passed. Limitations: Dynamically loaded plugins are not supported in clang on Windows and are not supported in flang either. Addenda: Some minor stylistic changes are made in the files that were modified to enable this functionality. Those changes make the naming of functions more consistent, but do not change any functionality that is not directly related to enabling -fpass-plugin. Differential Revision: https://reviews.llvm.org/D129156 --- flang/lib/Frontend/CompilerInvocation.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'flang/lib/Frontend/CompilerInvocation.cpp') diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 4ae35762..f0f070e 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -125,6 +125,9 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts, clang::driver::options::OPT_fno_debug_pass_manager, false)) opts.DebugPassManager = 1; + for (auto *a : args.filtered(clang::driver::options::OPT_fpass_plugin_EQ)) + opts.LLVMPassPlugins.push_back(a->getValue()); + // -mrelocation-model option. if (const llvm::opt::Arg *A = args.getLastArg(clang::driver::options::OPT_mrelocation_model)) { -- cgit v1.1