about summary refs log tree commit diff homepage
path: root/lib/Basic
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2016-04-11 08:19:02 -0500
committerDan Liew <daniel.liew@imperial.ac.uk>2016-09-15 13:09:43 +0100
commitd34a946acb7f5155ee62f1bdc95ae7ef7b848e49 (patch)
tree39e700b83f73e05223adf1727339f39119b4869a /lib/Basic
parent746c25599f75088c3b4d02fe51e4240b0079781c (diff)
downloadklee-d34a946acb7f5155ee62f1bdc95ae7ef7b848e49.tar.gz
Add ``-debug-cross-check-core-solver`` option to allow cross-checking
with another solver. For example the core solver can be STP and the
cross checking solver can be Z3.

Unfortunately a few fragile tests don't pass when actually using this
option.
Diffstat (limited to 'lib/Basic')
-rw-r--r--lib/Basic/CmdLineOptions.cpp13
-rw-r--r--lib/Basic/ConstructSolverChain.cpp4
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/Basic/CmdLineOptions.cpp b/lib/Basic/CmdLineOptions.cpp
index 20c190a5..70ef999e 100644
--- a/lib/Basic/CmdLineOptions.cpp
+++ b/lib/Basic/CmdLineOptions.cpp
@@ -139,6 +139,19 @@ llvm::cl::opt<CoreSolverType> CoreSolverToUse(
                      clEnumValN(Z3_SOLVER, "z3", "Z3" Z3_IS_DEFAULT_STR),
                      clEnumValEnd),
     llvm::cl::init(DEFAULT_CORE_SOLVER));
+
+llvm::cl::opt<CoreSolverType> DebugCrossCheckCoreSolverWith(
+    "debug-cross-check-core-solver",
+    llvm::cl::desc(
+        "Specifiy a solver to use for cross checking with the core solver"),
+    llvm::cl::values(clEnumValN(STP_SOLVER, "stp", "stp"),
+                     clEnumValN(METASMT_SOLVER, "metasmt", "metaSMT"),
+                     clEnumValN(DUMMY_SOLVER, "dummy", "Dummy solver"),
+                     clEnumValN(Z3_SOLVER, "z3", "Z3"),
+                     clEnumValN(NO_SOLVER, "none",
+                                "Do not cross check (default)"),
+                     clEnumValEnd),
+    llvm::cl::init(NO_SOLVER));
 }
 #undef STP_IS_DEFAULT_STR
 #undef METASMT_IS_DEFAULT_STR
diff --git a/lib/Basic/ConstructSolverChain.cpp b/lib/Basic/ConstructSolverChain.cpp
index b48c5cb0..2df87d51 100644
--- a/lib/Basic/ConstructSolverChain.cpp
+++ b/lib/Basic/ConstructSolverChain.cpp
@@ -62,6 +62,10 @@ Solver *constructSolverChain(Solver *coreSolver, std::string querySMT2LogPath,
     llvm::errs() << "Logging all queries in .smt2 format to "
                  << querySMT2LogPath.c_str() << "\n";
   }
+  if (DebugCrossCheckCoreSolverWith != NO_SOLVER) {
+    Solver *oracleSolver = createCoreSolver(DebugCrossCheckCoreSolverWith);
+    solver = createValidatingSolver(/*s=*/solver, /*oracle=*/oracleSolver);
+  }
 
   return solver;
 }