Re-implement clspv-opt as a standalone driver (#346)
* Fix #307 and #322.
This re-implements clspv-opt as a standalone driver. The initial
implementation used the plugin facility for LLVM opt, but this is
difficult to implement in Windows (#307).
The driver only supports LLVM scalar transformations and all of clspv
transformations. To do this, passes must be declared using LLVM's
INITIALIZE_PASS macro. Additionally, the function
initializeClspvPasses() must include a call to the initialize*()
function generated by INITIALIZE_PASS.
This change also adds tests for all the existing passes in clspv. It
does not check for specific transformations. It checks that the flags
are accepted by clspv-opt.
Finally, this change reduces the build time for LLVM by building no
target backends by default.
diff --git a/lib/ShareModuleScopeVariables.cpp b/lib/ShareModuleScopeVariables.cpp
index afbb5a3..61f754c 100644
--- a/lib/ShareModuleScopeVariables.cpp
+++ b/lib/ShareModuleScopeVariables.cpp
@@ -22,10 +22,11 @@
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
-#include "ArgKind.h"
#include "clspv/AddressSpace.h"
#include "clspv/Option.h"
-#include "clspv/Passes.h"
+
+#include "ArgKind.h"
+#include "Passes.h"
using namespace llvm;
@@ -67,12 +68,12 @@
EntryPointMap function_to_entry_points_;
};
-char ShareModuleScopeVariablesPass::ID = 0;
-static RegisterPass<ShareModuleScopeVariablesPass>
- X("ShareModuleScopeVariablesPass", "Share module scope variables");
-
} // namespace
+char ShareModuleScopeVariablesPass::ID = 0;
+INITIALIZE_PASS(ShareModuleScopeVariablesPass, "ShareModuleScopeVariablesPass",
+ "Share module scope variables", false, false)
+
namespace clspv {
ModulePass *createShareModuleScopeVariablesPass() {
return new ShareModuleScopeVariablesPass();