This option is available in both the compiler driver and the frontend driver.
Note that LLVM plugins are not officially supported on Windows.
+
+## LLVM Pass Extensions
+
+Pass extensions are similar to plugins, except that they can also be linked
+statically. Setting `-DLLVM_${NAME}_LINK_INTO_TOOLS` to `ON` in the cmake
+command turns the project into a statically linked extension. An example would
+be Polly, e.g., using `-DLLVM_POLLY_LINK_INTO_TOOLS=ON` would link Polly passes
+into `flang-new` as built-in middle-end passes.
+
+See the
+[`WritingAnLLVMNewPMPass`](https://llvm.org/docs/WritingAnLLVMNewPMPass.html#id9)
+documentation for more details.
* Flang now supports loading LLVM pass plugins with the `-fpass-plugin` option
which is also available in clang. The option mimics the behavior of the
corresponding option in clang and has the same capabilities and limitations.
+* Flang also supports statically linked LLVM pass extensions. Projects can be
+ linked statically into `flang-new` if the cmake command includes
+ `-DLLVM_${NAME}_LINK_INTO_TOOLS=ON`. This behavior is also similar to clang.
## Bug Fixes
LINK_COMPONENTS
Passes
Analysis
+ Extensions
IRReader
Option
Support
using namespace Fortran::frontend;
+// Declare plugin extension function declarations.
+#define HANDLE_EXTENSION(Ext) \
+ llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+#include "llvm/Support/Extension.def"
+
//===----------------------------------------------------------------------===//
// Custom BeginSourceFileAction
//===----------------------------------------------------------------------===//
<< pluginFile << passPlugin.takeError();
}
}
+ // Register static plugin extensions.
+#define HANDLE_EXTENSION(Ext) \
+ get##Ext##PluginInfo().RegisterPassBuilderCallbacks(pb);
+#include "llvm/Support/Extension.def"
// Register all the basic analyses with the managers.
pb.registerModuleAnalyses(mam);
llvm_canonicalize_cmake_booleans(
FLANG_BUILD_EXAMPLES
FLANG_STANDALONE_BUILD
+ LLVM_BYE_LINK_INTO_TOOLS
LLVM_ENABLE_PLUGINS
)
-! Verify that the plugin passed to -fpass-plugin is loaded and run
+! Verify that the static and dynamically loaded pass plugins work as expected.
! UNSUPPORTED: system-windows
! REQUIRES: plugins, shell, examples
-! RUN: %flang -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
-! RUN: %flang_fc1 -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+! RUN: %flang -S %s %loadbye -Xflang -fdebug-pass-manager -o /dev/null \
+! RUN: 2>&1 | FileCheck %s
+
+! RUN: %flang_fc1 -S %s %loadbye -fdebug-pass-manager -o /dev/null \
+! RUN: 2>&1 | FileCheck %s
+
! CHECK: Running pass: {{.*}}Bye on empty_
if config.has_plugins:
config.available_features.add('plugins')
+if config.linked_bye_extension:
+ config.substitutions.append(('%loadbye', ''))
+else:
+ config.substitutions.append(('%loadbye',
+ '-fpass-plugin={}/Bye{}'.format(config.llvm_shlib_dir,
+ config.llvm_plugin_ext)))
+
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
config.python_executable = "@PYTHON_EXECUTABLE@"
config.flang_standalone_build = @FLANG_STANDALONE_BUILD@
config.has_plugins = @LLVM_ENABLE_PLUGINS@
+config.linked_bye_extension = @LLVM_BYE_LINK_INTO_TOOLS@
config.cc = "@CMAKE_C_COMPILER@"
config.targets_to_build = "@TARGETS_TO_BUILD@"