31 case Expr::Constant: {
32 assert(value == cast<ConstantExpr>(e) &&
33 "error in implied value calculation");
39 case Expr::NotOptimized:
break;
47 results.push_back(std::make_pair(re, value));
57 if (TrueCE != FalseCE) {
58 if (value == TrueCE) {
62 assert(value == FalseCE &&
63 "err in implied value calculation");
132 if (value->isTrue()) {
144 if (value->isZero()) {
161 value = value->Not();
164 EqExpr *ee = cast<EqExpr>(e);
165 if (value->isTrue()) {
166 if (
ConstantExpr *CE = dyn_cast<ConstantExpr>(ee->left))
176 if (
ConstantExpr *CE = dyn_cast<ConstantExpr>(ee->left))
177 if (CE->getWidth() == Expr::Bool)
190 std::vector<ref<ReadExpr> > reads;
196 for (
auto &i : results) {
197 auto it = found.find(i.first);
198 if (it != found.end()) {
199 assert(it->second == i.second &&
"Invalid ImpliedValue!");
201 found.insert(std::make_pair(i.first, i.second));
206 std::set< ref<ReadExpr> > readsSet(reads.begin(), reads.end());
207 reads = std::vector< ref<ReadExpr> >(readsSet.begin(), readsSet.end());
210 assumption.
push_back(EqExpr::create(e, value));
218 for (std::vector<
ref<ReadExpr> >::iterator i = reads.begin(),
219 ie = reads.end(); i != ie; ++i) {
221 assumption.push_back(UltExpr::create(re->
index,
223 Context::get().getPointerWidth())));
226 for (
const auto &var : reads) {
228 bool success = S->
getValue(
Query(assumption, var), possible);
230 assert(success &&
"FIXME: Unhandled solver failure");
235 assert(success &&
"FIXME: Unhandled solver failure");
237 if (it != found.end()) {
238 assert(possible == it->second &&
"Invalid ImpliedValue!");
242 if (it!=found.end()) {
244 llvm::errs() <<
"checkForImpliedValues: " << e <<
" = " << value <<
"\n"
245 <<
"\t\t implies " << var <<
" == " << binding
252 assert(found.empty());
ref< Expr > getKid(unsigned i) const
void push_back(const ref< Expr > &e)
virtual Kind getKind() const =0
virtual Width getWidth() const =0
Class representing a one byte read from an array.
Class representing an if-then-else expression.
bool mustBeTrue(const Query &, bool &result)
bool getValue(const Query &, ref< ConstantExpr > &result)
void getImpliedValues(ref< Expr > e, ref< ConstantExpr > cvalue, ImpliedValueList &result)
void checkForImpliedValues(Solver *S, ref< Expr > e, ref< ConstantExpr > cvalue)
void findReads(ref< Expr > e, bool visitUpdates, std::vector< ref< ReadExpr > > &result)
std::vector< std::pair< ref< ReadExpr >, ref< ConstantExpr > > > ImpliedValueList