summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/RegisterScavenging.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Additional check for regno==0Jim Grosbach2009-09-291-1/+1
| | | | llvm-svn: 83103
* Moving register scavenging to a post pass results in virtual registers inJim Grosbach2009-09-291-2/+3
| | | | | | | the instruction we're scavenging for. The scavenger needs to know to avoid them when analyzing register usage. llvm-svn: 83077
* Fix PR5024 with a big hammer: disable the double-def assertion in the scavenger.Evan Cheng2009-09-241-39/+4
| | | | | | | | | | | | | | | | | | | | | | LiveVariables add implicit kills to correctly track partial register kills. This works well enough and is fairly accurate. But coalescer can make it impossible to maintain these markers. e.g. BL <ga:sss1>, %R0<kill,undef>, %S0<kill>, %R0<imp-def>, %R1<imp-def,dead>, %R2<imp-def,dead>, %R3<imp-def,dead>, %R12<imp-def,dead>, %LR<imp-def,dead>, %D0<imp-def>, ... ... %reg1031<def> = FLDS <cp#1>, 0, 14, %reg0, Mem:LD4[ConstantPool] ... %S0<def> = FCPYS %reg1031<kill>, 14, %reg0, %D0<imp-use,kill> When reg1031 and S0 are coalesced, the copy (FCPYS) will be eliminated the the implicit-kill of D0 is lost. In this case it's possible to move the marker to the FLDS. But in many cases, this is not possible. Suppose %reg1031<def> = FOO <cp#1>, %D0<imp-def> ... %S0<def> = FCPYS %reg1031<kill>, 14, %reg0, %D0<imp-use,kill> When FCPYS goes away, the definition of S0 is the "FOO" instruction. However, transferring the D0 implicit-kill to FOO doesn't work since it is the def of D0 itself. We need to fix this in another time by introducing a "kill" pseudo instruction to track liveness. Disabling the assertion is not ideal, but machine verifier is doing that job now. It's important to know double-def is not a miscomputation since it means a register should be free but it's not tracked as free. It's a performance issue instead. llvm-svn: 82677
* Simplify RegScavenger::FindUnusedReg.Jakob Stoklund Olesen2009-08-181-30/+6
| | | | | | | | | - Drop the Candidates argument and fix all callers. Now that RegScavenger tracks available registers accurately, there is no need to restict the search. - Make sure that no aliases of the found register are in use. This was a potential bug. llvm-svn: 79369
* Replace RegScavenger::DistanceMap with a simpler local algorithm.Jakob Stoklund Olesen2009-08-161-68/+47
| | | | llvm-svn: 79195
* Clean up the public interface of RegScavenger.Jakob Stoklund Olesen2009-08-161-19/+0
| | | | | | Remove unused methods and make others private. llvm-svn: 79194
* Refine EarlyClobber assert in register scavenger.Jakob Stoklund Olesen2009-08-151-1/+1
| | | | | | | | | | | | | | It is legal for an inline asm operand to use an earlyclobber register if the use operand is tied to the earlyclobber operand. The issue is discussed here: http://gcc.gnu.org/ml/gcc/1999-04n/msg00431.html We should perhaps let only the machine code verifier worry about these finer details. EarlyClobber operands are not really interesting to the scavenger. This fixes PR4528 for the third time. llvm-svn: 79122
* Track pristine registers as if they were live-in in the register scavenger.Jakob Stoklund Olesen2009-08-131-14/+12
| | | | llvm-svn: 78913
* Rebuild RegScavenger::DistanceMap each time it is needed.Jakob Stoklund Olesen2009-08-111-23/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The register scavenger maintains a DistanceMap that maps MI pointers to their distance from the top of the current MBB. The DistanceMap is built incrementally in forward() and in bulk in findFirstUse(). It is used by scavengeRegister() to determine which candidate register has the longest unused interval. Unfortunately the DistanceMap contents can become outdated. The first time scavengeRegister() is called, the DistanceMap is filled to cover the MBB. If then instructions are inserted in the MBB (as they always are following scavengeRegister()), the recorded distances are too short. This causes bad behaviour in the included test case where a register use /after/ the current position is ignored because findFirstUse() thinks is is /before/ the current position. A "using an undefined register" assertion follows promptly. The fix is to build a fresh DistanceMap at the top of scavengeRegister(), and discard it after use. This means that DistanceMap is no longer needed as a RegScavenger member variable, and forward() doesn't need to update it. The fix then discloses issue number two in the same test case: The candidate search in scavengeRegister() finds a CSR that has been saved in the prologue, but is currently unused. It would be both inefficient and wrong to spill such a register in the emergency spill slot. In the present case, the emergency slot restore is placed immediately before the normal epilogue restore, leading to a "Redefining a live register" assertion. Fix number two: When scavengerRegister() stumbles upon an unused register that is overwritten later in the MBB, return that register early. It is important to verify that the register is defined later in the MBB, otherwise it might be an unspilled CSR. llvm-svn: 78650
* Remove RegisterScavenger::isSuperRegUsed(). This completely reverses the ↵Jakob Stoklund Olesen2009-08-081-32/+2
| | | | | | | | | | | | | | | mistaken commit r77904. Now there is no special treatment of instructions that redefine part of a super-register. Instead, the super-register is marked with <imp-use,kill> and <imp-def>. For instance, from LowerSubregs on ARM: subreg: CONVERTING: %Q1<def> = INSERT_SUBREG %Q1<undef>, %D1<kill>, 5 subreg: %D2<def> = FCPYD %D1<kill>, 14, %reg0, %Q1<imp-def> subreg: CONVERTING: %Q1<def> = INSERT_SUBREG %Q1, %D0<kill>, 6 subreg: %D3<def> = FCPYD %D0<kill>, 14, %reg0, %Q1<imp-use,kill>, %Q1<imp-def> llvm-svn: 78466
* Simplify RegScavenger::forward a bit more.Jakob Stoklund Olesen2009-08-081-65/+53
| | | | | | | | | | | Verify that early clobber registers and their aliases are not used. All changes to RegsAvailable are now done as a transaction so the order of operands makes no difference. The included test case is from PR4686. It has behaviour that was dependent on the order of operands. llvm-svn: 78465
* Back out some of recent register scavenger change by John Mosby. It broke a ↵Evan Cheng2009-08-071-27/+14
| | | | | | number of ARM tests. llvm-svn: 78421
* Get rid of RegScavenger::backwards() before the bitrot spreads.Jakob Stoklund Olesen2009-08-061-64/+0
| | | | | | If we need it one day, there is nothing wrong with putting it back in. llvm-svn: 78337
* Reg Scavenging generalization (Thumb support):John Mosby2009-08-061-27/+52
| | | | | | | - start support for new PEI w/reg alloc, allow running RS from emit{Pro,Epi}logue() target hooks. - fix minor issue with recursion detection. llvm-svn: 78318
* Clean up the handling of two-address operands in RegScavenger.Jakob Stoklund Olesen2009-08-041-12/+3
| | | | | | This fixes PR4528. llvm-svn: 78107
* Don't give implicit machine operands special treatment in the register ↵Jakob Stoklund Olesen2009-08-041-5/+2
| | | | | | | | | scavenger. Imp-def is *not* allowed to redefine a live register. Imp-use is *not* allowed to use a dead register. llvm-svn: 78106
* Fix PR4528. This scavenger assertion is too strict. The two-address value isEvan Cheng2009-08-041-1/+2
| | | | | | | | | killed by another operand. There is probably a better fix. Either 1) scavenger can look at other operands, or 2) livevariables can be smarter about kill markers. Patches welcome. llvm-svn: 78072
* Fix issue in regscavenger when scavenging a callee-saved register that has ↵Jakob Stoklund Olesen2009-08-021-1/+8
| | | | | | not been spilled. llvm-svn: 77912
* Scavenger asserts.Jakob Stoklund Olesen2009-08-021-2/+11
| | | | | | | Allow imp-def and imp-use of anything in the scavenger asserts, just like the machine code verifier. Allow redefinition of a sub-register of a live register. llvm-svn: 77904
* Ignore undef uses.Evan Cheng2009-07-221-0/+3
| | | | llvm-svn: 76799
* Fix bug in RegScavenger::scavengeRegister().Jakob Stoklund Olesen2009-07-151-1/+1
| | | | | | | | | | | | | Reserved registers are not candidates for scavenging, and they were removed from the candidate list like this: CreateRegClassMask(RC, Candidates); Candidates ^= ReservedRegs; However, when there are reserved registers outside RC, this causes invalid bits to be set in Candidates. llvm-svn: 75847
* Fix assert(0) conversion, as suggested by Chris.Torok Edwin2009-07-121-3/+2
| | | | llvm-svn: 75423
* Convert more assert(0)+abort() -> LLVM_UNREACHABLE,Torok Edwin2009-07-111-2/+2
| | | | | | and abort()/exit() -> llvm_report_error(). llvm-svn: 75363
* Remove special handling of implicit_def. Fix a couple more bugs in ↵Evan Cheng2009-07-011-22/+9
| | | | | | | | liveintervalanalysis and coalescer handling of implicit_def. Note, isUndef marker must be placed even on implicit_def def operand or else the scavenger will not ignore it. This is necessary because -O0 path does not use liveintervalanalysis, it treats implicit_def just like any other def. llvm-svn: 74601
* Handle IMPLICIT_DEF with isUndef operand marker, part 2. This patch moves ↵Evan Cheng2009-07-011-1/+7
| | | | | | the code to annotate machineoperands to LiveIntervalAnalysis. It also add markers for implicit_def that define physical registers. The rest, is just a lot of details. llvm-svn: 74580
* Temporarily restore the scavenger implicit_def checking code. MachineOperand ↵Evan Cheng2009-06-301-5/+23
| | | | | | isUndef mark is not being put on implicit_def of physical registers (created for parameter passing, etc.). llvm-svn: 74519
* Add a bit IsUndef to MachineOperand. This indicates the def / use register ↵Evan Cheng2009-06-301-26/+8
| | | | | | | | | | operand is defined by an implicit_def. That means it can def / use any register and passes (e.g. register scavenger) can feel free to ignore them. The register allocator, when it allocates a register to a virtual register defined by an implicit_def, can allocate any physical register without worrying about overlapping live ranges. It should mark all of operands of the said virtual register so later passes will do the right thing. This is not the best solution. But it should be a lot less fragile to having the scavenger try to track what is defined by implicit_def. llvm-svn: 74518
* If killed register is defined by implicit_def, do not clear it since it's ↵Evan Cheng2009-06-121-5/+12
| | | | | | live range may overlap another def of same register. llvm-svn: 73255
* Fix pr3954. The register scavenger asserts for inline assembly withBob Wilson2009-04-091-4/+2
| | | | | | | | | | | | register destinations that are tied to source operands. The TargetInstrDescr::findTiedToSrcOperand method silently fails for inline assembly. The existing MachineInstr::isRegReDefinedByTwoAddr was very close to doing what is needed, so this revision makes a few changes to that method and also renames it to isRegTiedToUseOperand (for consistency with the very similar isRegTiedToDefOperand and because it handles both two-address instructions and inline assembly with tied registers). llvm-svn: 68714
* Tidy up #includes, deleting a bunch of unnecessary #includes.Dan Gohman2009-01-051-0/+1
| | | | llvm-svn: 61715
* Silience unused warnings.Devang Patel2008-12-231-0/+2
| | | | llvm-svn: 61390
* Initialize the ImplicitDefed member, to avoid getting staleDan Gohman2008-12-191-0/+1
| | | | | | data from a previous block. llvm-svn: 61237
* Fix a typo in a comment.Dan Gohman2008-12-021-1/+1
| | | | llvm-svn: 60434
* - Register scavenger should use MachineRegisterInfo and internal map to find ↵Evan Cheng2008-11-201-32/+62
| | | | | | | | | the first use of a register after a given machine instruction. - When scavenging a register, in addition to the spill, insert a restore before the first use. - Abort if client is looking to scavenge a register even when a previously scavenged register is still live. llvm-svn: 59697
* Make the same change to RegScavenger::backward.Evan Cheng2008-11-181-9/+28
| | | | llvm-svn: 59566
* We also need to keep the operand index for two address check.Evan Cheng2008-11-181-9/+11
| | | | llvm-svn: 59562
* Register scavenger should process early clobber defs first. A dead early ↵Evan Cheng2008-11-181-23/+37
| | | | | | clobber def should not interfere with a normal def which happens one slot later. llvm-svn: 59559
* Switch the MachineOperand accessors back to the short names likeDan Gohman2008-10-031-7/+7
| | | | | | isReg, etc., from isRegister, etc. llvm-svn: 57006
* Minor const-correctness fixes.Dan Gohman2008-07-071-1/+1
| | | | llvm-svn: 53196
* Fix some constructs that gcc-4.4 warns about.Duncan Sands2008-05-271-1/+2
| | | | llvm-svn: 51591
* Allow registers defined by implicit_def to be clobbered.Evan Cheng2008-04-101-6/+15
| | | | llvm-svn: 49512
* 1. IMPLICIT_DEF can *re-define* any register.Evan Cheng2008-04-051-2/+42
| | | | | | | 2. Coalescer can now create an interesting situation where a register def can reaches itself without being killed. llvm-svn: 49246
* Something that kills a super-register alsoBill Wendling2008-03-071-2/+1
| | | | | | kills the sub-register. llvm-svn: 48038
* Fixed a register scavenger bug. If a def is re-defining part of a super ↵Evan Cheng2008-03-071-3/+8
| | | | | | register, there must be an implicit def of the super-register on the MI. llvm-svn: 48024
* When setting the "unused" info, take into account something like this:Bill Wendling2008-03-061-8/+38
| | | | | | | | %r3<def> = OR %x3<kill>, %x3 We don't want to mark the %r3 as unused even though it's a sub-register of %x3. llvm-svn: 48003
* Refactor code. Remove duplicated functions that basically do the same thing asEvan Cheng2008-03-051-15/+16
| | | | | | findRegisterUseOperandIdx, findRegisterDefOperandIndx. Fix some naming inconsistencies. llvm-svn: 47927
* Make the register scavenger update the bookkeeping values for sub/superBill Wendling2008-03-031-3/+39
| | | | | | registers. llvm-svn: 47861
* Fix typos.Bill Wendling2008-02-161-2/+2
| | | | llvm-svn: 47200
* Rename MRegisterInfo to TargetRegisterInfo.Dan Gohman2008-02-101-1/+1
| | | | llvm-svn: 46930
* rename TargetInstrDescriptor -> TargetInstrDesc.Chris Lattner2008-01-071-5/+5
| | | | | | | Make MachineInstr::getDesc return a reference instead of a pointer, since it can never be null. llvm-svn: 45695
OpenPOWER on IntegriCloud