void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map,
                            const char *Name) const {

  OS << "Map Name: " << Name << "\n";
  OS << "Size: " << Map.size() << "\n";
  for (ValueMapType::const_iterator I = Map.begin(),
         E = Map.end(); I != E; ++I) {

    const Value *V = I->first;
    if (V->hasName())
      OS << "Value: " << V->getName();
    else
      OS << "Value: [null]\n";
    V->dump();

    OS << " Uses(" << std::distance(V->use_begin(),V->use_end()) << "):";
    for (const Use &U : V->uses()) {
      if (&U != &*V->use_begin())
        OS << ",";
      if(U->hasName())
        OS << " " << U->getName();
      else
        OS << " [null]";

    }
    OS <<  "\n\n";
  }
}
Ejemplo n.º 2
0
void
ValueInfoMap::mapValueInformation(ValueToValueMapTy& valueMap)
{
    // We iterate over a map while deleting and inserting elements...
    // Better just create a new map and replace the old one.
    ValueMapType newValueMap;

    for (auto it : mValueMap)
    {
        // Map ValueInfo contents.
        const Value*     value = it.first;
        const ValueInfo* info  = it.second;

        assert (valueMap.count(value));
        const Value* newValue = valueMap[value];

        // Map entry of mValueMap itself.
        newValueMap[newValue] = info;
    }

    mValueMap.clear();
    mValueMap.insert(newValueMap.begin(), newValueMap.end());
}