aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/SimpleRegisterCoalescing.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Disable physical register coalescing by default.Jakob Stoklund Olesen2011-05-041-1/+1
| | | | | | | | | | | | Joining physregs is inherently dangerous because it uses a heuristic to avoid creating invalid code. Linear scan had an emergency spilling mechanism to deal with those rare cases. The new greedy allocator does not. The greedy register allocator is much better at taking hints, so this has almost no impact on code size and quality. The few cases where it matters show up as unit tests that now have -join-physregs enabled explicitly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130896 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename -disable-physical-join to -join-physregs and invert it.Jakob Stoklund Olesen2011-05-041-4/+4
| | | | | | Physreg joining is still on by default, but I will turn it off shortly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130844 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't add live ranges for sub-registers when clobbering a physical register.Jakob Stoklund Olesen2011-04-111-8/+7
| | | | | | | | | Both coalescing and register allocation already check aliases for interference, so these extra segments are only slowing us down. This speeds up both linear scan and the greedy register allocator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129283 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow coalescing with reserved physregs in certain cases:Jakob Stoklund Olesen2011-04-041-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | When a virtual register has a single value that is defined as a copy of a reserved register, permit that copy to be joined. These virtual register are usually copies of the stack pointer: %vreg75<def> = COPY %ESP; GR32:%vreg75 MOV32mr %vreg75, 1, %noreg, 0, %noreg, %vreg74<kill> MOV32mi %vreg75, 1, %noreg, 8, %noreg, 0 MOV32mi %vreg75<kill>, 1, %noreg, 4, %noreg, 0 CALLpcrel32 ... Coalescing these virtual registers early decreases register pressure. Previously, they were coalesced by RALinScan::attemptTrivialCoalescing after register allocation was completed. The lower register pressure causes the mcinst-lowering-cmp0.ll test case to fail because it depends on linear scan spilling a particular register. I am deleting 2008-08-05-SpillerBug.ll because it is counting the number of instructions emitted, and its revision history shows the 'correct' count being edited many times. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128845 91177308-0d34-0410-b5e6-96231b3b80d8
* Extract physreg joining policy to a separate method.Jakob Stoklund Olesen2011-04-041-53/+57
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128844 91177308-0d34-0410-b5e6-96231b3b80d8
* Mark all uses as <undef> when joining a copy.Jakob Stoklund Olesen2011-03-311-3/+15
| | | | | | | | | | | | This way, shrinkToUses() will ignore the instruction that is about to be deleted, and we avoid leaving invalid live ranges that SplitKit doesn't like. Fix a misunderstanding in MachineVerifier about <def,undef> operands. The <undef> flag is valid on def operands where it has the same meaning as <undef> on a use operand. It only applies to sub-register defines which also read the full register. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128642 91177308-0d34-0410-b5e6-96231b3b80d8
* Make physreg coalescing independent on the number of uses of the virtual ↵Jakob Stoklund Olesen2011-03-091-3/+1
| | | | | | | | | | | | | | | | | register. The damage done by physreg coalescing only depends on the number of instructions the extended physreg live range covers. This fixes PR9438. The heuristic is still luck-based, and physreg coalescing really should be disabled completely. We need a register allocator with better hinting support before that is possible. Convert a test to FileCheck and force spilling by inserting an extra call. The previous spilling behavior was dependent on misguided physreg coalescing decisions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127351 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid comparing invalid slot indexes, and assert that it doesn't happen.Jakob Stoklund Olesen2011-03-031-3/+1
| | | | | | | The SlotIndex created by the default construction does not represent a position in the function, and it doesn't make sense to compare it to other indexes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126924 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch to SmallVector in SimpleRegisterCoalescing for a 3.5% speedup on 403.gcc.Cameron Zwarich2011-02-171-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125728 91177308-0d34-0410-b5e6-96231b3b80d8
* Add LiveIntervals::shrinkToUses().Jakob Stoklund Olesen2011-02-081-21/+9
| | | | | | | | After uses of a live range are removed, recompute the live range to only cover the remaining uses. This is necessary after rematerializing the value before some (but not all) uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125058 91177308-0d34-0410-b5e6-96231b3b80d8
* Check that a live range exists before shortening it. This fixes PR8989.Jakob Stoklund Olesen2011-01-201-3/+5
| | | | | | The live range may have been deleted earlier because of rematerialization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123891 91177308-0d34-0410-b5e6-96231b3b80d8
* Add hidden -verify-coalescing to run the machine code verifier before and afterJakob Stoklund Olesen2011-01-201-0/+10
| | | | | | register coalescing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123890 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace TargetRegisterInfo::printReg with a PrintReg class that also works ↵Jakob Stoklund Olesen2011-01-091-8/+4
| | | | | | | | | | without a TRI instance. Print virtual registers numbered from 0 instead of the arbitrary FirstVirtualRegister. The first virtual register is printed as %vreg0. TRI::NoRegister is printed as %noreg. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123107 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove some checks for StrongPHIElim. These checks make it impossible to use anCameron Zwarich2010-12-191-4/+2
| | | | | | | | | | | | alternative register allocator that does not require LiveIntervals by specifying it on the command-line for a target that has StrongPHIElimination enabled by default. These checks are pretty meaningless anyways, since StrongPHIElimination and PHIElimination are never used at the same time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122176 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a comment typo.Bob Wilson2010-12-171-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122016 91177308-0d34-0410-b5e6-96231b3b80d8
* Update LiveDebugVariables during coalescing.Jakob Stoklund Olesen2010-12-021-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120720 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the first half of LiveDebugVariables.Jakob Stoklund Olesen2010-12-021-0/+5
| | | | | | | | | | | | | | | | | | | Scan the MachineFunction for DBG_VALUE instructions, and replace them with a data structure similar to LiveIntervals. The live range of a DBG_VALUE is determined by propagating it down the dominator tree until a new DBG_VALUE is found. When a DBG_VALUE lives in a register, its live range is confined to the live range of the register's value. LiveDebugVariables runs before coalescing, so DBG_VALUEs are not artificially extended when registers are joined. The missing half will recreate DBG_VALUE instructions from the intervals when register allocation is complete. The pass is disabled by default. It can be enabled with the temporary command line option -live-debug-variables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120636 91177308-0d34-0410-b5e6-96231b3b80d8
* Unbreak build.Evan Cheng2010-10-221-10/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117155 91177308-0d34-0410-b5e6-96231b3b80d8
* Transfer implicit ops when forming load multiple and return instructions.Evan Cheng2010-10-221-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117151 91177308-0d34-0410-b5e6-96231b3b80d8
* When SimpleRegisterCoalescing is trimming kill flags on a physical registerJakob Stoklund Olesen2010-10-201-1/+11
| | | | | | | | | | | operand, also check if subregisters are killed. Add <imp-def> operands for subregisters that remain alive after a super register is killed. I don't have a testcase for this that reproduces on trunk. <rdar://problem/8441758> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116940 91177308-0d34-0410-b5e6-96231b3b80d8
* Begin adding static dependence information to passes, which will allow us toOwen Anderson2010-10-121-1/+11
| | | | | | | | | | perform initialization without static constructors AND without explicit initialization by the client. For the moment, passes are required to initialize both their (potential) dependencies and any passes they preserve. I hope to be able to relax the latter requirement in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116334 91177308-0d34-0410-b5e6-96231b3b80d8
* Now with fewer extraneous semicolons!Owen Anderson2010-10-071-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115996 91177308-0d34-0410-b5e6-96231b3b80d8
* Drop the use of LiveInterval::iterator and the LiveRange class inJakob Stoklund Olesen2010-10-011-14/+7
| | | | | | RemoveCopyByCommutingDef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115386 91177308-0d34-0410-b5e6-96231b3b80d8
* When RemoveCopyByCommutingDef is creating additional identity copies, just useJakob Stoklund Olesen2010-10-011-47/+7
| | | | | | | | | | | LiveInterval::MergeValueNumberInto instead of trying to extend LiveRanges and getting it wrong. This fixed PR8249 where a valno with a multi-segment live range was defined by an identity copy created by RemoveCopyByCommutingDef. Some of the live segments disappeared. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115385 91177308-0d34-0410-b5e6-96231b3b80d8
* Pretty up the debug output during RemoveCopyByCommutingDef.Jakob Stoklund Olesen2010-10-011-19/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115384 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed some tests to avoid LiveIntervals::getInstructionFromIndex(..) ↵Lang Hames2010-09-261-5/+5
| | | | | | overhead where possible. Thanks to Jakob for the suggestions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114798 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid using VNInfo::getCopy as much as possible. I want to get rid of it.Jakob Stoklund Olesen2010-09-251-10/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114794 91177308-0d34-0410-b5e6-96231b3b80d8
* Removed VNInfo::isDefAccurate(). Def "accuracy" can be checked by testing ↵Lang Hames2010-09-251-10/+9
| | | | | | whether LiveIntervals::getInstructionFromIndex(def) returns NULL. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114791 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach RemoveCopyByCommutingDef to check all aliases, not just subregisters.Jakob Stoklund Olesen2010-09-011-16/+14
| | | | | | | This caused a miscompilation in WebKit where %RAX had conflicting defs when RemoveCopyByCommutingDef was commuting a %EAX use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112751 91177308-0d34-0410-b5e6-96231b3b80d8
* Add experimental -disable-physical-join command line option.Jakob Stoklund Olesen2010-08-311-0/+10
| | | | | | | | | | Eventually, we want to disable physreg coalescing completely, and let the register allocator do its job using hints. This option makes it possible to measure the impact of disabling physreg coalescing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112567 91177308-0d34-0410-b5e6-96231b3b80d8
* Now that PassInfo and Pass::ID have been separated, move the rest of the ↵Owen Anderson2010-08-231-5/+3
| | | | | | passes over to the new registration API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111815 91177308-0d34-0410-b5e6-96231b3b80d8
* Transpose the calculation of spill weights such that we are calculating oneJakob Stoklund Olesen2010-08-101-4/+1
| | | | | | | | | | | | | | register at a time. This turns out to be slightly faster than iterating over instructions, but more importantly, it allows us to compute spill weights for new registers created after the spill weight pass has run. Also compute the allocation hint at the same time as the spill weight. This allows us to use the spill weight as a cost metric for copies, and choose the most profitable hint if there is more than one possibility. The new hints provide a very small (< 0.1%) but universal code size improvement. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110631 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson2010-08-061-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110460 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r110396 to fix buildbots.Owen Anderson2010-08-061-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110410 91177308-0d34-0410-b5e6-96231b3b80d8
* Be more aggressive about removing joined physreg copies.Jakob Stoklund Olesen2010-08-051-3/+10
| | | | | | | When a joined COPY changes subreg liveness, we keep it around as a KILL, otherwise it is safe to delete. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110403 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use PassInfo* as a type identifier for passes. Instead, use the ↵Owen Anderson2010-08-051-1/+1
| | | | | | | | | address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110396 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove many calls to TII::isMoveInstr. Targets should be producing COPY anyway.Jakob Stoklund Olesen2010-07-161-78/+21
| | | | | | TII::isMoveInstr is going tobe completely removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108507 91177308-0d34-0410-b5e6-96231b3b80d8
* Remat uncoalescable COPY instrsJakob Stoklund Olesen2010-07-091-0/+11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108010 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid creating %physreg:subidx operands in ↵Jakob Stoklund Olesen2010-07-091-1/+4
| | | | | | | | SimpleRegisterCoalescing::RemoveCopyByCommutingDef. This fixes PR7602. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107957 91177308-0d34-0410-b5e6-96231b3b80d8
* Deal with a few remaining spots that assume physical registers have live ↵Jakob Stoklund Olesen2010-07-091-2/+4
| | | | | | | | intervals. This fixes PR7601. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107955 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix broken isCopy handling in TrimLiveIntervalToLastUse.Jakob Stoklund Olesen2010-07-091-3/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107950 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Fix broken isCopy handling in TrimLiveIntervalToLastUse"Jakob Stoklund Olesen2010-07-081-7/+3
| | | | | | This reverts commit 107921. It broke the clang self host. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107926 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix broken isCopy handling in TrimLiveIntervalToLastUseJakob Stoklund Olesen2010-07-081-3/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107921 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert EXTRACT_SUBREG to COPY when emitting machine instrs.Jakob Stoklund Olesen2010-07-081-3/+7
| | | | | | | | | EXTRACT_SUBREG no longer appears as a machine instruction. Use COPY instead. Add isCopy() checks in many places using isMoveInstr() and isExtractSubreg(). The isMoveInstr hook will be removed later. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107879 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove references to INSERT_SUBREG after de-SSA.Jakob Stoklund Olesen2010-07-081-6/+1
| | | | | | | Fix X86InstrInfo::convertToThreeAddressWithLEA to generate COPY instead of INSERT_SUBREG. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107878 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix more places assuming subregisters have live intervalsJakob Stoklund Olesen2010-07-071-1/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107780 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Remove references to INSERT_SUBREG after de-SSA" r107725.Jakob Stoklund Olesen2010-07-071-1/+6
| | | | | | Buildbot breakage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107744 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove references to INSERT_SUBREG after de-SSAJakob Stoklund Olesen2010-07-061-6/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107732 91177308-0d34-0410-b5e6-96231b3b80d8
* One more case assuming that subregs have live ranges.Jakob Stoklund Olesen2010-07-061-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107700 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix buildbot breakage where a def is missing.Jakob Stoklund Olesen2010-07-061-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107698 91177308-0d34-0410-b5e6-96231b3b80d8