summaryrefslogtreecommitdiff
path: root/tools/llc
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2005-07-28 02:25:30 +0000
committerReid Spencer <rspencer@reidspencer.com>2005-07-28 02:25:30 +0000
commit4418c2b3acfcb6cdb05f133aef8eef74ed0d0566 (patch)
treeb5abffcb83be46cb05d138e55b81b24a26628164 /tools/llc
parent832481fd99f7916e09c0ebc08c1b5d9402ce739b (diff)
downloadllvm-4418c2b3acfcb6cdb05f133aef8eef74ed0d0566.tar.gz
llvm-4418c2b3acfcb6cdb05f133aef8eef74ed0d0566.tar.bz2
llvm-4418c2b3acfcb6cdb05f133aef8eef74ed0d0566.tar.xz
Make the verifier pass run (in debug mode) in llc. This adds a sanity check
to llc when debugging. Also allow other passes to be run from llc. Patch contributed by Michael McCracken. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22532 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llc')
-rw-r--r--tools/llc/llc.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 70d8c70fc3..9643f1e2e0 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -22,6 +22,8 @@
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/PluginLoader.h"
+#include "llvm/Support/PassNameParser.h"
+#include "llvm/Analysis/Verifier.h"
#include "llvm/System/Signals.h"
#include "llvm/Config/config.h"
#include <fstream>
@@ -57,6 +59,14 @@ FileType("filetype", cl::init(TargetMachine::AssemblyFile),
" Emit a native dynamic library ('.so') file"),
clEnumValEnd));
+// The LLCPassList is populated with passes that were registered using
+// PassInfo::LLC by the FilteredPassNameParser:
+cl::list<const PassInfo*, bool, FilteredPassNameParser<PassInfo::LLC> >
+LLCPassList(cl::desc("Passes Available"));
+
+cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
+ cl::desc("Do not verify input module"));
+
// GetFileNameRoot - Helper function to get the basename of a filename.
static inline std::string
@@ -113,6 +123,25 @@ int main(int argc, char **argv) {
PassManager Passes;
Passes.add(new TargetData(TD));
+#ifndef NDEBUG
+ if(!NoVerify)
+ Passes.add(createVerifierPass());
+#endif
+
+ // Create a new pass for each one specified on the command line
+ for (unsigned i = 0; i < LLCPassList.size(); ++i) {
+ const PassInfo *aPass = LLCPassList[i];
+
+ if (aPass->getNormalCtor()) {
+ Pass *P = aPass->getNormalCtor()();
+ Passes.add(P);
+ } else {
+ std::cerr << argv[0] << ": cannot create pass: "
+ << aPass->getPassName() << "\n";
+ }
+ }
+
+
// Figure out where we are going to send the output...
std::ostream *Out = 0;
if (OutputFilename != "") {