From 8c0f69315031d89080caf2c487bab08936e50b34 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 6 Aug 2010 18:46:59 +0000 Subject: Add LiveInterval::RenumberValues - Garbage collection for VNInfos. After heavy editing of a live interval, it is much easier to simply renumber the live values instead of trying to keep track of the unused ones. llvm-svn: 110463 --- llvm/lib/CodeGen/LiveInterval.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'llvm/lib/CodeGen/LiveInterval.cpp') diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp index 14b10d18256..f4c06b203cb 100644 --- a/llvm/lib/CodeGen/LiveInterval.cpp +++ b/llvm/lib/CodeGen/LiveInterval.cpp @@ -180,6 +180,21 @@ void LiveInterval::markValNoForDeletion(VNInfo *ValNo) { } } +/// RenumberValues - Renumber all values in order of appearance and delete the +/// remaining unused values. +void LiveInterval::RenumberValues() { + SmallPtrSet Seen; + valnos.clear(); + for (const_iterator I = begin(), E = end(); I != E; ++I) { + VNInfo *VNI = I->valno; + if (!Seen.insert(VNI)) + continue; + assert(!VNI->isUnused() && "Unused valno used by live range"); + VNI->id = (unsigned)valnos.size(); + valnos.push_back(VNI); + } +} + /// extendIntervalEndTo - This method is used when we want to extend the range /// specified by I to end at the specified endpoint. To do this, we should /// merge and eliminate all ranges that this will overlap with. The iterator is -- cgit v1.2.3