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/DirectResourceAccessPass.cpp b/lib/DirectResourceAccessPass.cpp
index 83ee1bc..ad7f7b6 100644
--- a/lib/DirectResourceAccessPass.cpp
+++ b/lib/DirectResourceAccessPass.cpp
@@ -31,10 +31,10 @@
#include "llvm/Support/raw_ostream.h"
#include "clspv/Option.h"
-#include "clspv/Passes.h"
#include "ArgKind.h"
#include "Constants.h"
+#include "Passes.h"
using namespace llvm;
@@ -71,11 +71,12 @@
// same resource access. Returns true if the module changed.
bool RewriteAccessesForArg(Function *fn, int arg_index, Argument &arg);
};
+
} // namespace
char DirectResourceAccessPass::ID = 0;
-static RegisterPass<DirectResourceAccessPass> X("DirectResourceAccessPass",
- "Direct resource access");
+INITIALIZE_PASS(DirectResourceAccessPass, "DirectResourceAccessPass",
+ "Direct resource access", false, false)
namespace clspv {
ModulePass *createDirectResourceAccessPass() {