diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h index e1c5717f5face..f18c177b1c35b 100644 --- a/llvm/include/llvm/CodeGen/LiveInterval.h +++ b/llvm/include/llvm/CodeGen/LiveInterval.h @@ -83,8 +83,16 @@ namespace llvm { /// Mark this value as unused. void markUnused() { def = SlotIndex(); } + + LLVM_ABI void print(raw_ostream &OS) const; + LLVM_ABI void dump() const; }; + inline raw_ostream &operator<<(raw_ostream &OS, const VNInfo &VNI) { + VNI.print(OS); + return OS; + } + /// Result of a LiveRange query. This class hides the implementation details /// of live ranges, and it should be used as the primary interface for /// examining live ranges around instructions. diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp index b682998c329bc..299db85233c2d 100644 --- a/llvm/lib/CodeGen/LiveInterval.cpp +++ b/llvm/lib/CodeGen/LiveInterval.cpp @@ -996,6 +996,17 @@ LLVM_DUMP_METHOD void LiveRange::Segment::dump() const { } #endif +void VNInfo::print(raw_ostream &OS) const { + OS << id << '@'; + if (isUnused()) { + OS << 'x'; + } else { + OS << def; + if (isPHIDef()) + OS << "-phi"; + } +} + void LiveRange::print(raw_ostream &OS) const { if (empty()) OS << "EMPTY"; @@ -1013,15 +1024,10 @@ void LiveRange::print(raw_ostream &OS) const { for (const_vni_iterator i = vni_begin(), e = vni_end(); i != e; ++i, ++vnum) { const VNInfo *vni = *i; - if (vnum) OS << ' '; - OS << vnum << '@'; - if (vni->isUnused()) { - OS << 'x'; - } else { - OS << vni->def; - if (vni->isPHIDef()) - OS << "-phi"; - } + if (vnum) + OS << ' '; + OS << *vni; + assert(vnum == vni->id && "Bad VNInfo"); } } } @@ -1041,9 +1047,9 @@ void LiveInterval::print(raw_ostream &OS) const { } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) -LLVM_DUMP_METHOD void LiveRange::dump() const { - dbgs() << *this << '\n'; -} +LLVM_DUMP_METHOD void VNInfo::dump() const { dbgs() << *this << '\n'; } + +LLVM_DUMP_METHOD void LiveRange::dump() const { dbgs() << *this << '\n'; } LLVM_DUMP_METHOD void LiveInterval::SubRange::dump() const { dbgs() << *this << '\n';