aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SplitKit.cpp
AgeCommit message (Collapse)AuthorFilesLines
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-7/+7
instead of comparing to nullptr. llvm-svn: 206142
2014-03-17Switch a number of loops in lib/CodeGen over to range-based for-loops, now thatOwen Anderson1-5/+3
the MachineRegisterInfo iterators are compatible with it. llvm-svn: 204075
2014-03-13Phase 2 of the great MachineRegisterInfo cleanup. This time, we're changingOwen Anderson1-3/+3
operator* on the by-operand iterators to return a MachineOperand& rather than a MachineInstr&. At this point they almost behave like normal iterators! Again, this requires making some existing loops more verbose, but should pave the way for the big range-based for-loop cleanups in the future. llvm-svn: 203865
2014-03-02[C++11] Replace llvm::tie with std::tie.Benjamin Kramer1-5/+5
The old implementation is no longer needed in C++11. llvm-svn: 202644
2014-03-02[C++11] Replace llvm::next and llvm::prior with std::next and std::prev.Benjamin Kramer1-2/+2
Remove the old functions. llvm-svn: 202636
2013-10-10Work on LiveRange instead of LiveInterval where possibleMatthias Braun1-9/+9
Also change some pointer arguments to references at some places where 0-pointers are not allowed. llvm-svn: 192396
2013-10-10Rename LiveRange to LiveInterval::SegmentMatthias Braun1-7/+7
The Segment struct contains a single interval; multiple instances of this struct are used to construct a live range, but the struct is not a live range by itself. llvm-svn: 192392
2013-08-14Auto-compute live intervals on demand.Mark Lacey1-3/+3
When new virtual registers are created during splitting/spilling, defer creation of the live interval until we need to use the live interval. Along with the recent commits to notify LiveRangeEdit when new virtual registers are created, this makes it possible for functions like TargetInstrInfo::loadRegFromStackSlot() and TargetInstrInfo::storeRegToStackSlot() to create multiple virtual registers as part of the process of generating loads/stores for different register classes, and then have the live intervals for those new registers computed when they are needed. llvm-svn: 188437
2013-08-14Track new virtual registers by register number.Mark Lacey1-12/+15
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-08-14Remove unnecessary parameter to RenumberValues.Jakob Stoklund Olesen1-1/+1
Patch by Matthias Braun! llvm-svn: 188393
2013-06-17Switch spill weights from a basic loop depth estimation to BlockFrequencyInfo.Benjamin Kramer1-2/+4
The main advantages here are way better heuristics, taking into account not just loop depth but also __builtin_expect and other static heuristics and will eventually learn how to use profile info. Most of the work in this patch is pushing the MachineBlockFrequencyInfo analysis into the right places. This is good for a 5% speedup on zlib's deflate (x86_64), there were some very unfortunate spilling decisions in its hottest loop in longest_match(). Other benchmarks I tried were mostly neutral. This changes register allocation in subtle ways, update the tests for it. 2012-02-20-MachineCPBug.ll was deleted as it's very fragile and the instruction it looked for was gone already (but the FileCheck pattern picked up unrelated stuff). llvm-svn: 184105
2012-11-28Make the LiveRegMatrix analysis available to targets.Jakob Stoklund Olesen1-1/+1
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-09-11Release build: guard dump functions withManman Ren1-1/+1
"#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)" No functional change. Update r163339. llvm-svn: 163653
2012-09-06Release build: guard dump functions with "ifndef NDEBUG"Manman Ren1-0/+2
No functional change. llvm-svn: 163339
2012-08-03Fix a couple of loops that were processing unused value numbers.Jakob Stoklund Olesen1-1/+5
Unused VNInfos should be left alone. Their def SlotIndex doesn't point to anything. llvm-svn: 161257
2012-07-27Eliminate the IS_PHI_DEF flag and VNInfo::setIsPHIDef().Jakob Stoklund Olesen1-2/+1
A value number is a PHI def if and only if it begins at a block boundary. This can be derived from the def slot, a separate flag is not necessary. llvm-svn: 160893
2012-06-04Pass context pointers to LiveRangeCalc::reset().Jakob Stoklund Olesen1-10/+8
Remove the same pointers from all the other LiveRangeCalc functions, simplifying the interface. llvm-svn: 157941
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-04-02Refactored the LiveRangeEdit interface so that MachineFunction, ↵Pete Cooper1-8/+8
TargetInstrInfo, MachineRegisterInfo, LiveIntervals, and VirtRegMap are all passed into the constructor and stored as members instead of passed in to each method. llvm-svn: 153903
2012-02-04Don't store COPY pointers in VNInfo.Jakob Stoklund Olesen1-5/+2
If a value is defined by a COPY, that instuction can easily and cheaply be found by getInstructionFromIndex(VNI->def). This reduces the size of VNInfo from 24 to 16 bytes, and improves llc compile time by 3%. llvm-svn: 149763
2012-01-20More dead code removal (using -Wunreachable-code)David Blaikie1-1/+0
llvm-svn: 148578
2012-01-11Detect when a value is undefined on an edge to a landing pad.Jakob Stoklund Olesen1-4/+19
Consider this code: int h() { int x; try { x = f(); g(); } catch (...) { return x+1; } return x; } The variable x is undefined on the first edge to the landing pad, but it has the f() return value on the second edge to the landing pad. SplitAnalysis::getLastSplitPoint() would assume that the return value from f() was live into the landing pad when f() throws, which is of course impossible. Detect these cases, and treat them as if the landing pad wasn't there. This allows spill code to be inserted after the function call to f(). <rdar://problem/10664933> llvm-svn: 147912
2012-01-11Exclusively use SplitAnalysis::getLastSplitPoint().Jakob Stoklund Olesen1-2/+10
Delete the alternative implementation in LiveIntervalAnalysis. These functions computed the same thing, but SplitAnalysis caches the result. llvm-svn: 147911
2011-12-07Add bundle aware API for querying instruction properties and switch the codeEvan Cheng1-1/+1
generator to it. For non-bundle instructions, these behave exactly the same as the MC layer API. For properties like mayLoad / mayStore, look into the bundle and if any of the bundled instructions has the property it would return true. For properties like isPredicable, only return true if *all* of the bundled instructions have the property. For properties like canFoldAsLoad, isCompare, conservatively return false for bundles. llvm-svn: 146026
2011-11-14Use getVNInfoBefore() when it makes sense.Jakob Stoklund Olesen1-1/+1
llvm-svn: 144517
2011-11-13Terminate all dead defs at the dead slot instead of the 'next' slot.Jakob Stoklund Olesen1-5/+5
This makes no difference for normal defs, but early clobber dead defs now look like: [Slot_EarlyClobber; Slot_Dead) instead of: [Slot_EarlyClobber; Slot_Register). Live ranges for normal dead defs look like: [Slot_Register; Slot_Dead) as before. llvm-svn: 144512
2011-11-13Rename SlotIndexes to match how they are used.Jakob Stoklund Olesen1-5/+5
The old naming scheme (load/use/def/store) can be traced back to an old linear scan article, but the names don't match how slots are actually used. The load and store slots are not needed after the deferred spill code insertion framework was deleted. The use and def slots don't make any sense because we are using half-open intervals as is customary in C code, but the names suggest closed intervals. In reality, these slots were used to distinguish early-clobber defs from normal defs. The new naming scheme also has 4 slots, but the names match how the slots are really used. This is a purely mechanical renaming, but some of the code makes a lot more sense now. llvm-svn: 144503
2011-09-16Spill mode: Hoist back-copies locally.Jakob Stoklund Olesen1-6/+17
The leaveIntvAfter() function normally inserts a back-copy after the requested instruction, making the back-copy kill the live range. In spill mode, try to insert the back-copy before the last use instead. That means the last use becomes the kill instead of the back-copy. This lowers the register pressure because the last use can now redefine the same register it was reading. This will also improve compile time: The back-copy isn't a kill, so hoisting it in hoistCopiesForSize() won't force a recomputation of the source live range. Similarly, if the back-copy isn't hoisted by the splitter, the spiller will not attempt hoisting it locally. llvm-svn: 139883
2011-09-14Hoist back-copies to the least busy dominator.Jakob Stoklund Olesen1-2/+61
When a back-copy is hoisted to the nearest common dominator, keep looking up the dominator tree for a less loopy dominator, and place the back-copy there instead. Don't do this when a single existing back-copy dominates all the others. Assume the client knows what he is doing, and keep the dominating back-copy. This prevents us from hoisting back-copies into loops in most cases. If a value is defined in a loop with multiple exits, we may still hoist back-copies into that loop. That is the speed/size tradeoff. llvm-svn: 139698
2011-09-13Distinguish complex mapped values from forced recomputation.Jakob Stoklund Olesen1-31/+26
When a ParentVNI maps to multiple defs in a new interval, its live range may still be derived directly from RegAssign by transferValues(). On the other hand, when instructions have been rematerialized or hoisted, it may be necessary to completely recompute live ranges using LiveRangeCalc::extend() to all uses. Use a bit in the value map to indicate that a live range must be recomputed. Rename markComplexMapped() to forceRecompute(). This fixes some live range verification errors when -split-spill-mode=size hoists back-copies by recomputing source ranges when RegAssign kills can't be moved. llvm-svn: 139660
2011-09-13Implement -split-spill-mode=size.Jakob Stoklund Olesen1-0/+156
Whenever the complement interval is defined by multiple copies of the same value, hoist those back-copies to the nearest common dominator. This ensures that at most one copy is inserted per value in the complement inteval, and no phi-defs are needed. llvm-svn: 139651
2011-09-13Add SplitEditor::markOverlappedComplement().Jakob Stoklund Olesen1-2/+13
This function is used to flag values where the complement interval may overlap other intervals. Call it from overlapIntv, and use the flag to fully recompute those live ranges in transferValues(). llvm-svn: 139612
2011-09-13Eliminate the extendRange() wrapper.Jakob Stoklund Olesen1-16/+15
llvm-svn: 139608
2011-09-13Switch extendInBlock() to take a kill slot instead of the last use slot.Jakob Stoklund Olesen1-4/+2
Three out of four clients prefer this interface which is consistent with extendIntervalEndTo() and LiveRangeCalc::extend(). llvm-svn: 139604
2011-09-13Use a separate LiveRangeCalc for the complement in spill modes.Jakob Stoklund Olesen1-9/+19
The complement interval may overlap the other intervals created, so use a separate LiveRangeCalc instance to compute its live range. A LiveRangeCalc instance can only be shared among non-overlapping intervals. llvm-svn: 139603
2011-09-13Extract live range calculations from SplitKit.Jakob Stoklund Olesen1-236/+15
SplitKit will soon need two copies of these data structures, and the algorithms will also be useful when LiveIntervalAnalysis becomes independent of LiveVariables. llvm-svn: 139572
2011-09-12Add an interface for SplitKit complement spill modes.Jakob Stoklund Olesen1-2/+4
SplitKit always computes a complement live range to cover the places where the original live range was live, but no explicit region has been allocated. Currently, the complement live range is created to be as small as possible - it never overlaps any of the regions. This minimizes register pressure, but if the complement is going to be spilled anyway, that is not very important. The spiller will eliminate redundant spills, and hoist others by making the spill slot live range overlap some of the regions created by splitting. Stack slots are cheap. This patch adds the interface to enable spill modes in SplitKit. In spill mode, SplitKit will assume that the complement is going to spill, so it will allow it to overlap regions in order to avoid back-copies. By doing some of the spiller's work early, the complement live range becomes simpler. In some cases, it can become much simpler because no extra PHI-defs are required. This will speed up both splitting and spilling. This is only the interface to enable spill modes, no implementation yet. llvm-svn: 139500
2011-08-05Delete getMultiUseBlocks and splitSingleBlocks.Jakob Stoklund Olesen1-29/+0
These functions are no longer used, and they are easily replaced with a loop calling shouldSplitSingleBlock and splitSingleBlock. llvm-svn: 136993
2011-08-05Split around single instructions to enable register class inflation.Jakob Stoklund Olesen1-0/+18
Normally, we don't create a live range for a single instruction in a basic block, the spiller does that anyway. However, when splitting a live range that belongs to a proper register sub-class, inserting these extra COPY instructions completely remove the constraints from the remainder interval, and it may be allocated from the larger super-class. The spiller will mop up these small live ranges if we end up spilling anyway. It calls them snippets. llvm-svn: 136989
2011-08-02Rename {First,Last}Use to {First,Last}Instr.Jakob Stoklund Olesen1-30/+30
With a 'FirstDef' field right there, it is very confusing that FirstUse refers to an instruction that may be a def. llvm-svn: 136739
2011-08-02Add a BlockInfo::FirstDef field.Jakob Stoklund Olesen1-1/+14
This is either an invalid SlotIndex, or valno->def for the first value defined inside the block. PHI values are not counted as defined inside the block. The FirstDef field will be used when estimating the cost of spilling around a block. llvm-svn: 136736
2011-08-02Delete BlockInfo::LiveThrough. It wasn't used any more.Jakob Stoklund Olesen1-3/+0
llvm-svn: 136735
2011-07-24Never extend live ranges for <undef> uses.Jakob Stoklund Olesen1-1/+1
llvm-svn: 135886
2011-07-24Correctly handle <undef> tied uses when rewriting after a split.Jakob Stoklund Olesen1-8/+4
This fixes PR10463. A two-address instruction with an <undef> use operand was incorrectly rewritten so the def and use no longer used the same register, violating the tie constraint. Fix this by always rewriting <undef> operands with the register a def operand would use. llvm-svn: 135885
2011-07-23Fix bug in SplitEditor::splitLiveThroughBlock when switching registers.Jakob Stoklund Olesen1-5/+14
If there is no interference and no last split point, we cannot enterIntvBefore(Stop) - that function needs a real instruction. Use enterIntvAtEnd instead for that very easy case. This code doesn't currently run, it is needed by multi-way splitting. llvm-svn: 135846
2011-07-18Fix a crash when building 177.mesa for armv6.Jakob Stoklund Olesen1-1/+1
When splitting a live range immediately before an LDR_POST instruction that redefines the address register, make sure to use the correct value number in leaveIntvBefore. We need the value number entering the instruction. <rdar://problem/9793765> llvm-svn: 135413
2011-07-16Silence unused variable warningMatt Beaumont-Gay1-0/+1
llvm-svn: 135339
2011-07-16He said *before* the last split point.Jakob Stoklund Olesen1-1/+1
This should unbreak the build-self-4-mingw32 tester. I have a very complicated test case that I will try to clean up. llvm-svn: 135329
2011-07-15Extract parts of RAGreedy::splitAroundRegion as SplitKit methods.Jakob Stoklund Olesen1-0/+259
This gets rid of some of the gory splitting details in RAGreedy and makes them available to future SplitKit clients. Slightly generalize the functionality to support multi-way splitting. Specifically, SplitEditor::splitLiveThroughBlock() supports switching between different register intervals in a block. llvm-svn: 135307