remove unreachable instruction (replaced with assume false)
MODIFY
ir/instr.cpp
ir/instr.cpp
@@ -584,18 +584,4 @@ expr Assume::getTypeConstraints(const Function &f) const {
return cond.getType().enforceIntType();
}
-
-void Unreachable::print(ostream &os) const {
- os << "unreachable";
-}
-
-StateValue Unreachable::toSMT(State &s) const {
- s.addUB(false);
- return {};
-}
-
-expr Unreachable::getTypeConstraints(const Function &f) const {
- return true;
-}
-
}

MODIFY
ir/instr.h
ir/instr.h
@@ -190,14 +190,4 @@ public:
smt::expr getTypeConstraints(const Function &f) const override;
};
-
-class Unreachable final : public Instr {
-public:
- Unreachable() : Instr(Type::voidTy, "") {}
-
- void print(std::ostream &os) const override;
- StateValue toSMT(State &s) const override;
- smt::expr getTypeConstraints(const Function &f) const override;
-};
-
}

MODIFY
tools/alive_parser.cpp
tools/alive_parser.cpp
@@ -595,7 +595,8 @@ static void parse_fn(Function &f) {
break;
}
case UNREACH:
- bb->addInstr(make_unique<Unreachable>());
+ bb->addInstr(make_unique<Assume>(get_constant(0, *int_types[1].get()),
+ /*if_non_poison=*/false));
break;
default:
tokenizer.unget(t);

MODIFY
tv/tv.cpp
tv/tv.cpp
@@ -259,7 +259,8 @@ public:
}
RetTy visitUnreachableInst(llvm::UnreachableInst &i) {
- return make_unique<Unreachable>();
+ return make_unique<Assume>(get_operand(llvm::ConstantInt::getFalse()),
+ /*if_non_poison=*/false);
}
RetTy visitIntrinsicInst(llvm::IntrinsicInst &i) {

remove unreachable instruction (replaced with assume false)