summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocGreedy.cpp
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2014-03-27 23:10:04 +0000
committerManman Ren <manman.ren@gmail.com>2014-03-27 23:10:04 +0000
commitd9524d66cd6a69ded63b29bed5413217444b162a (patch)
tree959f0770f6f7ec62fe1d442a3eb676877bb81d66 /lib/CodeGen/RegAllocGreedy.cpp
parent2ea701e67a136b834f059d87e389060d60cba05a (diff)
downloadllvm-d9524d66cd6a69ded63b29bed5413217444b162a.tar.gz
llvm-d9524d66cd6a69ded63b29bed5413217444b162a.tar.bz2
llvm-d9524d66cd6a69ded63b29bed5413217444b162a.tar.xz
Provide a target override for the cost of using a callee-saved register
for the first time. Thanks Andy for the discussion. rdar://16162005 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204979 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocGreedy.cpp')
-rw-r--r--lib/CodeGen/RegAllocGreedy.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/CodeGen/RegAllocGreedy.cpp b/lib/CodeGen/RegAllocGreedy.cpp
index 0eb91ab292..6a623b8200 100644
--- a/lib/CodeGen/RegAllocGreedy.cpp
+++ b/lib/CodeGen/RegAllocGreedy.cpp
@@ -2123,7 +2123,10 @@ unsigned RAGreedy::tryAssignCSRFirstTime(LiveInterval &VirtReg,
unsigned PhysReg,
unsigned &CostPerUseLimit,
SmallVectorImpl<unsigned> &NewVRegs) {
- BlockFrequency CSRCost(CSRFirstTimeCost);
+ // We use the larger one out of the command-line option and the value report
+ // by TRI.
+ BlockFrequency CSRCost(std::max((unsigned)CSRFirstTimeCost,
+ TRI->getCSRFirstUseCost()));
if (getStage(VirtReg) == RS_Spill && VirtReg.isSpillable()) {
// We choose spill over using the CSR for the first time if the spill cost
// is lower than CSRCost.
@@ -2172,7 +2175,8 @@ unsigned RAGreedy::selectOrSplitImpl(LiveInterval &VirtReg,
// When NewVRegs is not empty, we may have made decisions such as evicting
// a virtual register, go with the earlier decisions and use the physical
// register.
- if (CSRFirstTimeCost > 0 && CSRFirstUse && NewVRegs.empty()) {
+ if ((CSRFirstTimeCost || TRI->getCSRFirstUseCost()) &&
+ CSRFirstUse && NewVRegs.empty()) {
unsigned CSRReg = tryAssignCSRFirstTime(VirtReg, Order, PhysReg,
CostPerUseLimit, NewVRegs);
if (CSRReg || !NewVRegs.empty())