fix crash in some unit tests (regressions due to refactoring for alive-exec)
MODIFY
tools/alive-exec.cpp
tools/alive-exec.cpp
@@ -183,7 +183,7 @@ static void execFunction(llvm::Function &F, llvm::Triple &triple,
smt_init->reset();
try {
auto p = verifier.exec();
- auto &state = p.first;
+ auto &state = *p.first;
auto ret_domain = state.returnDomain()();
auto [ret_val, ret_undefs] = state.returnVal();

MODIFY
tools/transform.cpp
tools/transform.cpp
@@ -883,17 +883,18 @@ TransformVerify::TransformVerify(Transform &t, bool check_each_var) :
}
}
-pair<State, State> TransformVerify::exec() const {
+pair<unique_ptr<State>, unique_ptr<State>> TransformVerify::exec() const {
StopWatch symexec_watch;
t.tgt.syncDataWithSrc(t.src);
calculateAndInitConstants(t);
State::resetGlobals();
- State src_state(t.src, true), tgt_state(t.tgt, false);
- sym_exec(src_state);
- tgt_state.syncSEdataWithSrc(src_state);
- sym_exec(tgt_state);
- src_state.mkAxioms(tgt_state);
+ auto src_state = make_unique<State>(t.src, true);
+ auto tgt_state = make_unique<State>(t.tgt, false);
+ sym_exec(*src_state);
+ tgt_state->syncSEdataWithSrc(*src_state);
+ sym_exec(*tgt_state);
+ src_state->mkAxioms(*tgt_state);
symexec_watch.stop();
if (symexec_watch.seconds() > 5) {
@@ -944,27 +945,26 @@ Errors TransformVerify::verify() const {
auto [src_state, tgt_state] = exec();
if (check_each_var) {
- for (auto &[var, val, used] : src_state.getValues()) {
- (void)used;
+ for (auto &[var, val, used] : src_state->getValues()) {
auto &name = var->getName();
if (name[0] != '%' || !dynamic_cast<const Instr*>(var))
continue;
// TODO: add data-flow domain tracking for Alive, but not for TV
- check_refinement(errs, t, src_state, tgt_state, var, var->getType(),
+ check_refinement(errs, t, *src_state, *tgt_state, var, var->getType(),
true, true, val,
- true, true, tgt_state.at(*tgt_instrs.at(name)),
+ true, true, tgt_state->at(*tgt_instrs.at(name)),
check_each_var);
if (errs)
return errs;
}
}
- check_refinement(errs, t, src_state, tgt_state, nullptr, t.src.getType(),
- src_state.returnDomain()(), src_state.functionDomain()(),
- src_state.returnVal(),
- tgt_state.returnDomain()(), tgt_state.functionDomain()(),
- tgt_state.returnVal(),
+ check_refinement(errs, t, *src_state, *tgt_state, nullptr, t.src.getType(),
+ src_state->returnDomain()(), src_state->functionDomain()(),
+ src_state->returnVal(),
+ tgt_state->returnDomain()(), tgt_state->functionDomain()(),
+ tgt_state->returnVal(),
check_each_var);
} catch (AliveException e) {
return move(e);

MODIFY
tools/transform.h
tools/transform.h
#include "ir/state.h"
#include "smt/solver.h"
#include "util/errors.h"
+#include <memory>
#include <string>
#include <ostream>
#include <unordered_map>
@@ -53,7 +54,7 @@ class TransformVerify {
public:
TransformVerify(Transform &t, bool check_each_var);
- std::pair<IR::State, IR::State> exec() const;
+ std::pair<std::unique_ptr<IR::State>,std::unique_ptr<IR::State>> exec() const;
util::Errors verify() const;
TypingAssignments getTypings() const;
void fixupTypes(const TypingAssignments &ty);

fix crash in some unit tests (regressions due to refactoring for alive-exec)