[PATCH] D18613: [PassManager] Make PassManagerBuilder::addExtension take an std::function, rather than a function pointer.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 30 11:52:02 PDT 2016
jlebar created this revision.
jlebar added a reviewer: chandlerc.
jlebar added a subscriber: cfe-commits.
Herald added a subscriber: joker.eph.
This gives callers flexibility to pass lambdas with captures, which lets
callers avoid the C-style void*-ptr closure style. (Currently, callers
in clang store state in the PassManagerBuilderBase arg.)
No functional change, and the new API is backwards-compatible.
http://reviews.llvm.org/D18613
Files:
include/llvm/Transforms/IPO/PassManagerBuilder.h
lib/Transforms/IPO/PassManagerBuilder.cpp
Index: lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- lib/Transforms/IPO/PassManagerBuilder.cpp
+++ lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -158,11 +158,11 @@
void PassManagerBuilder::addGlobalExtension(
PassManagerBuilder::ExtensionPointTy Ty,
PassManagerBuilder::ExtensionFn Fn) {
- GlobalExtensions->push_back(std::make_pair(Ty, Fn));
+ GlobalExtensions->push_back(std::make_pair(Ty, std::move(Fn)));
}
void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) {
- Extensions.push_back(std::make_pair(Ty, Fn));
+ Extensions.push_back(std::make_pair(Ty, std::move(Fn)));
}
void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy,
Index: include/llvm/Transforms/IPO/PassManagerBuilder.h
===================================================================
--- include/llvm/Transforms/IPO/PassManagerBuilder.h
+++ include/llvm/Transforms/IPO/PassManagerBuilder.h
@@ -59,8 +59,9 @@
public:
/// Extensions are passed the builder itself (so they can see how it is
/// configured) as well as the pass manager to add stuff to.
- typedef void (*ExtensionFn)(const PassManagerBuilder &Builder,
- legacy::PassManagerBase &PM);
+ typedef std::function<void(const PassManagerBuilder &Builder,
+ legacy::PassManagerBase &PM)>
+ ExtensionFn;
enum ExtensionPointTy {
/// EP_EarlyAsPossible - This extension point allows adding passes before
/// any other transformations, allowing them to see the code as it is coming
@@ -143,7 +144,7 @@
private:
/// ExtensionList - This is list of all of the extensions that are registered.
- std::vector<std::pair<ExtensionPointTy, ExtensionFn> > Extensions;
+ std::vector<std::pair<ExtensionPointTy, ExtensionFn>> Extensions;
public:
PassManagerBuilder();
@@ -184,7 +185,7 @@
struct RegisterStandardPasses {
RegisterStandardPasses(PassManagerBuilder::ExtensionPointTy Ty,
PassManagerBuilder::ExtensionFn Fn) {
- PassManagerBuilder::addGlobalExtension(Ty, Fn);
+ PassManagerBuilder::addGlobalExtension(Ty, std::move(Fn));
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18613.52096.patch
Type: text/x-patch
Size: 2209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160330/5c79a474/attachment.bin>
More information about the cfe-commits
mailing list