#include <RelationSolver.h>
|
| | RelationSolver ()=default |
| |
| Z3Expr | gamma_hat (const AbstractState &exeState) const |
| | Return Z3Expr according to valToValMap.
|
| |
| Z3Expr | gamma_hat (const AbstractState &alpha, const AbstractState &exeState) const |
| | Return Z3Expr according to another valToValMap.
|
| |
| Z3Expr | gamma_hat (u32_t id, const AbstractState &exeState) const |
| | Return Z3Expr from a NodeID.
|
| |
| AbstractState | abstract_consequence (const AbstractState &lower, const AbstractState &upper, const AbstractState &domain) const |
| |
| AbstractState | beta (const Map< u32_t, s32_t > &sigma, const AbstractState &exeState) const |
| |
| virtual Z3Expr | toIntZ3Expr (u32_t varId) const |
| | Return Z3 expression lazily based on SVFVar ID.
|
| |
| Z3Expr | toIntVal (s32_t f) const |
| |
| Z3Expr | toRealVal (BoundedDouble f) const |
| |
| AbstractState | bilateral (const AbstractState &domain, const Z3Expr &phi, u32_t descend_check=0) |
| |
| AbstractState | RSY (const AbstractState &domain, const Z3Expr &phi) |
| |
| Map< u32_t, s32_t > | BoxedOptSolver (const Z3Expr &phi, Map< u32_t, s32_t > &ret, Map< u32_t, s32_t > &low_values, Map< u32_t, s32_t > &high_values) |
| |
| AbstractState | BS (const AbstractState &domain, const Z3Expr &phi) |
| |
| void | updateMap (Map< u32_t, s32_t > &map, u32_t key, const s32_t &value) |
| |
| void | decide_cpa_ext (const Z3Expr &phi, Map< u32_t, Z3Expr > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &) |
| |
Definition at line 42 of file RelationSolver.h.
◆ RelationSolver()
| SVF::RelationSolver::RelationSolver |
( |
| ) |
|
|
default |
◆ abstract_consequence()
for variable in self.variables:
proposed = self.top.copy()
proposed.set_interval(variable, lower.interval_of(variable)) proposed._locToItvVal
if not proposed >= upper:
return proposed
return lower.copy()
Definition at line 176 of file RelationSolver.cpp.
178{
179
180
181
182
183
184
185
186
187
188
189 for (
auto it =
domain.getVarToVal().begin();
192 {
198 {
200 }
201 }
203}
AbstractState top() const
Set all value top.
llvm::IRBuilder IRBuilder
◆ beta()
◆ bilateral()
init variables
TODO: add option for timeout
start processing
compute domain.model_and(phi, domain.logic_not(domain.gamma_hat(consequence)))
find any solution, which is sat
unknown or unsat
for timeout reason return upper
Definition at line 42 of file RelationSolver.cpp.
44{
52 p.set(
":timeout",
static_cast<unsigned>(600));
55
58 {
60 {
62 }
63 else
64 {
66 }
69 solver.push();
70 solver.add(
phi.getExpr() &&
rhs.getExpr());
72 z3::check_result
checkRes = solver.check();
75 {
76 z3::model
m = solver.get_model();
78 {
79 z3::func_decl
v =
m[
i];
80
82 continue;
83 solution.emplace(std::stoi(
v.name().str()),
84 m.get_const_interp(
v).get_numeral_int());
85 }
87 {
89 {
91 }
92 }
93 solver.pop();
100 }
101 else
102 {
103 solver.pop();
105 {
107 if (solver.reason_unknown() == "timeout")
109 }
115 }
116 }
118}
AbstractState bottom() const
Set all value bottom.
void joinWith(const AbstractState &other)
domain join with other, important! other widen this.
void meetWith(const AbstractState &other)
domain meet with other, important! other widen this.
Z3Expr gamma_hat(const AbstractState &exeState) const
Return Z3Expr according to valToValMap.
AbstractState beta(const Map< u32_t, s32_t > &sigma, const AbstractState &exeState) const
AbstractState abstract_consequence(const AbstractState &lower, const AbstractState &upper, const AbstractState &domain) const
static z3::solver & getSolver()
Get z3 solver, singleton design here to make sure we only have one context.
static z3::context & getContext()
Get z3 context, singleton design here to make sure we only have one context.
◆ BoxedOptSolver()
this is the S in the original paper
Definition at line 351 of file RelationSolver.cpp.
352{
356 while (1)
357 {
359 for (
const auto&
item : ret)
360 {
363 {
368 }
369 }
371 break;
372 else
374 }
375 return ret;
376}
virtual Z3Expr toIntZ3Expr(u32_t varId) const
Return Z3 expression lazily based on SVFVar ID.
void updateMap(Map< u32_t, s32_t > &map, u32_t key, const s32_t &value)
void decide_cpa_ext(const Z3Expr &phi, Map< u32_t, Z3Expr > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &)
Z3Expr toIntVal(s32_t f) const
◆ BS()
because key of _varToItvVal is u32_t, -key may out of range for int so we do key + bias for -key
init low, ret, high
init objects -x
add a relation that x == -(x+bias)
optimize each object
fill in the return values
Definition at line 276 of file RelationSolver.cpp.
277{
282
283
284
290 {
295 else
299 else
303 }
305 {
312 else
316 else
320 }
325 for (
const auto&
item: ret)
326 {
328 {
331
335 else
337
338 }
339 else
340 {
344 else
346 }
347 }
349}
static BoundedInt plus_infinity()
bool is_minus_infinity() const
bool is_plus_infinity() const
s64_t getIntNumeral() const
static BoundedInt minus_infinity()
const BoundedInt & ub() const
Return the upper bound.
static IntervalValue top()
Create the IntervalValue [-inf, +inf].
const BoundedInt & lb() const
Return the lower bound.
Map< u32_t, s32_t > BoxedOptSolver(const Z3Expr &phi, Map< u32_t, s32_t > &ret, Map< u32_t, s32_t > &low_values, Map< u32_t, s32_t > &high_values)
◆ decide_cpa_ext()
| void RelationSolver::decide_cpa_ext |
( |
const Z3Expr & |
phi, |
|
|
Map< u32_t, Z3Expr > & |
L_phi, |
|
|
Map< u32_t, s32_t > & |
mid_values, |
|
|
Map< u32_t, s32_t > & |
ret, |
|
|
Map< u32_t, s32_t > & |
low_values, |
|
|
Map< u32_t, s32_t > & |
high_values |
|
) |
| |
find any solution, which is sat
id is the var id, value is the solution found for var_id add a relation to check if the solution meets phi_id
unknown or unsat, we consider unknown as unsat
Definition at line 379 of file RelationSolver.cpp.
385{
386 while (1)
387 {
393 solver.push();
396 z3::check_result
checkRes = solver.check();
399 {
400 z3::model
m = solver.get_model();
401 solver.pop();
403 {
405 int value =
m.eval(
toIntZ3Expr(
id).getExpr()).get_numeral_int();
406
410 solver.push();
411 solver.add(
expr.getExpr());
412
413 if (solver.check() == z3::sat)
414 {
417
421
424 }
425 solver.pop();
426 }
427 }
428 else
429 {
430 solver.pop();
433 return;
434 }
435 }
436
437}
◆ gamma_hat() [1/3]
Return Z3Expr according to another valToValMap.
Definition at line 222 of file RelationSolver.cpp.
224{
227 {
231 if (interval.
isTop())
232 continue;
236 }
237 return res;
238}
s64_t getNumeral() const
Retrieves the numeral value of the BoundedInt object.
◆ gamma_hat() [2/3]
Return Z3Expr according to valToValMap.
Definition at line 205 of file RelationSolver.cpp.
206{
209 {
213 if (interval.
isTop())
214 continue;
218 }
219 return res;
220}
◆ gamma_hat() [3/3]
Return Z3Expr from a NodeID.
Definition at line 240 of file RelationSolver.cpp.
241{
245
246 Z3Expr res = (
v >= (
int)
it->second.getInterval().lb().getNumeral() &&
247 v <= (
int)
it->second.getInterval().ub().getNumeral());
248 return res;
249}
◆ RSY()
TODO: add option for timeout
find any solution, which is sat
unknown or unsat
for timeout reason return upper
Definition at line 120 of file RelationSolver.cpp.
121{
126 p.set(
":timeout",
static_cast<unsigned>(600));
128 while (1)
129 {
131 solver.push();
132 solver.add(
phi.getExpr() &&
rhs.getExpr());
134 z3::check_result
checkRes = solver.check();
137 {
138 z3::model
m = solver.get_model();
140 {
141 z3::func_decl
v =
m[
i];
143 continue;
144
145 solution.emplace(std::stoi(
v.name().str()),
146 m.get_const_interp(
v).get_numeral_int());
147 }
149 {
151 {
153 }
154 }
155 solver.pop();
160 }
161 else
162 {
163 solver.pop();
165 {
167 if (solver.reason_unknown() == "timeout")
169 }
170 break;
171 }
172 }
174}
◆ toIntVal()
◆ toIntZ3Expr()
◆ toRealVal()
◆ updateMap()
The documentation for this class was generated from the following files: