24#include "llvm/Support/CommandLine.h"
30cl::opt<bool> DebugCexCacheCheckBinding(
31 "debug-cex-cache-check-binding", cl::init(
false),
32 cl::desc(
"Debug the correctness of the counterexample "
33 "cache assignments (default=false)"),
37 CexCacheTryAll(
"cex-cache-try-all", cl::init(
false),
38 cl::desc(
"Try substituting all counterexamples before "
39 "asking the SMT solver (default=false)"),
43 CexCacheSuperSet(
"cex-cache-superset", cl::init(
false),
44 cl::desc(
"Try substituting SAT superset counterexample "
45 "before asking the SMT solver (default=false)"),
48cl::opt<bool> CexCacheExperimental(
49 "cex-cache-exp", cl::init(
false),
50 cl::desc(
"Optimization for validity queries (default=false)"),
95 const std::vector<const Array*> &objects,
96 std::vector< std::vector<unsigned char> > &values,
137 if (CexCacheTryAll) {
141 if (CexCacheSuperSet)
159 if (a->
satisfies(key.begin(), key.end())) {
170 if (CexCacheSuperSet)
227 std::vector<const Array*> objects;
230 std::vector< std::vector<unsigned char> > values;
241 std::pair<assignmentsTable_ty::iterator, bool>
245 binding = *res.first;
248 if (DebugCexCacheCheckBinding)
249 if (!binding->
satisfies(key.begin(), key.end())) {
252 klee_error(
"Generated assignment doesn't match query");
280 assert(a &&
"computeValidity() must have assignment");
282 assert(isa<ConstantExpr>(q) &&
283 "assignment evaluation did not result in constant");
285 if (cast<ConstantExpr>(q)->isTrue()) {
288 result = !a ? Solver::True : Solver::Unknown;
292 result = !a ? Solver::False : Solver::Unknown;
310 if (CexCacheExperimental) {
332 assert(a &&
"computeValue() must have assignment");
334 assert(isa<ConstantExpr>(result) &&
335 "assignment evaluation did not result in constant");
341 const std::vector<const Array*>
343 std::vector< std::vector<unsigned char> >
357 values = std::vector< std::vector<unsigned char> >(objects.size());
358 for (
unsigned i=0; i < objects.size(); ++i) {
359 const Array *os = objects[i];
360 Assignment::bindings_ty::iterator it = a->
bindings.find(os);
363 values[i] = std::vector<unsigned char>(os->
size, 0);
365 values[i] = it->second;
std::set< ref< Expr > > KeyType
CexCachingSolver(Solver *_solver)
SolverRunStatus getOperationStatusCode()
getOperationStatusCode - get the status of the last solver operation
bool computeInitialValues(const Query &, const std::vector< const Array * > &objects, std::vector< std::vector< unsigned char > > &values, bool &hasSolution)
bool computeValue(const Query &, ref< Expr > &result)
bool computeValidity(const Query &, Solver::Validity &result)
assignmentsTable_ty assignmentsTable
bool searchForAssignment(KeyType &key, Assignment *&result)
bool lookupAssignment(const Query &query, Assignment *&result)
MapOfSets< ref< Expr >, Assignment * > cache
bool lookupAssignment(const Query &query, KeyType &key, Assignment *&result)
bool getAssignment(const Query &query, Assignment *&result)
char * getConstraintLog(const Query &query)
std::set< Assignment *, AssignmentLessThan > assignmentsTable_ty
bool computeTruth(const Query &, bool &isValid)
void setCoreSolverTimeout(time::Span timeout)
bool satisfies(InputIterator begin, InputIterator end)
ref< Expr > evaluate(const Array *mo, unsigned index) const
constraint_iterator end() const
constraint_iterator begin() const
V * lookup(const std::set< K > &set)
V * findSuperset(const std::set< K > &set, const Predicate &p)
void insert(const std::set< K > &set, const V &value)
V * findSubset(const std::set< K > &set, const Predicate &p)
SolverImpl - Abstract base clase for solver implementations.
virtual void setCoreSolverTimeout(time::Span timeout)
virtual bool computeInitialValues(const Query &query, const std::vector< const Array * > &objects, std::vector< std::vector< unsigned char > > &values, bool &hasSolution)=0
virtual char * getConstraintLog(const Query &query)
virtual SolverRunStatus getOperationStatusCode()=0
getOperationStatusCode - get the status of the last solver operation
Statistic queryCexCacheMisses
Statistic queryCexCacheHits
void findSymbolicObjects(ref< Expr > e, std::vector< const Array * > &results)
Solver * createCexCachingSolver(Solver *s)
void klee_error(const char *msg,...) __attribute__((format(printf
llvm::cl::OptionCategory SolvingCat
bool operator()(const Assignment *a, const Assignment *b) const
bool operator()(Assignment *a) const
bool operator()(Assignment *a) const
bool operator()(Assignment *a) const
NullOrSatisfyingAssignment(KeyType &_key)
const ConstraintSet & constraints
void dump() const
Dump query.
Query withFalse() const
withFalse - Return a copy of the query with a false expression.
Query negateExpr() const
negateExpr - Return a copy of the query with the expression negated.