summaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveInterval.cpp
Commit message (Collapse)AuthorAge
* Don't dereference begin() on an empty vector.Jakob Stoklund Olesen2012-09-27
| | | | | | | | The fix is obvious and the only test case I have is horrible, so I am not including it. The problem shows up when self-hosting clang on i386 with -new-coalescer enabled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164793 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete dead code.Jakob Stoklund Olesen2012-09-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163735 91177308-0d34-0410-b5e6-96231b3b80d8
* Release build: guard dump functions withManman Ren2012-09-11
| | | | | | | | | "#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)" No functional change. Update r163339. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163653 91177308-0d34-0410-b5e6-96231b3b80d8
* Release build: guard dump functions with "ifndef NDEBUG"Manman Ren2012-09-06
| | | | | | | No functional change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163339 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow overlaps between virtreg and physreg live ranges.Jakob Stoklund Olesen2012-09-06
| | | | | | | | | | | | | | | | | The RegisterCoalescer understands overlapping live ranges where one register is defined as a copy of the other. With this change, register allocators using LiveRegMatrix can do the same, at least for copies between physical and virtual registers. When a physreg is defined by a copy from a virtreg, allow those live ranges to overlap: %CL<def> = COPY %vreg11:sub_8bit; GR32_ABCD:%vreg11 %vreg13<def,tied1> = SAR32rCL %vreg13<tied0>, %CL<imp-use,kill> We can assign %vreg11 to %ECX, overlapping the live range of %CL. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163336 91177308-0d34-0410-b5e6-96231b3b80d8
* Completely eliminate VNInfo flags.Jakob Stoklund Olesen2012-08-03
| | | | | | | | The 'unused' state of a value number can be represented as an invalid def SlotIndex. This also exposed code that shouldn't have been looking at unused value VNInfos. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161258 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate the VNInfo::hasPHIKill() flag.Jakob Stoklund Olesen2012-08-03
| | | | | | | | | | The only real user of the flag was removeCopyByCommutingDef(), and it has been switched to LiveIntervals::hasPHIKill(). All the code changed by this patch was only concerned with computing and propagating the flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161255 91177308-0d34-0410-b5e6-96231b3b80d8
* Preserve 2-addr constraints in ConnectedVNInfoEqClasses.Jakob Stoklund Olesen2012-07-25
| | | | | | | | | | | | | | | | | | | | When a live range splits into multiple connected components, we would arbitrarily assign <undef> uses to component 0. This is wrong when the use is tied to a def that gets assigned to a different component: %vreg69<def> = ADD8ri %vreg68<undef>, 1 The use and def must get the same virtual register. Fix this by assigning <undef> uses to the same component as the value defined by the instruction, if any: %vreg69<def> = ADD8ri %vreg69<undef>, 1 This fixes PR13402. The PR has a test case which I am not including because it is unlikely to keep exposing this behavior in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160739 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach the LiveInterval::join function to use the fast merge algorithm,Chandler Carruth2012-07-10
| | | | | | | | | | | generalizing its implementation sufficiently to support this value number scenario as well. This cuts out another significant performance hit in large functions (over 10k basic blocks, etc), especially those with "natural" CFG structures. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160026 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug where I didn't test for an empty range before inspecting theChandler Carruth2012-07-10
| | | | | | | | | | | | | | | back of it. I don't have anything even remotely close to a test case for this. It only broke two build bots, both of them doing bootstrap builds, one of them a dragonegg bootstrap. It doesn't break for me when I bootstrap either. It doesn't reproduce every time or on many machines during the bootstrap. Many thanks to Duncan Sands who got the exact command (and stage of the bootstrap) which failed on the dragonegg bootstrap and managed to get it to trigger under valgrind with debug symbols. The fix was then found by inspection. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159993 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an efficient merge operation to LiveInterval and use it to avoidChandler Carruth2012-07-10
| | | | | | | | | | | quadratic behavior when performing pathological merges. Fixes the core element of PR12652. There is only one user of addRangeFrom left: join. I'm hoping to refactor further in a future patch and have join use this merge operation as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159982 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach LiveIntervals how to verify themselves and start using it in someChandler Carruth2012-07-10
| | | | | | | | | | of the trick merge routines. This adds a layer of testing that was necessary when implementing more efficient (and complex) merge logic for this datastructure. No functionality changed here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159981 91177308-0d34-0410-b5e6-96231b3b80d8
* Optimize extendIntervalEndTo a tiny bit by saving one call through theChandler Carruth2012-07-05
| | | | | | vector erase. No functionality changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159746 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify LiveInterval::print().Jakob Stoklund Olesen2012-06-05
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158031 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement LiveRangeCalc::extendToUses() and createDeadDefs().Jakob Stoklund Olesen2012-06-05
| | | | | | | These LiveRangeCalc methods are to be used when computing a live range from scratch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158027 91177308-0d34-0410-b5e6-96231b3b80d8
* Run proper recursive dead code elimination during coalescing.Jakob Stoklund Olesen2012-05-19
| | | | | | | | | | | | | | | Dead copies cause problems because they are trivial to coalesce, but removing them gived the live range a dangling end point. This patch enables full dead code elimination which trims live ranges to their uses so end points don't dangle. DCE may erase multiple instructions. Put the pointers in an ErasedInstrs set so we never risk visiting erased instructions in the work list. There isn't supposed to be any dead copies entering RegisterCoalescer, but they do slip by as evidenced by test/CodeGen/X86/coalescer-dce.ll. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157101 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't update spill weights when joining intervals.Jakob Stoklund Olesen2012-04-28
| | | | | | We don't compute spill weights until after coalescing anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155766 91177308-0d34-0410-b5e6-96231b3b80d8
* Spring cleaning - Delete dead code.Jakob Stoklund Olesen2012-04-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155765 91177308-0d34-0410-b5e6-96231b3b80d8
* Drop the REDEF_BY_EC VNInfo flag.Jakob Stoklund Olesen2012-02-04
| | | | | | | | | | A live range that has an early clobber tied redef now looks like a normal tied redef, except the early clobber def uses the early clobber slot. This is enough to handle any strange interference problems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149769 91177308-0d34-0410-b5e6-96231b3b80d8
* Break as soon as the MustMapCurValNos flag is set - no need to reiterate.Lang Hames2012-02-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149596 91177308-0d34-0410-b5e6-96231b3b80d8
* PR11868. The previous loop in LiveIntervals::join would sometimes fall over ifLang Hames2012-02-02
| | | | | | | | more than two adjacent ranges needed to be merged. The new version should be able to handle an arbitrary sequence of adjancent ranges. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149588 91177308-0d34-0410-b5e6-96231b3b80d8
* Use getVNInfoBefore() when it makes sense.Jakob Stoklund Olesen2011-11-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144517 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename SlotIndexes to match how they are used.Jakob Stoklund Olesen2011-11-13
| | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144503 91177308-0d34-0410-b5e6-96231b3b80d8
* Leave hasPHIKill flags alone in LiveInterval::RenumberValues.Jakob Stoklund Olesen2011-09-15
| | | | | | | | | | | It is conservatively correct to keep the hasPHIKill flags, even after deleting PHI-defs. The calculation can be very expensive after taildup has created a quadratic number of indirectbr edges in the CFG, and the hasPHIKill flag isn't used for anything after RenumberValues(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139780 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch extendInBlock() to take a kill slot instead of the last use slot.Jakob Stoklund Olesen2011-09-13
| | | | | | | Three out of four clients prefer this interface which is consistent with extendIntervalEndTo() and LiveRangeCalc::extend(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139604 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace a broken LiveInterval::MergeValueInAsValue() with something simpler.Jakob Stoklund Olesen2011-03-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127960 91177308-0d34-0410-b5e6-96231b3b80d8
* Rewrite instructions as part of ConnectedVNInfoEqClasses::Distribute.Jakob Stoklund Olesen2011-03-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127779 91177308-0d34-0410-b5e6-96231b3b80d8
* That's it, I am declaring this a failure of the C++03 STL.Jakob Stoklund Olesen2011-03-12
| | | | | | | | | | | | | | There are too many compatibility problems with using mixed types in std::upper_bound, and I don't want to spend 110 lines of boilerplate setting up a call to a 10-line function. Binary search is not /that/ hard to implement correctly. I tried terminating the binary search with a linear search, but that actually made the algorithm slower against my expectation. Most live intervals have less than 4 segments. The early test against endIndex() does pay, and this version is 25% faster than plain std::upper_bound(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127522 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix use of CompEnd predicate to be standards conformingJohn Wiegley2011-03-11
| | | | | | | | | | | | | The existing CompEnd predicate does not define a strict weak order as required by the C++03 standard; therefore, its use as a predicate to std::upper_bound is invalid. For a discussion of this issue, see http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#270 This patch replaces the asymmetrical comparison with an iterator adaptor that achieves the same effect while being strictly standard-conforming by ensuring an apples-to-apples comparison. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127462 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the build for MSVC 9 whose upper_bound() wants to compare elements in ↵Jakob Stoklund Olesen2011-03-08
| | | | | | | | the sorted array. Patch by Olaf Krzikalla! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127264 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Make a comparator's argument `const'. This fixes the build forOscar Fuentes2011-03-08
| | | | | | | | | | MSVC 9." The "fix" was meaningless. This reverts commit r127245. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127260 91177308-0d34-0410-b5e6-96231b3b80d8
* Make a comparator's argument `const'. This fixes the build for MSVC 9.Oscar Fuentes2011-03-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127245 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid comparing invalid slot indexes.Jakob Stoklund Olesen2011-03-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126922 91177308-0d34-0410-b5e6-96231b3b80d8
* Move LiveIntervalMap::extendTo into LiveInterval itself.Jakob Stoklund Olesen2011-03-02
| | | | | | | This method could probably be used by LiveIntervalAnalysis::shrinkToUses, and now it can use extendIntervalEndTo() which coalesces ranges. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126803 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement RAGreedy::splitAroundRegion and remove loop splitting.Jakob Stoklund Olesen2011-01-19
| | | | | | | | | | | | | | Region splitting includes loop splitting as a subset, and it is more generic. The splitting heuristics for variables that are live in more than one block are now: 1. Try to create a region that covers multiple basic blocks. 2. Try to create a new live range for each block with multiple uses. 3. Spill. Steps 2 and 3 are similar to what the standard spiller is doing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123853 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach TargetRegisterInfo how to cram stack slot indexes in with the virtual andJakob Stoklund Olesen2011-01-09
| | | | | | | | | | | | | physical register numbers. This makes the hack used in LiveInterval official, and lets LiveInterval be oblivious of stack slots. The isPhysicalRegister() and isVirtualRegister() predicates don't know about this, so when a variable may contain a stack slot, isStackSlot() should always be tested first. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123128 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace TargetRegisterInfo::printReg with a PrintReg class that also works ↵Jakob Stoklund Olesen2011-01-09
| | | | | | | | | | 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
* Use IntEqClasses to compute connected components of live intervals.Jakob Stoklund Olesen2010-12-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122296 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR8815 by checking for an explicit clobber def tied to a use operand inCameron Zwarich2010-12-19
| | | | | | | ConnectedVNInfoEqClasses::Classify(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122202 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach ConnectedVNInfoEqClasses::Classify to deal with unused values.Jakob Stoklund Olesen2010-10-29
| | | | | | | | We don't want unused values forming their own equivalence classes, so we lump them all together in one class, and then merge them with the class of the last used value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117670 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix broken equivalence class calculation. We could probably also useJakob Stoklund Olesen2010-10-29
| | | | | | | EquvivalenceClasses.h except it looks like overkill when elements are continuous integers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117631 91177308-0d34-0410-b5e6-96231b3b80d8
* Silence compiler warning.Benjamin Kramer2010-10-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116156 91177308-0d34-0410-b5e6-96231b3b80d8
* Classify value numbers into connected components in linear time.Jakob Stoklund Olesen2010-10-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116105 91177308-0d34-0410-b5e6-96231b3b80d8
* After splitting, the remaining LiveInterval may be fragmented into multipleJakob Stoklund Olesen2010-10-07
| | | | | | | | | | | | | connected components. These components should be allocated different virtual registers because there is no reason for them to be allocated together. Add the ConnectedVNInfoEqClasses class to calculate the connected components, and move values to new LiveIntervals. Use it from SplitKit::rewrite by creating new virtual registers for the components. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116006 91177308-0d34-0410-b5e6-96231b3b80d8
* Tweak VNInfo printing.Jakob Stoklund Olesen2010-10-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115650 91177308-0d34-0410-b5e6-96231b3b80d8
* Add assert for valid slot indexes.Jakob Stoklund Olesen2010-10-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115649 91177308-0d34-0410-b5e6-96231b3b80d8
* When RemoveCopyByCommutingDef is creating additional identity copies, just useJakob Stoklund Olesen2010-10-01
| | | | | | | | | | | 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
* Removed VNInfo::isDefAccurate(). Def "accuracy" can be checked by testing ↵Lang Hames2010-09-25
| | | | | | whether LiveIntervals::getInstructionFromIndex(def) returns NULL. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114791 91177308-0d34-0410-b5e6-96231b3b80d8
* Refix MSVC9 and upper_bound. It actually needs a fully symmetric comparator.Jakob Stoklund Olesen2010-09-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114469 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't pollute the global namespace.Jakob Stoklund Olesen2010-09-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114459 91177308-0d34-0410-b5e6-96231b3b80d8