aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/RegAllocBase.cpp
AgeCommit message (Collapse)AuthorFilesLines
2015-01-08[RegAllocGreedy] Introduce a late pass to repair broken hints.Quentin Colombet1-0/+2
A broken hint is a copy where both ends are assigned different colors. When a variable gets evicted in the neighborhood of such copies, it is likely we can reconcile some of them. ** Context ** Copies are inserted during the register allocation via splitting. These split points are required to relax the constraints on the allocation problem. When such a point is inserted, both ends of the copy would not share the same color with respect to the current allocation problem. When variables get evicted, the allocation problem becomes different and some split point may not be required anymore. However, the related variables may already have been colored. This usually shows up in the assembly with pattern like this: def A ... save A to B def A use A restore A from B ... use B Whereas we could simply have done: def B ... def A use A ... use B ** Proposed Solution ** A variable having a broken hint is marked for late recoloring if and only if selecting a register for it evict another variable. Indeed, if no eviction happens this is pointless to look for recoloring opportunities as it means the situation was the same as the initial allocation problem where we had to break the hint. Finally, when everything has been allocated, we look for recoloring opportunities for all the identified candidates. The recoloring is performed very late to rely on accurate copy cost (all involved variables are allocated). The recoloring is simple unlike the last change recoloring. It propagates the color of the broken hint to all its copy-related variables. If the color is available for them, the recoloring uses it, otherwise it gives up on that hint even if a more complex coloring would have worked. The recoloring happens only if it is profitable. The profitability is evaluated using the expected frequency of the copies of the currently recolored variable with a) its current color and b) with the target color. If a) is greater or equal than b), then it is profitable and the recoloring happen. ** Example ** Consider the following example: BB1: a = b = BB2: ... = b = a Let us assume b gets split: BB1: a = b = BB2: c = b ... d = c = d = a Because of how the allocation work, b, c, and d may be assigned different colors. Now, if a gets evicted to make room for c, assuming b and d were assigned to something different than a. We end up with: BB1: a = st a, SpillSlot b = BB2: c = b ... d = c = d e = ld SpillSlot = e This is likely that we can assign the same register for b, c, and d, getting rid of 2 copies. ** Performances ** Both ARM64 and x86_64 show performance improvements of up to 3% for the llvm-testsuite + externals with Os and O3. There are a few regressions too that comes from the (in)accuracy of the block frequency estimate. <rdar://problem/18312047> llvm-svn: 225422
2014-11-17Move register class name strings to a single array in MCRegisterInfo to ↵Craig Topper1-1/+1
reduce static table size and number of relocation entries. Indices into the table are stored in each MCRegisterClass instead of a pointer. A new method, getRegClassName, is added to MCRegisterInfo and TargetRegisterInfo to lookup the string in the table. llvm-svn: 222118
2014-10-14Remove unnecessary TargetMachine.h includes.Eric Christopher1-1/+0
llvm-svn: 219672
2014-04-22[Modules] Remove potential ODR violations by sinking the DEBUG_TYPEChandler Carruth1-1/+2
define below all header includes in the lib/CodeGen/... tree. While the current modules implementation doesn't check for this kind of ODR violation yet, it is likely to grow support for it in the future. It also removes one layer of macro pollution across all the included headers. Other sub-trees will follow. llvm-svn: 206837
2014-04-14[C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper1-1/+1
instead of comparing to nullptr. llvm-svn: 206142
2014-03-13Phase 1 of refactoring the MachineRegisterInfo iterators to make them suitableOwen Anderson1-4/+9
for use with C++11 range-based for-loops. The gist of phase 1 is to remove the skipInstruction() and skipBundle() methods from these iterators, instead splitting each iterator into a version that walks operands, a version that walks instructions, and a version that walks bundles. This has the result of making some "clever" loops in lib/CodeGen more verbose, but also makes their iterator invalidation characteristics much more obvious to the casual reader. (Making them concise again in the future is a good motivating case for a pre-incrementing range adapter!) Phase 2 of this undertaking with consist of removing the getOperand() method, and changing operator*() of the operand-walker to return a MachineOperand&. At that point, it should be possible to add range views for them that work as one might expect. llvm-svn: 203757
2014-02-22Fix typoManman Ren1-1/+1
llvm-svn: 201944
2013-11-22DEBUG shouldEvict decisionsAndrew Trick1-2/+2
llvm-svn: 195490
2013-11-19[weak vtables] Remove a bunch of weak vtablesJuergen Ributzka1-0/+3
This patch removes most of the trivial cases of weak vtables by pinning them to a single object file. The memory leaks in this version have been fixed. Thanks Alexey for pointing them out. Differential Revision: http://llvm-reviews.chandlerc.com/D2068 Reviewed by Andy llvm-svn: 195064
2013-11-18Revert r194865 and r194874.Alexey Samsonov1-3/+0
This change is incorrect. If you delete virtual destructor of both a base class and a subclass, then the following code: Base *foo = new Child(); delete foo; will not cause the destructor for members of Child class. As a result, I observe plently of memory leaks. Notable examples I investigated are: ObjectBuffer and ObjectBufferStream, AttributeImpl and StringSAttributeImpl. llvm-svn: 194997
2013-11-15[weak vtables] Remove a bunch of weak vtablesJuergen Ributzka1-0/+3
This patch removes most of the trivial cases of weak vtables by pinning them to a single object file. Differential Revision: http://llvm-reviews.chandlerc.com/D2068 Reviewed by Andy llvm-svn: 194865
2013-10-10Print register in LiveInterval::print()Matthias Braun1-1/+1
llvm-svn: 192398
2013-10-05Emit a better error when running out of registers on inline asm.Benjamin Kramer1-3/+2
The most likely case where this error happens is when the user specifies too many register operands. Don't make it look like an internal LLVM bug when we can see that the error is coming from an inline asm instruction. For other instructions we keep the "ran out of registers" error. llvm-svn: 192041
2013-08-14Track new virtual registers by register number.Mark Lacey1-2/+2
Track new virtual registers by register number, rather than by the live interval created for them. This is the first step in separating the creation of new virtual registers and new live intervals. Eventually live intervals will be created and populated on demand after the virtual registers have been created and used in instructions. llvm-svn: 188434
2013-07-17Make constant string pointer into an array to remove a pointer lookup for ↵Craig Topper1-1/+1
every access. llvm-svn: 186482
2012-11-28Make the LiveRegMatrix analysis available to targets.Jakob Stoklund Olesen1-2/+2
No functional change, just moved header files. Targets can inject custom passes between register allocation and rewriting. This makes it possible to tweak the register allocation before rewriting, using the full global interference checking available from LiveRegMatrix. llvm-svn: 168806
2012-11-28Revert r168630, r168631, and r168633 as these are causing nightly test failures.Chad Rosier1-0/+1
llvm-svn: 168751
2012-11-26Now that the X86 Maximal Stack Alignment Check pass has been removed (i.e.,Chad Rosier1-1/+0
r168627), we no longer need to call the freezeReservedRegs() function a second time. Previously, this pass was conservatively adding the FP to the set of reserved registers, requiring the second update to the reserved registers. rdar://12719844 llvm-svn: 168630
2012-06-20Remove LiveIntervalUnions from RegAllocBase.Jakob Stoklund Olesen1-107/+6
They are living in LiveRegMatrix now. llvm-svn: 158868
2012-06-20Convert RABasic to using LiveRegMatrix interference checking.Jakob Stoklund Olesen1-0/+13
Stop using the LiveIntervalUnions provided by RegAllocBase, they will be removed soon. llvm-svn: 158866
2012-06-20Avoid iterating with LiveIntervals::iterator.Jakob Stoklund Olesen1-19/+25
That is a DenseMap iterator keyed by pointers, so the iteration order is nondeterministic. I would like to replace the DenseMap with an IndexedMap which doesn't allow iteration. llvm-svn: 158856
2012-06-09Also compute MBB live-in lists in the new rewriter pass.Jakob Stoklund Olesen1-38/+0
This deduplicates some code from the optimizing register allocators, and it means that it is now possible to change the register allocators' solutions simply by editing the VirtRegMap between the register allocator pass and the rewriter. llvm-svn: 158249
2012-06-05Move LiveUnionArray into LiveIntervalUnion.hJakob Stoklund Olesen1-26/+8
It is useful outside RegAllocBase. llvm-svn: 158041
2012-06-05Don't print register names in LiveIntervalUnion::print().Jakob Stoklund Olesen1-1/+1
Soon we'll be making LiveIntervalUnions for register units as well. This was the only place using the RepReg member, so just remove it. llvm-svn: 158038
2012-06-05Simplify LiveInterval::print().Jakob Stoklund Olesen1-1/+1
Don't print out the register number and spill weight, making the TRI argument unnecessary. This allows callers to interpret the reg field. It can currently be a virtual register, a physical register, a spill slot, or a register unit. llvm-svn: 158031
2012-06-01Switch all register list clients to the new MC*Iterator interface.Jakob Stoklund Olesen1-3/+3
No functional change intended. Sorry for the churn. The iterator classes are supposed to help avoid giant commits like this one in the future. The TableGen-produced register lists are getting quite large, and it may be necessary to change the table representation. This makes it possible to do so without changing all clients (again). llvm-svn: 157854
2012-05-12Don't look for empty live ranges in the unions.Jakob Stoklund Olesen1-1/+4
Empty live ranges represent undef and still get allocated, but they won't appear in LiveIntervalUnions. Patch by Patrik Hägglund! llvm-svn: 156685
2012-04-02Moved LiveRangeEdit.h so that it can be called from other parts of the ↵Pete Cooper1-1/+1
backend, not just libCodeGen llvm-svn: 153906
2012-03-04Use uint16_t to store register overlaps to reduce static data.Craig Topper1-1/+1
llvm-svn: 152001
2012-01-11Sink spillInterferences into RABasic.Jakob Stoklund Olesen1-54/+0
This helper method is too simplistic for RAGreedy. llvm-svn: 147976
2012-01-11Move RegAllocBase into its own cpp file separate from RABasic.Jakob Stoklund Olesen1-0/+334
No functional change. llvm-svn: 147972