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/HideConstantLoadsPass.cpp b/lib/HideConstantLoadsPass.cpp
index ae4f4bd..d935267 100644
--- a/lib/HideConstantLoadsPass.cpp
+++ b/lib/HideConstantLoadsPass.cpp
@@ -25,6 +25,8 @@
#include "clspv/AddressSpace.h"
+#include "Passes.h"
+
using namespace llvm;
using std::string;
@@ -62,8 +64,8 @@
} // namespace
char HideConstantLoadsPass::ID = 0;
-static RegisterPass<HideConstantLoadsPass>
- X("HideConstantLoads", "Hide loads from __constant memory");
+INITIALIZE_PASS(HideConstantLoadsPass, "HideConstantLoads",
+ "Hide loads from __constant memory", false, false)
namespace clspv {
llvm::ModulePass *createHideConstantLoadsPass() {
@@ -145,8 +147,8 @@
} // namespace
char UnhideConstantLoadsPass::ID = 0;
-static RegisterPass<UnhideConstantLoadsPass>
- X2("UnhideConstantLoads", "Unhide loads from __constant memory");
+INITIALIZE_PASS(UnhideConstantLoadsPass, "UnhideConstantLoads",
+ "Unhide loads from __constant memory", false, false)
namespace clspv {
llvm::ModulePass *createUnhideConstantLoadsPass() {