From 86fb9fdb2000213d3cd5a082e8501cb8fe974a14 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Sun, 8 Feb 2009 08:24:28 +0000 Subject: [PATCH] Strengthen the previous check. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64076 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 16 +++++++--------- lib/CodeGen/SimpleRegisterCoalescing.cpp | 9 +++++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index f06ca43f2b3..1e8202e5f4b 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -272,17 +272,15 @@ namespace llvm { return I != kills.end() && *I == KillIdx; } - /// isOnlyKill - Return true if the specified index is the only kill of the - /// specified val#. - static bool isOnlyKill(const VNInfo *VNI, unsigned KillIdx) { - bool Found = false; - const SmallVector &kills = VNI->kills; - for (unsigned i = 0, e = kills.size(); i != e; ++i) { - if (KillIdx != kills[i]) + /// isOnlyLROfValNo - Return true if the specified live range is the only + /// one defined by the its val#. + bool isOnlyLROfValNo( const LiveRange *LR) { + for (const_iterator I = begin(), E = end(); I != E; ++I) { + const LiveRange *Tmp = I; + if (Tmp != LR && Tmp->valno == LR->valno) return false; - Found = true; } - return Found; + return true; } /// MergeValueNumberInto - This method is called when two value nubmers diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp index a7d5d0075d2..db7109e7a63 100644 --- a/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -489,7 +489,7 @@ static void removeRange(LiveInterval &li, unsigned Start, unsigned End, } /// TrimLiveIntervalToLastUse - If there is a last use in the same basic block -/// as the copy instruction, trim the ive interval to the last use and return +/// as the copy instruction, trim the live interval to the last use and return /// true. bool SimpleRegisterCoalescing::TrimLiveIntervalToLastUse(unsigned CopyIdx, @@ -867,9 +867,10 @@ SimpleRegisterCoalescing::ShortenDeadCopySrcLiveRange(LiveInterval &li, if (LR->valno->def == RemoveStart) { // If the def MI defines the val# and this copy is the only kill of the // val#, then propagate the dead marker. - if (!li.isOnlyKill(LR->valno, RemoveEnd)) - li.removeKill(LR->valno, RemoveEnd); - else { + if (!li.isOnlyLROfValNo(LR)) { + if (li.isKill(LR->valno, RemoveEnd)) + li.removeKill(LR->valno, RemoveEnd); + } else { PropagateDeadness(li, CopyMI, RemoveStart, li_, tri_); ++numDeadValNo; }