[clang] [flang] [llvm] [polly] Import and Export `getXXXPluginInfo` from embedded plugin such as Polly (PR #156440)
Tomohiro Kashiwada via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 11 03:05:42 PDT 2025
https://github.com/kikairoya updated https://github.com/llvm/llvm-project/pull/156440
>From 730fdd7f3ff13fd4c1ca089aa8626653a5aa6f4e Mon Sep 17 00:00:00 2001
From: kikairoya <kikairoya at gmail.com>
Date: Sun, 7 Sep 2025 12:12:21 +0900
Subject: [PATCH 1/2] win32dll
---
clang/lib/CodeGen/BackendUtil.cpp | 2 +-
flang/lib/Frontend/FrontendActions.cpp | 2 +-
llvm/docs/WritingAnLLVMNewPMPass.rst | 4 ++--
llvm/lib/Extensions/Extensions.cpp | 2 +-
llvm/lib/LTO/LTOBackend.cpp | 2 +-
llvm/tools/bugpoint/bugpoint.cpp | 2 +-
llvm/tools/opt/NewPMDriver.cpp | 2 +-
polly/include/polly/RegisterPasses.h | 4 +++-
8 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 3f095c03397fd..2e6f9e90f2db6 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -94,7 +94,7 @@ using namespace clang;
using namespace llvm;
#define HANDLE_EXTENSION(Ext) \
- llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+ LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
#include "llvm/Support/Extension.def"
namespace llvm {
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 3bef6b1c31825..e61dee5e26636 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -87,7 +87,7 @@ constexpr llvm::StringLiteral timingIdBackend =
// Declare plugin extension function declarations.
#define HANDLE_EXTENSION(Ext) \
- llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+ LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
#include "llvm/Support/Extension.def"
/// Save the given \c mlirModule to a temporary .mlir file, in a location
diff --git a/llvm/docs/WritingAnLLVMNewPMPass.rst b/llvm/docs/WritingAnLLVMNewPMPass.rst
index ea30d637347f1..5e41a939081a3 100644
--- a/llvm/docs/WritingAnLLVMNewPMPass.rst
+++ b/llvm/docs/WritingAnLLVMNewPMPass.rst
@@ -254,7 +254,7 @@ See the definition of ``add_llvm_pass_plugin`` for more CMake details.
The pass must provide at least one of two entry points for the new pass manager,
one for static registration and one for dynamically loaded plugins:
-- ``llvm::PassPluginLibraryInfo get##Name##PluginInfo();``
+- ``LLVM_ABI llvm::PassPluginLibraryInfo get##Name##PluginInfo();``
- ``extern "C" ::llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() LLVM_ATTRIBUTE_WEAK;``
Pass plugins are compiled and linked dynamically by default. Setting
@@ -268,7 +268,7 @@ To make ``PassBuilder`` aware of statically linked pass plugins:
.. code-block:: c++
// Declare plugin extension function declarations.
- #define HANDLE_EXTENSION(Ext) llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+ #define HANDLE_EXTENSION(Ext) LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
#include "llvm/Support/Extension.def"
...
diff --git a/llvm/lib/Extensions/Extensions.cpp b/llvm/lib/Extensions/Extensions.cpp
index 0d25cbda38e00..67b1fa087e0c1 100644
--- a/llvm/lib/Extensions/Extensions.cpp
+++ b/llvm/lib/Extensions/Extensions.cpp
@@ -1,6 +1,6 @@
#include "llvm/Passes/PassPlugin.h"
#define HANDLE_EXTENSION(Ext) \
- llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+ LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
#include "llvm/Support/Extension.def"
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index ce42fc526beac..37ff7a4968e41 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -178,7 +178,7 @@ Error Config::addSaveTemps(std::string OutputFileName, bool UseInputModulePath,
}
#define HANDLE_EXTENSION(Ext) \
- llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+ LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
#include "llvm/Support/Extension.def"
#undef HANDLE_EXTENSION
diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp
index 87581e80a2496..741374bfaf162 100644
--- a/llvm/tools/bugpoint/bugpoint.cpp
+++ b/llvm/tools/bugpoint/bugpoint.cpp
@@ -93,7 +93,7 @@ class AddToDriver : public legacy::FunctionPassManager {
}
#define HANDLE_EXTENSION(Ext) \
- llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+ LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
#include "llvm/Support/Extension.def"
int main(int argc, char **argv) {
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index b9b8929a0f703..81909ea94f227 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -344,7 +344,7 @@ static void registerEPCallbacks(PassBuilder &PB) {
}
#define HANDLE_EXTENSION(Ext) \
- llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+ LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
#include "llvm/Support/Extension.def"
#undef HANDLE_EXTENSION
diff --git a/polly/include/polly/RegisterPasses.h b/polly/include/polly/RegisterPasses.h
index 3a81e1ba7487d..3c358c8d77d4c 100644
--- a/polly/include/polly/RegisterPasses.h
+++ b/polly/include/polly/RegisterPasses.h
@@ -13,6 +13,8 @@
#ifndef POLLY_REGISTER_PASSES_H
#define POLLY_REGISTER_PASSES_H
+#include "llvm/Support/Compiler.h"
+
namespace llvm {
class PassRegistry;
class PassBuilder;
@@ -27,6 +29,6 @@ void initializePollyPasses(llvm::PassRegistry &Registry);
void registerPollyPasses(llvm::PassBuilder &PB);
} // namespace polly
-llvm::PassPluginLibraryInfo getPollyPluginInfo();
+LLVM_ALWAYS_EXPORT llvm::PassPluginLibraryInfo getPollyPluginInfo();
#endif
>From b86b377b50e1a6f4042eb1d00f7f82f3631184da Mon Sep 17 00:00:00 2001
From: kikairoya <kikairoya at gmail.com>
Date: Wed, 10 Sep 2025 16:35:40 +0900
Subject: [PATCH 2/2] don't use LLVM_ALWAYS_EXPORT
---
polly/include/polly/RegisterPasses.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/polly/include/polly/RegisterPasses.h b/polly/include/polly/RegisterPasses.h
index 3c358c8d77d4c..0b6eec2b2db0c 100644
--- a/polly/include/polly/RegisterPasses.h
+++ b/polly/include/polly/RegisterPasses.h
@@ -29,6 +29,6 @@ void initializePollyPasses(llvm::PassRegistry &Registry);
void registerPollyPasses(llvm::PassBuilder &PB);
} // namespace polly
-LLVM_ALWAYS_EXPORT llvm::PassPluginLibraryInfo getPollyPluginInfo();
+LLVM_ABI llvm::PassPluginLibraryInfo getPollyPluginInfo();
#endif
More information about the llvm-commits
mailing list