summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocFast.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-05-17 04:50:57 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-05-17 04:50:57 +0000
commit0c9e4f5f3ff139733d74462a0ad5b94014e764a8 (patch)
treed2a849d95539d272e0419bedb30c622b8f7d4559 /lib/CodeGen/RegAllocFast.cpp
parent646dd7c899ea213301e193a25536a4bceebf7937 (diff)
downloadllvm-0c9e4f5f3ff139733d74462a0ad5b94014e764a8.tar.gz
llvm-0c9e4f5f3ff139733d74462a0ad5b94014e764a8.tar.bz2
llvm-0c9e4f5f3ff139733d74462a0ad5b94014e764a8.tar.xz
Only use clairvoyance when defining a register, and then only if it has one use.
This makes allocation independent on the ordering of use-def chains. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103935 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocFast.cpp')
-rw-r--r--lib/CodeGen/RegAllocFast.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/lib/CodeGen/RegAllocFast.cpp b/lib/CodeGen/RegAllocFast.cpp
index 9449780d82..04aa47e158 100644
--- a/lib/CodeGen/RegAllocFast.cpp
+++ b/lib/CodeGen/RegAllocFast.cpp
@@ -399,20 +399,6 @@ void RAFast::allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint) {
!Allocatable.test(Hint)))
Hint = 0;
- // If there is no hint, peek at the first use of this register.
- if (!Hint && !MRI->use_nodbg_empty(VirtReg)) {
- MachineInstr &MI = *MRI->use_nodbg_begin(VirtReg);
- unsigned SrcReg, DstReg, SrcSubReg, DstSubReg;
- // Copy to physreg -> use physreg as hint.
- if (TII->isMoveInstr(MI, SrcReg, DstReg, SrcSubReg, DstSubReg) &&
- SrcReg == VirtReg && TargetRegisterInfo::isPhysicalRegister(DstReg) &&
- RC->contains(DstReg) && !UsedInInstr.test(DstReg) &&
- Allocatable.test(DstReg)) {
- Hint = DstReg;
- DEBUG(dbgs() << "%reg" << VirtReg << " gets hint from " << MI);
- }
- }
-
// Take hint when possible.
if (Hint) {
assert(RC->contains(Hint) && !UsedInInstr.test(Hint) &&
@@ -543,9 +529,18 @@ RAFast::defineVirtReg(MachineInstr *MI, unsigned OpNum,
bool New;
tie(LRI, New) = LiveVirtRegs.insert(std::make_pair(VirtReg, LiveReg()));
LiveReg &LR = LRI->second;
- if (New)
+ if (New) {
+ // If there is no hint, peek at the only use of this register.
+ if ((!Hint || !TargetRegisterInfo::isPhysicalRegister(Hint)) &&
+ MRI->hasOneNonDBGUse(VirtReg)) {
+ unsigned SrcReg, DstReg, SrcSubReg, DstSubReg;
+ // It's a copy, use the destination register as a hint.
+ if (TII->isMoveInstr(*MRI->use_nodbg_begin(VirtReg),
+ SrcReg, DstReg, SrcSubReg, DstSubReg))
+ Hint = DstReg;
+ }
allocVirtReg(MI, *LRI, Hint);
- else
+ } else
addKillFlag(LR); // Kill before redefine.
assert(LR.PhysReg && "Register not assigned");
LR.LastUse = MI;