summaryrefslogtreecommitdiffstats
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
commitcd3939ef0ed644caea98e19ff16ede325fd61149 (patch)
tree0860c7022fdc456d1ab074b04a99d37fc4b0e3ee
parentef8b8ce2074bd868bf338e297f6feacca8f2bb1f (diff)
downloadbcm5719-llvm-cd3939ef0ed644caea98e19ff16ede325fd61149.tar.gz
bcm5719-llvm-cd3939ef0ed644caea98e19ff16ede325fd61149.zip
Fixed a bug in the coalescer where intervals were occasionally merged despite a real interference. This fixes rdar://problem/7157961.
llvm-svn: 85338
-rw-r--r--llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp19
-rw-r--r--llvm/lib/CodeGen/SimpleRegisterCoalescing.h5
2 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp b/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
index f8784f60f5e..430df54081e 100644
--- a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
+++ b/llvm/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
diff --git a/llvm/lib/CodeGen/SimpleRegisterCoalescing.h b/llvm/lib/CodeGen/SimpleRegisterCoalescing.h
index 3ebe3a1f7de..a381ae78afe 100644
--- a/llvm/lib/CodeGen/SimpleRegisterCoalescing.h
+++ b/llvm/lib/CodeGen/SimpleRegisterCoalescing.h
@@ -201,6 +201,11 @@ namespace llvm {
bool CanJoinInsertSubRegToPhysReg(unsigned DstReg, unsigned SrcReg,
unsigned SubIdx, unsigned &RealDstReg);
+ /// 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 ValueLiveAt(LiveInterval::iterator LRItr, LiveIndex defPoint) const;
+
/// RangeIsDefinedByCopyFromReg - Return true if the specified live range of
/// the specified live interval is defined by a copy from the specified
/// register.
OpenPOWER on IntegriCloud