do type checking in opt plugin & alive-tv so we skip unsupported vector ops
MODIFY
ir/instr.cpp
ir/instr.cpp
@@ -750,7 +750,7 @@ expr ConversionOp::getTypeConstraints(const Function &f) const {
break;
case BitCast:
// FIXME: input can only be ptr if result is a ptr as well
- c = getType().enforceIntType() &&
+ c = (getType().enforceIntOrPtrType() || getType().enforceFloatType()) &&
getType().sizeVar() == val->getType().sizeVar();
break;
case SIntToFP:
@@ -1350,6 +1350,8 @@ StateValue Branch::toSMT(State &s) const {
}
expr Branch::getTypeConstraints(const Function &f) const {
+ if (!cond)
+ return true;
return cond->getType().enforceIntType(1);
}

MODIFY
ir/type.cpp
ir/type.cpp
@@ -475,6 +475,10 @@ expr PtrType::getTypeConstraints() const {
return sizeVar() == bits();
}
+expr PtrType::sizeVar() const {
+ return defined ? expr::mkUInt(bits(), var_bw_bits) : Type::sizeVar();
+}
+
expr PtrType::operator==(const PtrType &rhs) const {
return sizeVar() == rhs.sizeVar() &&
ASVar() == rhs.ASVar();

MODIFY
ir/type.h
ir/type.h
@@ -197,6 +197,7 @@ public:
unsigned bits() const override;
IR::StateValue getDummyValue(bool non_poison) const override;
smt::expr getTypeConstraints() const override;
+ smt::expr sizeVar() const override;
smt::expr operator==(const PtrType &rhs) const;
smt::expr sameType(const PtrType &rhs) const;
void fixup(const smt::Model &m) override;

MODIFY
llvm_util/utils.cpp
llvm_util/utils.cpp
@@ -234,6 +234,17 @@ Value* get_operand(llvm::Value *v) {
return ret;
}
+ if (auto cnst = dyn_cast<llvm::ConstantDataSequential>(v)) {
+ vector<Value*> vals;
+ for (unsigned i = 0, e = cnst->getNumElements(); i != e; ++i) {
+ vals.emplace_back(get_operand(cnst->getElementAsConstant(i)));
+ }
+ auto val = make_unique<AggregateConst>(*ty, move(vals));
+ auto ret = val.get();
+ current_fn->addConstant(move(val));
+ return ret;
+ }
+
if (auto cnst = dyn_cast<llvm::ConstantAggregateZero>(v)) {
vector<Value*> vals;
for (unsigned i = 0, e = cnst->getNumElements(); i != e; ++i) {

MODIFY
tools/alive-tv.cpp
tools/alive-tv.cpp
@@ -251,6 +251,16 @@ int main(int argc, char **argv) {
TransformVerify verifier(t, false);
t.print(cout, print_opts);
+ {
+ auto types = verifier.getTypings();
+ if (!types) {
+ cerr << "Transformation doesn't verify!\n"
+ "ERROR: progrm doesn't type check!\n\n";
+ return false;
+ }
+ assert(types.hasSingleTyping());
+ }
+
Errors errs = verifier.verify();
bool result(errs);
if (result) {

MODIFY
tools/transform.h
tools/transform.h
@@ -38,6 +38,7 @@ public:
bool operator!() const { return !(bool)*this; }
operator bool() const;
void operator++(void);
+ bool hasSingleTyping() const { return has_only_one_solution; }
friend class TransformVerify;
};

MODIFY
tv/tv.cpp
tv/tv.cpp
@@ -124,6 +124,16 @@ struct TVPass : public llvm::FunctionPass {
TransformVerify verifier(t, false);
t.print(*out, print_opts);
+ {
+ auto types = verifier.getTypings();
+ if (!types) {
+ *out << "Transformation doesn't verify!\n"
+ "ERROR: progrm doesn't type check!\n\n";
+ return false;
+ }
+ assert(types.hasSingleTyping());
+ }
+
if (Errors errs = verifier.verify()) {
*out << "Transformation doesn't verify!\n" << errs << endl;
if (opt_error_fatal && errs.isUnsound()) {

do type checking in opt plugin & alive-tv so we skip unsupported vector ops