skip functions with loops for now
MODIFY
ir/state.cpp
ir/state.cpp
@@ -66,6 +66,7 @@ const State::ValTy& State::at(const Value &val) const {
}
bool State::startBB(const BasicBlock &bb) {
+ seen_bbs.emplace(&bb);
auto I = domain_bbs.find(&bb);
if (I == domain_bbs.end())
return false;
@@ -76,6 +77,9 @@ bool State::startBB(const BasicBlock &bb) {
}
void State::addJump(const BasicBlock &dst, expr &&domain) {
+ if (seen_bbs.count(&dst))
+ throw LoopInCFGDetected();
+
auto p = domain_bbs.try_emplace(&dst, move(domain), undef_vars);
if (!p.second) {
p.first->second.first |= move(domain);

MODIFY
ir/state.h
ir/state.h
#include <ostream>
#include <set>
#include <unordered_map>
+#include <unordered_set>
#include <utility>
#include <vector>
namespace IR {
+struct LoopInCFGDetected : public std::exception {};
+
+
struct StateValue {
smt::expr value, non_poison;
@@ -54,6 +58,7 @@ private:
std::unordered_map<const BasicBlock*,
std::pair<smt::expr, std::set<smt::expr>>> domain_bbs;
+ std::unordered_set<const BasicBlock*> seen_bbs;
// temp state
smt::expr domain;

MODIFY
tools/transform.cpp
tools/transform.cpp
@@ -218,8 +218,13 @@ TransformVerify::TransformVerify(Transform &t, bool check_each_var) :
Errors TransformVerify::verify() const {
Value::reset_gbl_id();
State src_state(t.src), tgt_state(t.tgt);
+
+ try {
sym_exec(src_state);
sym_exec(tgt_state);
+ } catch (LoopInCFGDetected &e) {
+ return "WARNING: Loops not supported yet! Skipping function.";
+ }
Errors errs;

MODIFY
util/errors.cpp
util/errors.cpp
@@ -7,6 +7,18 @@ using namespace std;
namespace util {
+Errors::Errors(const char *str) {
+ add(str);
+}
+
+Errors::Errors(string &&str) {
+ add(move(str));
+}
+
+void Errors::add(const char *str) {
+ errs.emplace_back(str);
+}
+
void Errors::add(string &&str) {
errs.emplace_back(str);
}

MODIFY
util/errors.h
util/errors.h
@@ -13,6 +13,10 @@ class Errors {
std::vector<std::string> errs;
public:
+ Errors() = default;
+ Errors(const char *str);
+ Errors(std::string &&str);
+ void add(const char *str);
void add(std::string &&str);
explicit operator bool() const { return !errs.empty(); }
bool isTimeout() const;

skip functions with loops for now