diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h --- a/llvm/include/llvm/CodeGen/LiveInterval.h +++ b/llvm/include/llvm/CodeGen/LiveInterval.h @@ -81,6 +81,17 @@ /// Mark this value as unused. void markUnused() { def = SlotIndex(); } + + void print(raw_ostream &O) const { + O << id << '@'; + if (isUnused()) { + O << 'x'; + } else { + O << def; + if (isPHIDef()) + O << "-phi"; + } + } }; /// Result of a LiveRange query. This class hides the implementation details diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp --- a/llvm/lib/CodeGen/LiveInterval.cpp +++ b/llvm/lib/CodeGen/LiveInterval.cpp @@ -1025,14 +1025,7 @@ ++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"; - } + vni->print(OS); } } } diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp --- a/llvm/lib/CodeGen/RegisterCoalescer.cpp +++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp @@ -2326,6 +2326,26 @@ Val() = default; bool isAnalyzed() const { return WriteLanes.any(); } + + void print(raw_ostream &O) const { + O << " Write:" << PrintLaneMask(WriteLanes) + << " Valid:" << PrintLaneMask(ValidLanes) << ' '; + switch(Resolution) { + case CR_Unresolved: O << "Unresolved"; return; + case CR_Impossible: O << "Impossible"; return; + case CR_Keep: O << "Keep"; break; + case CR_Replace: O << "Replace"; break; + case CR_Merge: O << "Merge"; break; + case CR_Erase: O << "Erase"; + if (Identical) O << " Identical"; + break; + } + if (OtherVNI) O << " Other:", OtherVNI->print(O); + if (RedefVNI) O << " Redef:", RedefVNI->print(O); + if (ErasableImplicitDef) O << " ImpDef"; + if (Pruned || PrunedComputed) O << ' ' << (Pruned ? "Pruned" : "NonPruned"); + if (PrunedComputed) O << 'C'; + } }; /// One entry per value number in LI. @@ -2442,6 +2462,26 @@ ConflictResolution getResolution(unsigned Num) const { return Vals[Num].Resolution; } + + void print(raw_ostream &O) const { + O << printReg(Register(Reg), TRI, SubIdx); + if (SubRangeJoin) O << ':' << PrintLaneMask(LaneMask); + O << ": "; + for (unsigned ValNo = 0, E = Vals.size(); ValNo < E; ++ValNo) { + if (ValNo > 0) O << ", "; + auto *VNI = LR.getValNumInfo(ValNo); + VNI->print(O); + Vals[ValNo].print(O); + if (Assignments[ValNo] != -1) { + O << " -> "; + NewVNInfo[Assignments[ValNo]]->print(O); + } + } + } + + LLVM_DUMP_METHOD void dump() const { + print(dbgs()); + } }; } // end anonymous namespace @@ -3291,6 +3331,9 @@ llvm_unreachable("*** Couldn't join subrange!\n"); } + LLVM_DEBUG(dbgs() << "\t\tRHSVals "; RHSVals.dump(); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "\t\tLHSVals "; LHSVals.dump(); dbgs() << '\n'); + // The merging algorithm in LiveInterval::join() can't handle conflicting // value mappings, so we need to remove any live ranges that overlap a // CR_Replace resolution. Collect a set of end points that can be used to @@ -3383,6 +3426,9 @@ if (!LHSVals.resolveConflicts(RHSVals) || !RHSVals.resolveConflicts(LHSVals)) return false; + LLVM_DEBUG(dbgs() << "\t\tRHSVals "; RHSVals.dump(); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "\t\tLHSVals "; LHSVals.dump(); dbgs() << '\n'); + // All clear, the live ranges can be merged. if (RHS.hasSubRanges() || LHS.hasSubRanges()) { BumpPtrAllocator &Allocator = LIS->getVNInfoAllocator();