If we need to support PHI node for SSA?


#1
let a = 0
for (i, 0, 10) {
  let a = a + 1
  Call(a)
}

After ‘ssa’ convert:

let a1 = 0
for (i, 0, 10) {
  let a2 = a1 + 1
  Call(a2)
}

If we have PHI node:

let a1 = 0
for (i, 0, 10) {
  a3 =PHI(a1, a2)
  let a2 = a3 + 1
  Call(a2)
}

Transform to:

let a3 = 0
for (i, 0, 10) {
  let a2 = a3 + 1
  Call(a2)
  let a3 = a2
}

LetStmt node in codegen_c also assert for SSA form:

std::string CodeGenSourceBase::AllocVarID(const Variable* v) {
    CHECK(!var_idmap_.count(v))
         << "Need input to be in SSA form dup " << v->name_hint;
  std::string key = v->name_hint;
  std::string vid = GetUniqueName(key);
  var_idmap_[v] = vid;
  return vid;
}