From 8a0f1af7500e10dadd97300f242424917d2e9902 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Mon, 1 Apr 2019 14:08:43 +0100 Subject: Use constraint sets and separate metadata for timing solver invocation Decouple ExecutionState from TimingSolver Instead of providing an execution state to the timing solver use a set of constraints and an additional object for metadata. Fixes: * correct accounting of metadata to a specific state * accounting of all solver invocations (e.g. solver-getRange was not accounted) * allows to invoke the solver without a state (avoids costly copying of states/constraints) --- lib/Core/TimingSolver.h | 78 ++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 37 deletions(-) (limited to 'lib/Core/TimingSolver.h') diff --git a/lib/Core/TimingSolver.h b/lib/Core/TimingSolver.h index 9470bd31..1f179e54 100644 --- a/lib/Core/TimingSolver.h +++ b/lib/Core/TimingSolver.h @@ -19,54 +19,58 @@ #include namespace klee { - class ExecutionState; - class Solver; - - /// TimingSolver - A simple class which wraps a solver and handles - /// tracking the statistics that we care about. - class TimingSolver { - public: - std::unique_ptr solver; - bool simplifyExprs; - - public: - /// TimingSolver - Construct a new timing solver. - /// - /// \param _simplifyExprs - Whether expressions should be - /// simplified (via the constraint manager interface) prior to - /// querying. - TimingSolver(Solver *_solver, bool _simplifyExprs = true) +class ConstraintSet; +class Solver; + +/// TimingSolver - A simple class which wraps a solver and handles +/// tracking the statistics that we care about. +class TimingSolver { +public: + std::unique_ptr solver; + bool simplifyExprs; + +public: + /// TimingSolver - Construct a new timing solver. + /// + /// \param _simplifyExprs - Whether expressions should be + /// simplified (via the constraint manager interface) prior to + /// querying. + TimingSolver(Solver *_solver, bool _simplifyExprs = true) : solver(_solver), simplifyExprs(_simplifyExprs) {} - void setTimeout(time::Span t) { - solver->setCoreSolverTimeout(t); - } - - char *getConstraintLog(const Query& query) { - return solver->getConstraintLog(query); - } + void setTimeout(time::Span t) { solver->setCoreSolverTimeout(t); } - bool evaluate(const ExecutionState&, ref, Solver::Validity &result); + char *getConstraintLog(const Query &query) { + return solver->getConstraintLog(query); + } - bool mustBeTrue(const ExecutionState&, ref, bool &result); + bool evaluate(const ConstraintSet &, ref, Solver::Validity &result, + SolverQueryMetaData &metaData); - bool mustBeFalse(const ExecutionState&, ref, bool &result); + bool mustBeTrue(const ConstraintSet &, ref, bool &result, + SolverQueryMetaData &metaData); - bool mayBeTrue(const ExecutionState&, ref, bool &result); + bool mustBeFalse(const ConstraintSet &, ref, bool &result, + SolverQueryMetaData &metaData); - bool mayBeFalse(const ExecutionState&, ref, bool &result); + bool mayBeTrue(const ConstraintSet &, ref, bool &result, + SolverQueryMetaData &metaData); - bool getValue(const ExecutionState &, ref expr, - ref &result); + bool mayBeFalse(const ConstraintSet &, ref, bool &result, + SolverQueryMetaData &metaData); - bool getInitialValues(const ExecutionState&, - const std::vector &objects, - std::vector< std::vector > &result); + bool getValue(const ConstraintSet &, ref expr, + ref &result, SolverQueryMetaData &metaData); - std::pair< ref, ref > - getRange(const ExecutionState&, ref query); - }; + bool getInitialValues(const ConstraintSet &, + const std::vector &objects, + std::vector> &result, + SolverQueryMetaData &metaData); + std::pair, ref> getRange(const ConstraintSet &, + ref query, + SolverQueryMetaData &metaData); +}; } #endif /* KLEE_TIMINGSOLVER_H */ -- cgit 1.4.1