diff options
author | Dale Johannesen <dalej@apple.com> | 2008-09-20 02:03:04 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2008-09-20 02:03:04 +0000 |
commit | 34d8f7559cfe3a416c400b863919dbc6e4f347f9 (patch) | |
tree | df3fded100e929eafbdbfd09d50b129602123914 /lib/CodeGen | |
parent | 5e8d9def77b4a68e6be32f21cda28d2a451267a9 (diff) | |
download | llvm-34d8f7559cfe3a416c400b863919dbc6e4f347f9.tar.gz llvm-34d8f7559cfe3a416c400b863919dbc6e4f347f9.tar.bz2 llvm-34d8f7559cfe3a416c400b863919dbc6e4f347f9.tar.xz |
Teach coalescer about earlyclobber bits.
Check bits for preferred register.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56384 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/RegAllocLinearScan.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/SimpleRegisterCoalescing.cpp | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp index df9d393a8f..5a1944fd5f 100644 --- a/lib/CodeGen/RegAllocLinearScan.cpp +++ b/lib/CodeGen/RegAllocLinearScan.cpp @@ -1122,9 +1122,12 @@ unsigned RALinScan::getFreePhysReg(LiveInterval *cur) { unsigned FreeRegInactiveCount = 0; // If copy coalescer has assigned a "preferred" register, check if it's - // available first. + // available first. Coalescer can create new earlyclobber interferences, + // so we need to check that. if (cur->preference) { - if (prt_->isRegAvail(cur->preference) && RC->contains(cur->preference)) { + if (prt_->isRegAvail(cur->preference) && + RC->contains(cur->preference) && + noEarlyClobberConflict(cur, cur->preference)) { DOUT << "\t\tassigned the preferred register: " << tri_->getName(cur->preference) << "\n"; return cur->preference; diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp index 33061890c0..88996575db 100644 --- a/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -1206,6 +1206,14 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) { DOUT << " and "; DstInt.print(DOUT, tri_); DOUT << ": "; + // If one interval is earlyclobber and the other is overlaps-earlyclobber, + // we cannot coalesce them. + if ((SrcInt.isEarlyClobber && DstInt.overlapsEarlyClobber) || + (DstInt.isEarlyClobber && SrcInt.overlapsEarlyClobber)) { + DOUT << "\t\tCannot join due to earlyclobber."; + return false; + } + // Check if it is necessary to propagate "isDead" property. if (!isExtSubReg && !isInsSubReg) { MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg, false); @@ -1366,6 +1374,10 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) { if (TargetRegisterInfo::isVirtualRegister(DstReg)) RemoveUnnecessaryKills(DstReg, *ResDstInt); + // Merge the earlyclobber bits. + ResDstInt->isEarlyClobber |= ResSrcInt->isEarlyClobber; + ResDstInt->overlapsEarlyClobber |= ResSrcInt->overlapsEarlyClobber; + if (isInsSubReg) // Avoid: // r1024 = op |