Ejemplo n.º 1
0
//------------------------------------------------------------------------------
// Build a vector with all the uses of the given value.
InstVector findUsers(llvm::Value *value) {
  InstVector result;
  for (auto user = value->user_begin(), end = value->user_end(); user != end;
       ++user) {
    if (Instruction *inst = dyn_cast<Instruction>(*user)) {
      result.push_back(inst);
    }
  }
  return result;
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
void applyMap(InstVector &insts, Map &map, InstVector &result) {
  result.clear();
  result.reserve(insts.size());

  for (auto inst : insts) {
    Value *newValue = map[inst];
    if (newValue != nullptr) {
      if (Instruction *newInst = dyn_cast<Instruction>(newValue)) {
        result.push_back(newInst);
      }
    }
  }
}