|
@@ -60,9 +60,10 @@ class PassManagerBuilder {
|
|
public:
|
|
public:
|
|
/// Extensions are passed the builder itself (so they can see how it is
|
|
/// Extensions are passed the builder itself (so they can see how it is
|
|
/// configured) as well as the pass manager to add stuff to.
|
|
/// configured) as well as the pass manager to add stuff to.
|
|
- typedef std::function<void(const PassManagerBuilder &Builder,
|
|
|
|
- legacy::PassManagerBase &PM)>
|
|
|
|
- ExtensionFn;
|
|
|
|
|
|
+ typedef void ExtensionProc(const PassManagerBuilder &Builder,
|
|
|
|
+ legacy::PassManagerBase &PM);
|
|
|
|
+ typedef std::function<ExtensionProc> ExtensionFn;
|
|
|
|
+
|
|
enum ExtensionPointTy {
|
|
enum ExtensionPointTy {
|
|
/// EP_EarlyAsPossible - This extension point allows adding passes before
|
|
/// EP_EarlyAsPossible - This extension point allows adding passes before
|
|
/// any other transformations, allowing them to see the code as it is coming
|
|
/// any other transformations, allowing them to see the code as it is coming
|
|
@@ -179,7 +180,7 @@ public:
|
|
/// Adds an extension that will be used by all PassManagerBuilder instances.
|
|
/// Adds an extension that will be used by all PassManagerBuilder instances.
|
|
/// This is intended to be used by plugins, to register a set of
|
|
/// This is intended to be used by plugins, to register a set of
|
|
/// optimisations to run automatically.
|
|
/// optimisations to run automatically.
|
|
- static void addGlobalExtension(ExtensionPointTy Ty, ExtensionFn Fn);
|
|
|
|
|
|
+ static void addGlobalExtension(ExtensionPointTy Ty, ExtensionProc Fn);
|
|
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn);
|
|
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn);
|
|
|
|
|
|
private:
|
|
private:
|
|
@@ -208,10 +209,12 @@ public:
|
|
/// used by optimizer plugins to allow all front ends to transparently use
|
|
/// used by optimizer plugins to allow all front ends to transparently use
|
|
/// them. Create a static instance of this class in your plugin, providing a
|
|
/// them. Create a static instance of this class in your plugin, providing a
|
|
/// private function that the PassManagerBuilder can use to add your passes.
|
|
/// private function that the PassManagerBuilder can use to add your passes.
|
|
|
|
+/// Currently limited to real functions to avoid crashes when used within the
|
|
|
|
+/// main executable before a loaded plugin has a chance to use this.
|
|
struct RegisterStandardPasses {
|
|
struct RegisterStandardPasses {
|
|
RegisterStandardPasses(PassManagerBuilder::ExtensionPointTy Ty,
|
|
RegisterStandardPasses(PassManagerBuilder::ExtensionPointTy Ty,
|
|
- PassManagerBuilder::ExtensionFn Fn) {
|
|
|
|
- PassManagerBuilder::addGlobalExtension(Ty, std::move(Fn));
|
|
|
|
|
|
+ PassManagerBuilder::ExtensionProc Fn) {
|
|
|
|
+ PassManagerBuilder::addGlobalExtension(Ty, Fn);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|