aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/SimpleRegisterCoalescing.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2009-10-27 23:16:58 +0000
committerLang Hames <lhames@gmail.com>2009-10-27 23:16:58 +0000
commit1239c9656bdcc0d86a2a4f89759acd5962e19ff6 (patch)
treebd88cbf34f2df7f2794cfa135cff20e7efd407da /lib/CodeGen/SimpleRegisterCoalescing.cpp
parenta6a99b4e160eea0060b25fbdeadc3437cd67d617 (diff)
downloadexternal_llvm-1239c9656bdcc0d86a2a4f89759acd5962e19ff6.zip
external_llvm-1239c9656bdcc0d86a2a4f89759acd5962e19ff6.tar.gz
external_llvm-1239c9656bdcc0d86a2a4f89759acd5962e19ff6.tar.bz2
Fixed a bug in the coalescer where intervals were occasionally merged despite a real interference. This fixes rdar://problem/7157961.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SimpleRegisterCoalescing.cpp')
-rw-r--r--lib/CodeGen/SimpleRegisterCoalescing.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp
index f8784f6..430df54 100644
--- a/lib/CodeGen/SimpleRegisterCoalescing.cpp
+++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp
@@ -1861,6 +1861,21 @@ bool SimpleRegisterCoalescing::RangeIsDefinedByCopyFromReg(LiveInterval &li,
return false;
}
+
+/// ValueLiveAt - Return true if the LiveRange pointed to by the given
+/// iterator, or any subsequent range with the same value number,
+/// is live at the given point.
+bool SimpleRegisterCoalescing::ValueLiveAt(LiveInterval::iterator LRItr,
+ LiveIndex defPoint) const {
+ for (const VNInfo *valno = LRItr->valno; LRItr->valno == valno; ++LRItr) {
+ if (LRItr->contains(defPoint))
+ return true;
+ }
+
+ return false;
+}
+
+
/// SimpleJoin - Attempt to joint the specified interval into this one. The
/// caller of this method must guarantee that the RHS only contains a single
/// value number and that the RHS is not defined by a copy from this
@@ -1907,7 +1922,7 @@ bool SimpleRegisterCoalescing::SimpleJoin(LiveInterval &LHS, LiveInterval &RHS){
if (!RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg))
return false; // Nope, bail out.
- if (LHSIt->contains(RHSIt->valno->def))
+ if (ValueLiveAt(LHSIt, RHSIt->valno->def))
// Here is an interesting situation:
// BB1:
// vr1025 = copy vr1024
@@ -1945,7 +1960,7 @@ bool SimpleRegisterCoalescing::SimpleJoin(LiveInterval &LHS, LiveInterval &RHS){
// Otherwise, if this is a copy from the RHS, mark it as being merged
// in.
if (RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg)) {
- if (LHSIt->contains(RHSIt->valno->def))
+ if (ValueLiveAt(LHSIt, RHSIt->valno->def))
// Here is an interesting situation:
// BB1:
// vr1025 = copy vr1024