summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-03-09 00:59:48 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-03-09 00:59:48 +0000
commit1d9eb4667dad56d624649d3fd1635f157efe7d4d (patch)
tree09c037ae4acdf9a07586b159f4bea951e2602ff7 /llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
parent408dcf60aaa1dee9eff0b8beded11ae2a6feec2f (diff)
downloadbcm5719-llvm-1d9eb4667dad56d624649d3fd1635f157efe7d4d.tar.gz
bcm5719-llvm-1d9eb4667dad56d624649d3fd1635f157efe7d4d.zip
Disable physical register coalescing when the number of live ranges for the
physreg becomes ridiculously high. std::upper_bound may be log(N), but for sufficiently large live intervals, it becomes log(N)*cachemiss = a long long time. This patch improves coalescer time by 4500x for a function with 20000 function calls. The generated code is different, but not significantly worse - the allocator hints are almost as good as physreg coalescing anyway. llvm-svn: 98023
Diffstat (limited to 'llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp')
-rw-r--r--llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp b/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
index ce72b2fc148..d25df1d2ad8 100644
--- a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
+++ b/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
@@ -1671,8 +1671,20 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
// density, do not join them, instead mark the physical register as its
// allocation preference.
LiveInterval &JoinVInt = SrcIsPhys ? DstInt : SrcInt;
+ LiveInterval &JoinPInt = SrcIsPhys ? SrcInt : DstInt;
unsigned JoinVReg = SrcIsPhys ? DstReg : SrcReg;
unsigned JoinPReg = SrcIsPhys ? SrcReg : DstReg;
+
+ // Don't join with physregs that have a ridiculous number of live
+ // ranges. The data structure performance is really bad when that
+ // happens.
+ if (JoinPInt.ranges.size() > 1000) {
+ mri_->setRegAllocationHint(JoinVInt.reg, 0, JoinPReg);
+ ++numAborts;
+ DEBUG(dbgs() << "\tPhysical register too complicated, abort!\n");
+ return false;
+ }
+
const TargetRegisterClass *RC = mri_->getRegClass(JoinVReg);
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
unsigned Length = li_->getApproximateInstructionCount(JoinVInt);
OpenPOWER on IntegriCloud