From 2079aa914062f0ff151e22dcbc28b4c8367e934a Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 10 Dec 2014 01:12:40 +0000 Subject: LiveInterval: Add removeEmptySubRanges(). llvm-svn: 223887 --- llvm/lib/CodeGen/LiveInterval.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'llvm/lib/CodeGen/LiveInterval.cpp') diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp index 5162579adf1..5d1b99400b7 100644 --- a/llvm/lib/CodeGen/LiveInterval.cpp +++ b/llvm/lib/CodeGen/LiveInterval.cpp @@ -592,6 +592,23 @@ VNInfo *LiveRange::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) { return V2; } +void LiveInterval::removeEmptySubRanges() { + SubRange **NextPtr = &SubRanges; + SubRange *I = *NextPtr; + while (I != nullptr) { + if (!I->empty()) { + NextPtr = &I->Next; + I = *NextPtr; + continue; + } + // Skip empty subranges until we find the first nonempty one. + do { + I = I->Next; + } while (I != nullptr && I->empty()); + *NextPtr = I; + } +} + unsigned LiveInterval::getSize() const { unsigned Sum = 0; for (const_iterator I = begin(), E = end(); I != E; ++I) -- cgit v1.2.3