summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge SimpleRegisterCoalescing.cpp into RegisterCoalescer.cpp.Rafael Espindola2011-06-261-1538/+0
| | | | llvm-svn: 133897
* merge SimpleRegisterCoalescing.h into RegisterCoalescer.h.Rafael Espindola2011-06-261-1/+1
| | | | llvm-svn: 133896
* Move RegisterCoalescer.h to lib/CodeGen.Rafael Espindola2011-06-261-1/+1
| | | | llvm-svn: 133895
* Remove unnecessary wrapper.Rafael Espindola2011-06-261-16/+15
| | | | llvm-svn: 133886
* Add a RegisterClassInfo class that lazily caches information aboutJakob Stoklund Olesen2011-06-021-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | register classes. It provides information for each register class that cannot be determined statically, like: - The number of allocatable registers in a class after filtering out the reserved and invalid registers. - The preferred allocation order with registers that overlap callee-saved registers last. - The last callee-saved register that overlaps a given physical register. This information usually doesn't change between functions, so it is reused for compiling multiple functions when possible. The many possible combinations of reserved and callee saves registers makes it unfeasible to compute this information statically in TableGen. Use RegisterClassInfo to count available registers in various heuristics in SimpleRegisterCoalescing, making the pass run 4% faster. llvm-svn: 132450
* Fix PR9962 by properly constraining register classes in ↵Cameron Zwarich2011-05-201-0/+4
| | | | | | | | RemoveCopyByCommutingDef(). This actually fixes most of the VerifyCoalescing failures in test-suite. llvm-svn: 131768
* Fix PR9960 by teaching SimpleRegisterCoalescing::AdjustCopiesBackFrom() to ↵Cameron Zwarich2011-05-201-0/+5
| | | | | | | | preserve the phikill flag. llvm-svn: 131717
* Eliminate dead dead code elimination code.Jakob Stoklund Olesen2011-05-181-266/+0
| | | | llvm-svn: 131524
* Also use shrinkToUses after AdjustCopiesBackFrom().Jakob Stoklund Olesen2011-05-181-1/+1
| | | | | | | The 'last use' may not be in the same basic block, and we still want a correct live range. llvm-svn: 131523
* Properly shrink live ranges after deleting dead copies. Clean up after all ↵Jakob Stoklund Olesen2011-05-181-24/+5
| | | | | | | | | | | | | joined copies. LiveInterval::shrinkToUses recomputes the live range from scratch instead of removing snippets. This should avoid the problem with dangling live ranges. Leave physreg identity copies alone. They can be created when joining a virtreg with a physreg. They don't affect register allocation, and they will be removed by the rewriter. llvm-svn: 131521
* Tweak cross-class coalescing to be more aggressive when the target class is ↵Jakob Stoklund Olesen2011-05-171-3/+9
| | | | | | | | | | | | | small. The greedy register allocator has live range splitting and register class inflation, so it can actually fully undo this join, including restoring the original register classes. We still don't want to do this for long live ranges, mostly because of the high register pressure of there are many constrained live ranges overlapping. llvm-svn: 131466
* 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. llvm-svn: 130896
* 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. llvm-svn: 130844
* 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. llvm-svn: 129283
* 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. llvm-svn: 128845
* Extract physreg joining policy to a separate method.Jakob Stoklund Olesen2011-04-041-53/+57
| | | | llvm-svn: 128844
* 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. llvm-svn: 128642
* 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. llvm-svn: 127351
* 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. llvm-svn: 126924
* Switch to SmallVector in SimpleRegisterCoalescing for a 3.5% speedup on 403.gcc.Cameron Zwarich2011-02-171-3/+3
| | | | llvm-svn: 125728
* 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. llvm-svn: 125058
* 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. llvm-svn: 123891
* Add hidden -verify-coalescing to run the machine code verifier before and afterJakob Stoklund Olesen2011-01-201-0/+10
| | | | | | register coalescing. llvm-svn: 123890
* 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. llvm-svn: 123107
* 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. llvm-svn: 122176
* Fix a comment typo.Bob Wilson2010-12-171-2/+2
| | | | llvm-svn: 122016
* Update LiveDebugVariables during coalescing.Jakob Stoklund Olesen2010-12-021-0/+4
| | | | llvm-svn: 120720
* 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. llvm-svn: 120636
* Unbreak build.Evan Cheng2010-10-221-10/+0
| | | | llvm-svn: 117155
* Transfer implicit ops when forming load multiple and return instructions.Evan Cheng2010-10-221-1/+1
| | | | llvm-svn: 117151
* 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> llvm-svn: 116940
* 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. llvm-svn: 116334
* Now with fewer extraneous semicolons!Owen Anderson2010-10-071-1/+1
| | | | llvm-svn: 115996
* Drop the use of LiveInterval::iterator and the LiveRange class inJakob Stoklund Olesen2010-10-011-14/+7
| | | | | | RemoveCopyByCommutingDef. llvm-svn: 115386
* 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. llvm-svn: 115385
* Pretty up the debug output during RemoveCopyByCommutingDef.Jakob Stoklund Olesen2010-10-011-19/+7
| | | | llvm-svn: 115384
* Fixed some tests to avoid LiveIntervals::getInstructionFromIndex(..) ↵Lang Hames2010-09-261-5/+5
| | | | | | overhead where possible. Thanks to Jakob for the suggestions. llvm-svn: 114798
* Avoid using VNInfo::getCopy as much as possible. I want to get rid of it.Jakob Stoklund Olesen2010-09-251-10/+6
| | | | llvm-svn: 114794
* Removed VNInfo::isDefAccurate(). Def "accuracy" can be checked by testing ↵Lang Hames2010-09-251-10/+9
| | | | | | whether LiveIntervals::getInstructionFromIndex(def) returns NULL. llvm-svn: 114791
* 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. llvm-svn: 112751
* 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. llvm-svn: 112567
* 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. llvm-svn: 111815
* 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. llvm-svn: 110631
* Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson2010-08-061-1/+1
| | | | llvm-svn: 110460
* Revert r110396 to fix buildbots.Owen Anderson2010-08-061-1/+1
| | | | llvm-svn: 110410
* 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. llvm-svn: 110403
* 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. llvm-svn: 110396
* 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. llvm-svn: 108507
* Remat uncoalescable COPY instrsJakob Stoklund Olesen2010-07-091-0/+11
| | | | llvm-svn: 108010
* Avoid creating %physreg:subidx operands in ↵Jakob Stoklund Olesen2010-07-091-1/+4
| | | | | | | | SimpleRegisterCoalescing::RemoveCopyByCommutingDef. This fixes PR7602. llvm-svn: 107957
OpenPOWER on IntegriCloud