From 8da7d1d7ee67e1935c685511de64e3bbc031b083 Mon Sep 17 00:00:00 2001 From: Philip Pfaffe Date: Tue, 17 Apr 2018 07:59:46 +0000 Subject: [PATCH] [NewPM] Update pass registration for the LLVM plugin interface Summary: As of rL329273, LLVM has a mechanism to load new-pm plugins in opt. Use this API in Polly. Reviewers: grosser, Meinersbur, bollu Reviewed By: grosser, Meinersbur Subscribers: lksbhm, bollu, pollydev, llvm-commits Differential Revision: https://reviews.llvm.org/D45484 llvm-svn: 330181 --- polly/lib/Support/RegisterPasses.cpp | 8 ++++++++ polly/test/Support/Plugins.ll | 13 +++++++++++++ polly/test/lit.site.cfg.in | 2 ++ 3 files changed, 23 insertions(+) create mode 100644 polly/test/Support/Plugins.ll diff --git a/polly/lib/Support/RegisterPasses.cpp b/polly/lib/Support/RegisterPasses.cpp index 6a8669875839..2ce0f63e0f57 100644 --- a/polly/lib/Support/RegisterPasses.cpp +++ b/polly/lib/Support/RegisterPasses.cpp @@ -42,6 +42,7 @@ #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Verifier.h" #include "llvm/Passes/PassBuilder.h" +#include "llvm/Passes/PassPlugin.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" @@ -703,3 +704,10 @@ void RegisterPollyPasses(PassBuilder &PB) { // FIXME else Error? } } // namespace polly + +// Plugin Entrypoint: +extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK LLVM_PLUGIN_EXPORT +llvmGetPassPluginInfo() { + return {LLVM_PLUGIN_API_VERSION, "Polly", LLVM_VERSION_STRING, + polly::RegisterPollyPasses}; +} diff --git a/polly/test/Support/Plugins.ll b/polly/test/Support/Plugins.ll new file mode 100644 index 000000000000..26f0a8e93dff --- /dev/null +++ b/polly/test/Support/Plugins.ll @@ -0,0 +1,13 @@ +; RUN: opt %loadPolly -passes='polly-prepare,scop(print)' -S < %s \ +; RUN: | FileCheck %s + +; This testcase tests plugin registration. Check-lines below serve to verify +; that the passes actually ran. + +; CHECK-LABEL: void @foo +; CHECK-NEXT: entry: +; CHECK-NEXT: br label %entry.split +define void @foo() { +entry: + ret void +} diff --git a/polly/test/lit.site.cfg.in b/polly/test/lit.site.cfg.in index fda0865271e9..ad8437478b16 100644 --- a/polly/test/lit.site.cfg.in +++ b/polly/test/lit.site.cfg.in @@ -45,6 +45,8 @@ if config.link_polly_into_tools == '' or \ config.link_polly_into_tools.lower() == 'notfound' or \ config.link_polly_into_tools.lower() == 'link_polly_into_tools-notfound': config.substitutions.append(('%loadPolly', '-load ' + + config.polly_lib_dir + '/LLVMPolly@LLVM_SHLIBEXT@' + + ' -load-pass-plugin ' + config.polly_lib_dir + '/LLVMPolly@LLVM_SHLIBEXT@' + ' -polly-process-unprofitable ' + ' -polly-remarks-minimal '