revert optimization for fncall non-undef args that was crashing
MODIFY
ir/instr.cpp
ir/instr.cpp
@@ -1700,12 +1700,11 @@ void FnCall::print(ostream &os) const {
static void unpack_inputs(State &s, Value &argv, Type &ty,
const ParamAttrs &argflag, StateValue value,
StateValue value2, vector<StateValue> &inputs,
- vector<Memory::PtrInput> &ptr_inputs,
- bool has_two_vals) {
+ vector<Memory::PtrInput> &ptr_inputs) {
if (auto agg = ty.getAsAggregateType()) {
for (unsigned i = 0, e = agg->numElementsConst(); i != e; ++i) {
unpack_inputs(s, argv, agg->getChild(i), argflag, agg->extract(value, i),
- agg->extract(value2, i), inputs, ptr_inputs, has_two_vals);
+ agg->extract(value2, i), inputs, ptr_inputs);
}
return;
}
@@ -1724,7 +1723,6 @@ static void unpack_inputs(State &s, Value &argv, Type &ty,
}
};
unpack(move(value));
- if (has_two_vals)
unpack(move(value2));
}
@@ -1787,11 +1785,10 @@ StateValue FnCall::toSMT(State &s) const {
// we duplicate each argument so that undef values are allowed to take
// different values so we can catch the bug in f(freeze(undef)) -> f(undef)
StateValue sv, sv2;
- bool has_two_vals = true;
if (flags.poisonImpliesUB()) {
sv = s.getAndAddPoisonUB(*arg, flags.undefImpliesUB());
if (flags.undefImpliesUB())
- has_two_vals = false;
+ sv2 = sv;
else
sv2 = s.getAndAddPoisonUB(*arg, false);
} else {
@@ -1800,7 +1797,7 @@ StateValue FnCall::toSMT(State &s) const {
}
unpack_inputs(s, *arg, arg->getType(), flags, move(sv), move(sv2), inputs,
- ptr_inputs, has_two_vals);
+ ptr_inputs);
fnName_mangled << '#' << arg->getType();
}
fnName_mangled << '!' << getType();

MODIFY
ir/memory.h
ir/memory.h
@@ -236,8 +236,6 @@ public:
bool byval;
bool nocapture;
- PtrInput(StateValue &&v, bool byval, bool nocapture) :
- val(std::move(v)), byval(byval), nocapture(nocapture) {}
smt::expr operator==(const PtrInput &rhs) const;
auto operator<=>(const PtrInput &rhs) const = default;
};

MODIFY
ir/state.cpp
ir/state.cpp
@@ -659,6 +659,7 @@ expr State::FnCallInput::refinedBy(
return false;
AndExpr refines;
+ assert(args_nonptr.size() == args_nonptr2.size());
for (unsigned i = 0, e = args_nonptr.size(); i != e; ++i) {
refines.add(args_nonptr[i].non_poison.implies(
args_nonptr[i].value == args_nonptr2[i].value &&
@@ -669,6 +670,7 @@ expr State::FnCallInput::refinedBy(
return false;
set<expr> undef_vars;
+ assert(args_ptr.size() == args_ptr2.size());
for (unsigned i = 0, e = args_ptr.size(); i != e; ++i) {
// TODO: needs to take read/read2 as input to control if mem blocks
// need to be compared

revert optimization for fncall non-undef args that was crashing