TV: add support for br
MODIFY
ir/state.cpp
ir/state.cpp
@@ -107,8 +107,8 @@ void State::addJump(const BasicBlock &dst) {
void State::addCondJump(const StateValue &cond, const BasicBlock &dst_true,
const BasicBlock &dst_false) {
- addJump(dst_true, cond.value && cond.non_poison);
- addJump(dst_false, !cond.value && cond.non_poison);
+ addJump(dst_true, cond.value == 1 && cond.non_poison);
+ addJump(dst_false, cond.value == 0 && cond.non_poison);
domain = false;
}

MODIFY
tv/tv.cpp
tv/tv.cpp
#include "tools/transform.h"
#include "util/config.h"
#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Operator.h"
#include "llvm/Pass.h"
@@ -208,6 +209,19 @@ unique_ptr<Instr> llvm_instr2alive(const llvm::Instruction &i) {
identifiers.emplace(&i, op.get());
return op;
}
+ case llvm::Instruction::Br:
+ {
+ auto &br = cast<llvm::BranchInst>(i);
+ auto &dst_true = current_fn->getBB(value_name(*br.getSuccessor(0)));
+ if (br.isUnconditional())
+ return make_unique<Branch>(dst_true);
+
+ auto &dst_false = current_fn->getBB(value_name(*br.getSuccessor(1)));
+ auto cond = get_operand(br.getCondition());
+ if (!cond)
+ return nullptr;
+ return make_unique<Branch>(*cond, dst_true, dst_false);
+ }
case llvm::Instruction::Ret:
{
auto ty = llvm_type2alive(i.getType());

TV: add support for br