History log of /external/llvm/lib/CodeGen/RegAllocGreedy.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
69d37fa6351d5fe2a97ea24a2d0d667a92f14a9c 05-Mar-2013 Bill Wendling <isanbard@gmail.com> Remove unused #includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176467 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
6d6132986d2ef14bbf9d76f5acbf2a0bace32d69 12-Jan-2013 Jakob Stoklund Olesen <stoklund@2pi.dk> Limit the search space in RAGreedy::tryEvict().

When tryEvict() is looking for a cheaper register in the allocation
order, skip the tail of too expensive registers when possible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172281 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
f7999fe1cb2c2bdb0a4080efabb4743719ce45ca 04-Dec-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Speed up the AllocationOrder class a bit.

Allow the central functions to be inlined, and use the argumentless
isHint() function when possible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169319 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
fc6374439edf2f74da4026f4cea8e341d092be5c 04-Dec-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Add VirtRegMap::hasKnownPreference().

Virtual registers with a known preferred register are prioritized by
RAGreedy. This function makes the condition explicit without depending
on getRegAllocPref().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169179 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d04a8d4b33ff316ca4cf961e06c9e312eff8e64f 03-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Use the new script to sort the includes of every file under lib.

Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
1ead68d769f27f6d68d4aaeffe4199fa2cacbc95 28-Nov-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Make the LiveRegMatrix analysis available to targets.

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168806 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
bb36a438722d4d56febc07c6472c8446bb6faafe 21-Sep-2012 Evan Cheng <evan.cheng@apple.com> Fix a significant recent(?) regression. StackSlotColoring no longer did anything
because LiveStackAnalysis was not preserved by VirtRegWriter. This caused
big stack usage regression in some cases.

rdar://12340383


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164408 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
67c8978617c3bce9d07210f93f6c64c715f77695 12-Sep-2012 Dmitri Gribenko <gribozavr@gmail.com> Fix a couple of Doxygen comment issues pointed out by -Wdocumentation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163721 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
986d76d7b3844b9a2f3d01a48975952749267a93 22-Aug-2012 David Blaikie <dblaikie@gmail.com> Tidy up a few more uses of MF.getFunction()->getName().

Based on CR feedback from r162301 and Craig Topper's refactoring in r162347
here are a few other places that could use the same API (& in one instance drop
a Function.h dependency).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162367 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
96601ca332ab388754ca4673be8973396fea2ddd 22-Aug-2012 Craig Topper <craig.topper@gmail.com> Add a getName function to MachineFunction. Use it in places that previously did getFunction()->getName(). Remove includes of Function.h that are no longer needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162347 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
79c78de3785a24cb6994038f0e8df92bded548e6 21-Aug-2012 David Blaikie <dblaikie@gmail.com> Remove unnecessary cast that was also unnecessarily casting away constness.

Even looking at the revision history I couldn't quite piece together why this
cast was ever written in the first place, but I assume it was because of some
change in the inheritance, perhaps this function was reimplemented in a
derived type & this caller was meant to get the base version (& it wasn't
virtual)?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162301 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d4348a2dc24c4fb012c1b9b20e71908f52049283 21-Jun-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Remove LiveIntervalUnions from RegAllocBase.

They are living in LiveRegMatrix now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158868 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
042888db2bb195c86bf34afbb6907d70855d2830 21-Jun-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Convert RAGreedy to LiveRegMatrix interference checking.

Stop depending on the LiveIntervalUnions in RegAllocBase, they are about
to be removed.

The changes are mostly replacing register alias iterators with regunit
iterators, and querying LiveRegMatrix instrad of RegAllocBase.

InterferenceCache is converted to work with per-regunit
LiveIntervalUnions, and it checks fixed regunit interference separately,
using the fixed live intervals provided by LiveIntervalAnalysis.

The local splitting helper calcGapWeights() is also considering fixed
regunit interference which is kept on the side now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158867 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
fe17bdbb50efe2f7f68d0b99e55ae52bd9477978 09-Jun-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Also compute MBB live-in lists in the new rewriter pass.

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158249 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
05ec712e7f75635abbdd84dced69f4a45fe0f541 09-Jun-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Reintroduce VirtRegRewriter.

OK, not really. We don't want to reintroduce the old rewriter hacks.

This patch extracts virtual register rewriting as a separate pass that
runs after the register allocator. This is possible now that
CodeGen/Passes.cpp can configure the full optimizing register allocator
pipeline.

The rewriter pass uses register assignments in VirtRegMap to rewrite
virtual registers to physical registers, and it inserts kill flags based
on live intervals.

These finalization steps are the same for the optimizing register
allocators: RABasic, RAGreedy, and PBQP.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158244 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
95a9d937728ca9cf2bf44f86ff1184df318b3bd7 06-Jun-2012 Benjamin Kramer <benny.kra@googlemail.com> Round 2 of dead private variable removal.

LLVM is now -Wunused-private-field clean except for
- lib/MC/MCDisassembler/Disassembler.h. Not sure why it keeps all those unaccessible fields.
- gtest.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158096 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
396618b43a85e12d290a90b181c6af5d7c0c5f11 02-Jun-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Switch all register list clients to the new MC*Iterator interface.

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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157854 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
9cda1be0aa5e9e70ae493ef6944a8c202c1c70e6 30-May-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Prioritize smaller register classes for urgent evictions.

It helps compile exotic inline asm. In the test case, normal GR32
virtual registers use up eax-edx so the final GR32_ABCD live range has
no registers left. Since all the live ranges were tiny, we had no way of
prioritizing the smaller register class.

This patch allows tiny unspillable live ranges to be evicted by tiny
unspillable live ranges from a smaller register class.

<rdar://problem/11542429>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157715 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d74d2847573df690b6a91254688ef3fd974f83f7 24-May-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Add a last resort tryInstructionSplit() to RAGreedy.

Live ranges with a constrained register class may benefit from splitting
around individual uses. It allows the remaining live range to use a
larger register class where it may allocate. This is like spilling to a
different register class.

This is only attempted on constrained register classes.

<rdar://problem/11438902>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157354 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
20942dcd8634ad75091fe89669868cfebf74e869 19-May-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Allow LiveRangeEdit to be created with a NULL parent.

The dead code elimination with callbacks is still useful.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157100 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
789d5d85ba6e9259a8e0f0bcfbd06a59ad164512 03-Apr-2012 Pete Cooper <peter_cooper@apple.com> Moved LiveRangeEdit.h so that it can be called from other parts of the backend, not just libCodeGen

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153906 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
e3b23cde80b19507f1d8b641a541e91ace0864dc 03-Apr-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Allocate virtual registers in ascending order.

This is just the fallback tie-breaker ordering, the main allocation
order is still descending size.

Patch by Shamil Kurmangaleev!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153904 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
8a06af96698537377275dd7848db69915638dd26 03-Apr-2012 Pete Cooper <peter_cooper@apple.com> Refactored the LiveRangeEdit interface so that MachineFunction, TargetInstrInfo, MachineRegisterInfo, LiveIntervals, and VirtRegMap are all passed into the constructor and stored as members instead of passed in to each method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153903 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
e4fd907e72a599eddfa7a81eac4366b5b82523e3 04-Mar-2012 Craig Topper <craig.topper@gmail.com> Use uint16_t to store register overlaps to reduce static data.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152001 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
19273aec441411b4d571fdb87c6daa0fbe7a33a0 21-Feb-2012 Andrew Trick <atrick@apple.com> Clear virtual registers after they are no longer referenced.

Passes after RegAlloc should be able to rely on MRI->getNumVirtRegs() == 0.
This makes sharing code for pre/postRA passes more robust.
Now, to check if a pass is running before the RA pipeline begins, use MRI->isSSA().
To check if a pass is running after the RA pipeline ends, use !MRI->getNumVirtRegs().

PEI resets virtual regs when it's done scavenging.

PTX will either have to provide its own PEI pass or assign physregs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151032 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
cac5fa39bd861861018bb2c3f0b36cc71c2caa38 15-Feb-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Fix details in local live range splitting with regmasks.

Perform all comparisons at instruction granularity, and make sure
register masks on uses count in both gaps.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150530 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
a6d513f47467b90344a74624d4fb77673942e3ce 11-Feb-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Handle register masks in local live range splitting.

Again the goal is to produce identical assembly with register mask
operands enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150287 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
6ef7da0197735a16aa534e9e2c80709d3d6e8c56 10-Feb-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Add register mask support to InterferenceCache.

This makes global live range splitting behave identically with and
without register mask operands.

This is not necessarily the best way of using register masks for live
range splitting. It would be more efficient to first split global live
ranges around calls (i.e., register masks), and reserve the fine grained
per-physreg interference guidance for global live ranges that do not
cross calls.

For now the goal is to produce identical assembly when enabling register
masks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150259 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
8dd26253f54247e77e5accfdd70e7b4bf27b39c2 10-Feb-2012 Andrew Trick <atrick@apple.com> RegAlloc superpass: includes phi elimination, coalescing, and scheduling.

Creates a configurable regalloc pipeline.

Ensure specific llc options do what they say and nothing more: -reglloc=... has no effect other than selecting the allocator pass itself. This patch introduces a new umbrella flag, "-optimize-regalloc", to enable/disable the optimizing regalloc "superpass". This allows for example testing coalscing and scheduling under -O0 or vice-versa.

When a CodeGen pass requires the MachineFunction to have a particular property, we need to explicitly define that property so it can be directly queried rather than naming a specific Pass. For example, to check for SSA, use MRI->isSSA, not addRequired<PHIElimination>.

CodeGen transformation passes are never "required" as an analysis

ProcessImplicitDefs does not require LiveVariables.

We have a plan to massively simplify some of the early passes within the regalloc superpass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150226 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
e7c2c15b0cfa14d6b273e0e95d9de133cc958da8 09-Feb-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Add register mask support to RAGreedy.

This only adds the interference checks required for correctness.
We still need to take advantage of register masks for the
interference driven live range splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150191 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
42b7a71dc7381d1f38bf7b7201fc26dd80453364 17-Jan-2012 Andrew Trick <atrick@apple.com> Renamed MachineScheduler to ScheduleTopDownLive.

Responding to code review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148290 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
c1b1c7b205589c9a081e1cbd33fb56506fc287b3 17-Jan-2012 Andrew Trick <atrick@apple.com> Moving options declarations around.

More short term hackery until we have a way to configure passes that work on LiveIntervals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148289 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
96f678f2d78ae9a2a8c99ca612bf59c056b36797 13-Jan-2012 Andrew Trick <atrick@apple.com> Added the MachineSchedulerPass skeleton.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148105 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b20b518f800293ea6b2bed04134c71293ac52403 12-Jan-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Make SplitAnalysis::UseSlots private.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148031 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
9384111e90cb840e7eb867098f19910cf4c4a11d 12-Jan-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Make data structures private.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147979 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
cb39064e7aee2273da1d00e6b800db84ddc34b6b 13-Nov-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Stop tracking spill slot uses in VirtRegMap.

Nobody cared, StackSlotColoring scans the instructions to find used stack
slots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144485 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
7bdf0060a00f04ad03d3c6f294d8db6f4951dbc2 01-Nov-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Update split candidate correctly when interference cache is full.

No test case, spotted by inspection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143407 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
0d4fea786670473b53d285be378e619399e03488 14-Sep-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Ignore the cloning of unknown registers.

THe LRE_DidCloneVirtReg callback may be called with vitual registers
that RAGreedy doesn't even know about yet. In that case, there are no
data structures to update.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139702 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
a16a25ddeaf495b78b04e2a19feeac00d9824e63 12-Sep-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Remove the -compact-regions flag.

It has been enabled by default for a while, it was only there to allow
performance comparisons.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139501 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
708d06f7fb5dfd9c8559aea07b042a88c65645f8 12-Sep-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add an interface for SplitKit complement spill modes.

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139500 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
a67f14bf53737f9bb0afefa28e08c4aac6ec4804 19-Aug-2011 Benjamin Kramer <benny.kra@googlemail.com> Make a bunch of symbols private.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138025 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
27215676c7114132a0374f7b5c9ea73d9354d329 09-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Refer to the RegisterCoalescer pass by ID.

A public interface is no longer needed since RegisterCoalescer is not an
analysis any more.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137082 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
69145baf36219b07a49d8ce14b4a04870e72a123 06-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Fix typo. Thanks, Andy!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137023 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
ccfa446450c9e3e0b3591343c4c5bea1e4cdc043 06-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Reject RS_Spill ranges from local splitting as well.

All new local ranges are marked as RS_New now, so there is no need to
attempt splitting of RS_Spill ranges any more.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137002 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
a9c41d39d1adc92107e095aca6f851aed71b6a5f 06-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Only mark remainder intervals as RS_Spill after per-block splitting.

The local ranges created get to stay in the RS_New stage, just like for
local and region splitting.

This gives tryLocalSplit a bit more freedom the first time it sees one
of these new local ranges.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137001 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
1f8804263ffc5e6843d81f5c7bd9c739aa90fde5 06-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Remember to update LiveDebugVariables after per-block splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136996 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
dab35d33ae17353cb01aaaa42abbcb28b33eb98a 06-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Extract per-block splitting into its own method.

No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136994 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b3ef7f6b97eb4a61bbafc0a97fb94086919dcbd6 06-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Also use shouldSplitSingleBlock() in the fallback splitting mode.

Drop the use of SplitAnalysis::getMultiUseBlocks, there is no need to go
through a SmallPtrSet any more.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136992 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
2d6d86be84ee355223ccd20b7f87a0c9971c50c9 06-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Split around single instructions to enable register class inflation.

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136989 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
a92afc18a8ff72b905902d75a2a4920d5438ca0c 04-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Enable compact region splitting by default.

This helps generate better code in functions with high register
pressure.

The previous version of compact region splitting caused regressions
because the regions were a bit too large. A stronger negative bias
applied in r136832 fixed this problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136836 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b87f91b063a0ac853735f2af3bd94fb8551a11ff 04-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Be more conservative when forming compact regions.

Apply twice the negative bias on transparent blocks when computing the
compact regions. This excludes loop backedges from the region when only
one of the loop blocks uses the register.

Previously, we would include the backedge in the region if the loop
preheader and the loop latch both used the register, but the loop header
didn't.

When both the header and latch blocks use the register, we still keep it
live on the backedge.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136832 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
32668ea7a290ee1cb6bfe8cd677cdd4e5df05b4d 04-Aug-2011 Chandler Carruth <chandlerc@gmail.com> Fix some warnings from Clang in release builds:

lib/CodeGen/RegAllocGreedy.cpp:1176:18: warning: unused variable 'B' [-Wunused-variable]
if (unsigned B = Cand.getBundles(BundleCand, BestCand)) {
^
lib/CodeGen/RegAllocGreedy.cpp:1188:18: warning: unused variable 'B' [-Wunused-variable]
if (unsigned B = Cand.getBundles(BundleCand, 0)) {
^

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136831 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
3f5beede1bb97ba4e06dc300e00b70e1013e7216 03-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Use the precomputed def presence in RAGreedy::calcSpillCost.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136742 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
5ebca793db6262386d7464d03cdaefeb5b640ad3 03-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Inform SpillPlacement about blocks with defs.

This information is not used for anything yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136741 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
fe62d92b7bbaf73e576bec0c0b11cfa6c191aa87 03-Aug-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Rename {First,Last}Use to {First,Last}Instr.

With a 'FirstDef' field right there, it is very confusing that FirstUse
refers to an instruction that may be a def.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136739 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
c47690264abd6ec6bdeab86ce057e99bb5d39fe4 31-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Time the emission of debug values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136584 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
21384c4ea8e1a8097a1feef1813c1414af9dae2a 30-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Revert r136528 "Enable compact region splitting by default."

While this generally helped x86-64, there was some large regressions
for i386.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136571 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
9162abb39f13146c0dea159e92ac291e4ea900bf 30-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Enable compact region splitting by default.

This helps generate better code in functions with high register
pressure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136528 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
cc07e04262fe4bc35469fbadc53d2ec7bfd02fe2 28-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Reverse order of RS_Split live ranges under -compact-regions.

There are two conflicting strategies in play:

- Under high register pressure, we want to assign large live ranges
first. Smaller live ranges are easier to place afterwards.

- Live range splitting is guided by interference, so splitting should be
deferred until interference is as realistic as possible.

With the recent changes to the live range stages, and with compact
regions enabled, it is less traumatic to split a live range too early.
If some of the split products were too big, they can often be split
again.

By reversing the RS_Split order, we get this queue order:

1. Normal live ranges, large to small.
2. RS_Split live ranges, large to small.

The large-to-small order improves RAGreedy's puzzle solving skills under
high register pressure. It may cause a bit more iterated splitting, but
we handle that better now.

With this change, -compact-regions is mostly an improvement on SPEC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136388 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
00005782fa860f4b48b3b5261d92541c61ee2495 27-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add support for multi-way live range splitting.

When splitting global live ranges, it is now possible to split for
multiple destination intervals at once. Previously, we only had the main
and stack intervals.

Each edge bundle is assigned to a split candidate, and splitAroundRegion
will insert copies between the candidate intervals and the stack
interval as needed.

The multi-way splitting is used to split around compact regions when
enabled with -compact-regions. The best candidate register still gets
all the bundles it wants, but everything outside the main interval is
first split around compact regions before we create single-block
intervals.

Compact region splitting still causes some regressions, so it is not
enabled by default.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136186 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
165e231c4295deb5cabd124d08e231b551bcc0b2 26-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Revert to RA_Assign when a virtreg separates into components.

When dead code elimination deletes a PHI value, the virtual register may
split into multiple connected components. In that case, revert each
component to the RS_Assign stage.

The new components are guaranteed to be smaller (the original value
numbers are distributed among the components), so this will always be
making progress. The components are now allowed to evict other live
ranges or be split again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136034 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
49743b18f50ac0f7e065f4754a26965d4db388de 25-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add an RS_Split2 stage used for loop prevention.

This mechanism already exists, but the RS_Split2 stage makes it clearer.

When live range splitting creates ranges that may not be making
progress, they are marked RS_Split2 instead of RS_New. These ranges may
be split again, but only in a way that can be proven to make progress.

For local ranges, that means they must be split into ranges used by
strictly fewer instructions.

For global ranges, region splitting is bypassed and the RS_Split2
ranges go straight to per-block splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135912 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
fa89a0344bba7a0ae87d3de204d18bb1ecaa5955 25-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Rename live range stages to better reflect how they are used.

The stage is used to control where a live range is going, not where it
is coming from. Live ranges created by splitting will usually be marked
RS_New, but some are marked RS_Spill to avoid wasting time trying to
split them again.

The old RS_Global and RS_Local stages are merged - they are really the
same thing for local and global live ranges.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135911 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
87972fa63f0e2631778166e0c258c456ec12db7c 23-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add RAGreedy::calcCompactRegion.

This method computes the edge bundles that should be live when splitting
around a compact region. This is independent of interference.

The function returns false if the live range was already a compact
region, or the compact region doesn't have any live bundles - it would
be the same as splitting around basic blocks.

Compact regions are computed using the normal spill placement code. We
pretend there is interference in all live-through blocks that don't use
the live range. This removes all edges from the Hopfield network used
for spill placement, so it converges instantly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135847 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b4666364f4db4889883d7a6c02a177ebcde7c240 23-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Prepare RAGreedy::growRegion for compact regions.

A split candidate can have a null PhysReg which means that it doesn't
map to a real interference pattern. Instead, pretend that all through
blocks have interference.

This makes it possible to generate compact regions where the live range
doesn't go through blocks that don't use it. The live range will still
be live between directly connected blocks with uses.

Splitting around a compact region tends to produce a live range with a
high spill weight, so it may evict a less dense live range.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135845 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
39b5abf507b43da6b92f68b86406e0015ead18e9 18-Jul-2011 Frits van Bommel <fvbommel@gmail.com> Migrate LLVM and Clang to use the new makeArrayRef(...) functions where previously explicit non-default constructors were used.
Mostly mechanical with some manual reformatting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135390 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
975eb99cf3e3efaf83cfeddde982800d6a84f704 16-Jul-2011 Jakub Staszak <jstaszak@apple.com> Remove unused LoopRanges from RegAllocGreedy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135354 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b4ddedce599183362b0f0333922c2fe0e163a129 15-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Extract parts of RAGreedy::splitAroundRegion as SplitKit methods.

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135307 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
f1c709837bd11c5383fce3b8a026a7c8eaabba86 14-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Reapply r135121 with a fixed copy constructor.

Original commit message:

Count references to interference cache entries.

Each InterferenceCache::Cursor instance references a cache entry. A
non-zero reference count guarantees that the entry won't be reused for a
new register.

This makes it possible to have multiple live cursors examining
interference for different physregs.

The total number of live cursors into a cache must be kept below
InterferenceCache::getMaxCursors().

Code generation should be unaffected by this change, and it doesn't seem
to affect the cache replacement strategy either.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135130 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
4fcfcf498436533ea9bc59404d10751bc76cfd2c 14-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Revert r135121 which broke a gcc-4.2 builder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135122 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
6a9feaac935c9345f825b272cf3225248e282f3f 14-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Count references to interference cache entries.

Each InterferenceCache::Cursor instance references a cache entry. A
non-zero reference count guarantees that the entry won't be reused for a
new register.

This makes it possible to have multiple live cursors examining
interference for different physregs.

The total number of live cursors into a cache must be kept below
InterferenceCache::getMaxCursors().

Code generation should be unaffected by this change, and it doesn't seem
to affect the cache replacement strategy either.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135121 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
c66a37df73f70ec3dbed06277763624f33ee3512 14-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Reapply r135074 and r135080 with a fix.

The cache entry referenced by the best split candidate could become
clobbered by an unsuccessful candidate.

The correct fix here is to use reference counts on the cache entries.
Coming up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135113 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
54c74e906a622c1a2d95d2fc11a7dae88a61963e 14-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Revert r135074 and r135080. They broke clamscan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135096 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
3bae1bf62eba1a2715ec22d9800799184cc495e6 13-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Only keep the global split candidates that work out.

Some pysical registers create split solutions that would spill anywhere.
They should not even be considered in future multi-way global splits.

This does not affect code generation (yet).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135080 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
1337e2b75a6fc52ced7f6c2b2ad05ac62b8cbdca 13-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Move the InterferenceCache cursor into the GlobalSplitCand struct.

This is in preparation of supporting multiple global split candidates in
a single live range split operation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135074 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
51458ed09e6db0e424cd528e10b879f59915abe4 08-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Be more aggressive about following hints.

RAGreedy::tryAssign will now evict interference from the preferred
register even when another register is free.

To support this, add the EvictionCost struct that counts how many hints
are broken by an eviction. We don't want to break one hint just to
satisfy another.

Rename canEvict to shouldEvict, and add the first bit of eviction policy
that doesn't depend on spill weights: Always make room in the preferred
register as long as the evictees can be split and aren't already
assigned to their preferred register.

Also make the CSR avoidance more accurate. When looking for a cheaper
register it is OK to use a new volatile register. Only CSR aliases that
have never been used before should be avoided.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134735 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
549019792a8b14500cab093ac8f3c5f7331e86d7 05-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Break infinite loop when the Hopfield network oscillates.

This is impossible in theory, I can prove it. In practice, our near-zero
threshold can cause the network to oscillate between equally good
solutions.

<rdar://problem/9720596>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134428 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
2b0f4abfbe1c651fe6bd233bf89373d276c535a8 05-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Tweak comment and debug output.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134412 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
736a0118b5384daa52b82dfb398ad980afdb7bb4 04-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Fix PR10244.

A split point inserted in a block with a landing pad successor may be
hoisted above the call to ensure that it dominates all successors. The
code that handles the rest of the basic block must take this into
account.

I am not including a test case, it would be very fragile. PR10244 comes
from building clang with exceptions enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134369 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
1a988004dba412deb5d6b8e93b955dfc837065f0 02-Jul-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Use a new strategy for preventing eviction loops in RAGreedy.

Every live range is assigned a cascade number the first time it is
involved in an eviction. As the evictor, it gets a new cascade number.
Every evictee is assigned the same cascade number as the evictor.

Eviction is prohibited if the evictor has a lower assigned cascade
number than the evictee.

This means that assigned cascade numbers are monotonically increasing
with every eviction, yet they are bounded by NextCascade which can only
be incremented by new live ranges. Thus, infinite loops cannot happen,
but eviction cascades can still be triggered by new live ranges as we
want.

Thanks to Andy for explaining this to me.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134303 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
87360f73ae205854f100ba5fb7eef7b90ac3bc27 30-Jun-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Reapply r134047 now that the world is ready for it.

This patch will sometimes choose live range split points next to
interference instead of always splitting next to a register point. That
means spill code can now appear almost anywhere, and it was necessary
to fix code that didn't expect that.

The difficult places were:

- Between a CALL returning a value on the x87 stack and the
corresponding FpPOP_RETVAL (was FpGET_ST0). Probably also near x87
inline assembly, but that didn't actually show up in testing.

- Between a CALL popping arguments off the stack and the corresponding
ADJCALLSTACKUP.

Both are fixed now. The only place spill code can't appear is after
terminators, see SplitAnalysis::getLastSplitPoint.

Original commit message:

Rewrite RAGreedy::splitAroundRegion, now with cool ASCII art.

This function has to deal with a lot of special cases, and the old
version got it wrong sometimes. In particular, it would sometimes leave
multiple uses in the stack interval in a single block. That causes bad
code with multiple reloads in the same basic block.

The new version handles block entry and exit in a single pass. It first
eliminates all the easy cases, and then goes on to create a local
interval for the blocks with difficult interference. Previously, we
would only create the local interval for completely isolated blocks.

It can happen that the stack interval becomes completely empty because
we could allocate a register in all edge bundles, and the new local
intervals deal with the interference. The empty stack interval is
harmless, but we need to remove a SplitKit assertion that checks for
empty intervals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134125 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
2c0cbce763a258ac58590a8ca3c28ff722093fef 29-Jun-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Revert r134047 while investigating a llvm-gcc-i386-linux-selfhost
miscompile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134053 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
4d517e34e5c8431adb724c94a14b02362a9cfe67 29-Jun-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Rewrite RAGreedy::splitAroundRegion, now with cool ASCII art.

This function has to deal with a lot of special cases, and the old
version got it wrong sometimes. In particular, it would sometimes leave
multiple uses in the stack interval in a single block. That causes bad
code with multiple reloads in the same basic block.

The new version handles block entry and exit in a single pass. It first
eliminates all the easy cases, and then goes on to create a local
interval for the blocks with difficult interference. Previously, we
would only create the local interval for completely isolated blocks.

It can happen that the stack interval becomes completely empty because
we could allocate a register in all edge bundles, and the new local
intervals deal with the interference. The empty stack interval is
harmless, but we need to remove a SplitKit assertion that checks for
empty intervals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134047 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
5b220213bfe9c37c2bb41a7ae0804e06a14f1007 27-Jun-2011 Rafael Espindola <rafael.espindola@gmail.com> There is only one register coalescer. Merge it into the base class and
remove the analysis group.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133899 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
fdf16ca44f130afe80c57481d0c08130aa08cc09 26-Jun-2011 Rafael Espindola <rafael.espindola@gmail.com> Move RegisterCoalescer.h to lib/CodeGen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133895 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b3e705f88987608d4eb49668dac0e235d04df884 07-Jun-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Simplify local live range splitting's safeguard to fix PR10070.

When local live range splitting creates a live range with the same
number of instructions as the old range, mark it as RS_Local. When such
a range is seen again, require that it be split in a way that reduces
the number of instructions. That guarantees we are making progress while
still being able to perform 3 -> 2+3 splits as required by PR10070.

This also means that the PrevSlot map is no longer needed. This was also
used to estimate new spill weights, but that is no longer necessary
after slotIndexes::insertMachineInstrInMaps() got the extra Late
insertion argument.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132697 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
5f2316a3b55f88dab2190212210770180a32aa95 03-Jun-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Switch AllocationOrder to using RegisterClassInfo instead of a BitVector
of reserved registers.

Use RegisterClassInfo in RABasic as well. This slightly changes som
allocation orders because RegisterClassInfo puts CSR aliases last.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132581 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
76395c9a31444fa86514473e0852cdd67752d0e8 01-Jun-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Revert r132358 "Simplify the eviction policy by making the failsafe explicit."

This commit caused regressions in i386 flops-[568], matrix, salsa20,
256.bzip2, and enc-md5.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132413 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d2056e51c662765f98413fa071afbff53d87b384 31-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Simplify the eviction policy by making the failsafe explicit.

When assigned ranges are evicted, they are put in the RS_Evicted stage and are
not allowed to evict anything else. That prevents looping automatically.

When evicting ranges just to get a cheaper register, use only spill weights to
find the possible candidates. Avoid breaking hints for this purpose, it is not
worth it.

Start implementing more complex eviction heuristics, guarded by the temporary
-complex-eviction flag. The initial version permits a heavier range to be
evicted if it doesn't have any uses where the evicting range is live. This makes
it a good candidate for live ranfge splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132358 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
a2e79ef908e0f4179cda9e85e2f75057181bf321 30-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Reapply r132245 with a fix for the bug that broke the darwin9/i386 build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132309 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
626d6fb1903e74337b257c5e165944bcd1273e65 29-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Revert r132245, "Create two BlockInfo entries when a live range is discontinuous through a block."

This commit seems to have broken a darwin 9 tester.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132299 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
c9cf9e94ec4daca659e2eb4e30d3f7d7f9b6b067 28-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Create two BlockInfo entries when a live range is discontinuous through a block.

Delete the Kill and Def markers in BlockInfo. They are no longer
necessary when BlockInfo describes a continuous live range.

This only affects the relatively rare kind of basic block where a live
range looks like this:

|---x o---|

Now live range splitting can pretend that it is looking at two blocks:

|---x
o---|

This allows the code to be simplified a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132245 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b2abfa0bf30edf292a27a06e091d03983e644c9b 28-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add SplitAnalysis::getNumLiveBlocks().

It is important that this function returns the same number of live blocks as
countLiveBlocks(CurLI) because live range splitting uses the number of live
blocks to ensure it is making progress.

This is in preparation of supporting duplicate UseBlock entries for basic blocks
that have a virtual register live-in and live-out, but not live-though.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132244 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b8d936bc179ddf31b6350015d74900b74db6b450 26-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add a RAGreedy::canEvict function.

This doesn't change functionality (much), but it allows for a more fine-grained
eviction policy. The current policy only compares spill weights, and that is not
always the best thing to do. Spill weights are designed to serve linear scan,
and they don't consider live range splitting.

Add a mechanism so canEvict() can request that a live range be evicted and
split/spilled. This is to avoid infinite eviction loops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132101 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
bdda37d7fbafe6876f248341837423a4100f95a5 10-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Fix PR9883. Make sure all caches are invalidated when a live range is repaired.

The previous invalidation missed the alias interference caches.

Also add a stats counter for the number of repaired ranges.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131133 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
bf4e10f2f69db24c107cb61d6fe10ed5b2047374 06-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Emit a proper error message when register allocators run out of registers.

This can't be just an assertion, users can always write impossible inline
assembly. Such an assembly statement should be included in the error message.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131024 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
f42b66169d75301346e3685fd2b3e45e47806367 06-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Update LiveDebugVariables after live range splitting.

After a virtual register is split, update any debug user variables that resided
in the old register. This ensures that the LiveDebugVariables are still correct
after register allocation.

This may create DBG_VALUE instructions that place a user variable in a register
in parts of the function and in a stack slot in other parts. DwarfDebug
currently doesn't support that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130998 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
7d6b6a05b549da70b4473f015c97954c2a422724 03-May-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Gracefully handle invalid live ranges. Fix PR9831.

Register coalescing can sometimes create live ranges that end in the middle of a
basic block without any killing instruction. When SplitKit detects this, it will
repair the live range by shrinking it to its uses.

Live range splitting also needs to know about this. When the range shrinks so
much that it becomes allocatable, live range splitting fails because it can't
find a good split point. It is paranoid about making progress, so an allocatable
range is considered an error.

The coalescer should really not be creating these bad live ranges. They appear
when coalescing dead copies.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130787 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
66446c803a11a26e4bb39b74091d146ac850ae4c 30-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Use hysteresis for local live range splitting as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130596 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
9f4b893b84d9c2b56aa2abc3c96ce1e5ccc465e5 27-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add a safe-guard against repeated splitting for some rare cases.

The number of blocks covered by a live range must be strictly decreasing when
splitting, otherwise we can't allow repeated splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130249 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
200729882a47535d4c2496283d26600171531fad 23-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Always compare the cost of region splitting with the cost of per-block splitting.

Sometimes it is better to split per block, and we missed those cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130025 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
5928046306d8bbe7db35707c294689f515f90e56 21-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Allow allocatable ranges from global live range splitting to be split again.

These intervals are allocatable immediately after splitting, but they may be
evicted because of later splitting. This is rare, but when it happens they
should be split again.

The remainder intervals that cannot be allocated after splitting still move
directly to spilling.

SplitEditor::finish can optionally provide a mapping from new live intervals
back to the original interval indexes returned by openIntv().

Each original interval index can map to multiple new intervals after connected
components have been separated. Dead code elimination may also add existing
intervals to the list.

The reverse mapping allows the SplitEditor client to treat the new intervals
differently depending on the split region they came from.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129925 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
6bfba2e5af163442a1c6b11fe14aa9df9101cfd7 20-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Prefer cheap registers for busy live ranges.

On the x86-64 and thumb2 targets, some registers are more expensive to encode
than others in the same register class.

Add a CostPerUse field to the TableGen register description, and make it
available from TRI->getCostPerUse. This represents the cost of a REX prefix or a
32-bit instruction encoding required by choosing a high register.

Teach the greedy register allocator to prefer cheap registers for busy live
ranges (as indicated by spill weight).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129864 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
fd1cced726469e83915f428877a521ba737d35f3 13-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Stop using dead function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129442 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
5db4289e404d76664f8aabe2675a4cc2d7b0e98e 12-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> SparseBitVector is SLOW.

Use a Bitvector instead, we didn't need the smaller memory footprint anyway.
This makes the greedy register allocator 10% faster.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129390 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
fd5c51342a429ecab86a645282d0b36b216c0256 12-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Create new intervals for isolated blocks during region splitting.

This merges the behavior of splitSingleBlocks into splitAroundRegion, so the
RS_Region and RS_Block register stages can be coalesced. That means the leftover
intervals after region splitting go directly to spilling instead of a second
pass of per-block splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129379 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
3f5bedf5cbde2cc2badc86b1a0b377f6efcde71c 11-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Speed up eviction by stopping collectInterferingVRegs as soon as the spill
weight limit has been exceeded.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129305 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
f4afdfc501b7185d24a0ef184fe3d0c0bbe22e0c 09-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Build the Hopfield network incrementally when splitting global live ranges.

It is common for large live ranges to have few basic blocks with register uses
and many live-through blocks without any uses. This approach grows the Hopfield
network incrementally around the use blocks, completely avoiding checking
interference for some through blocks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129188 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
7b41fbe87234f3ceef6ae11209730cbed4b69092 07-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Extract SpillPlacement::addLinks for handling the special transparent blocks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129079 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
9a54352879e5aaac2e2c37490e5cb7844550db8b 06-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Also account for the spill code that would be inserted in live-through blocks with interference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129030 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
1b400e840f58489c7950f815780cf08917cecaa8 06-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Abort the constraint calculation early when all positive bias is lost.

Without any positive bias, there is nothing for the spill placer to to. It will
spill everywhere.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129029 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
70d4370b47cdd375bbea98e50452789fe4f1af04 06-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Keep track of the number of positively biased nodes when adding constraints.

If there are no positive nodes, the algorithm can be aborted early.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129021 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
9efa2a263ea470caacef1c85f6ca45e32bf516d3 06-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Break the spill placement algorithm into three parts: prepare, addConstraints, and finish.

This will allow us to abort the algorithm early if it is determined to be futile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129020 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
49460bc49990ddfcf81e6f0670924f896645d9c7 06-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Oops. Scary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128986 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
db529a8a5d071610f3a8b467693bc40b073e68ef 06-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Analyze blocks with uses separately from live-through blocks without uses.

About 90% of the relevant blocks are live-through without uses, and the only
information required about them is their number. This saves memory and enables
later optimizations that need to look at only the use-blocks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128985 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
cfafc54040cc9722995558124f253d05a038176b 05-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Run LiveDebugVariables in RegAllocBasic and RegAllocGreedy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128935 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
612f7807c581eafb7c8105e1a55c8d839033bfb3 05-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Stop precomputing last split points, query the SplitAnalysis cache on demand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128875 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
6c8afd728eb02742ce320ecd39bcf3774d8423b7 04-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Stop caching basic block index ranges now that SlotIndexes can keep up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128821 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
eda0fe8d58b0aaff5f18e7f13edfda3022384e70 02-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Use InterferenceCache in RegAllocGreedy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128765 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
5907d863659eb972ebb2afe07bc863a4c616f0ef 02-Apr-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add an InterferenceCache class for caching per-block interference ranges.

When the greedy register allocator is splitting multiple global live ranges, it
tends to look at the same interference data many times. The InterferenceCache
class caches queries for unaltered LiveIntervalUnions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128764 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
f22ca3fe5f0cfbb832cf41270f97cf5c0134fd7b 30-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Treat clones the same as their origin.

When DCE clones a live range because it separates into connected components,
make sure that the clones enter the same register allocator stage as the
register they were cloned from.

For instance, clones may be split even when they where created during spilling.
Other registers created during spilling are not candidates for splitting or even
(re-)spilling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128524 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
6094bd87d845afabba5b99ec4848fa6116bac682 29-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Recompute register class and hint for registers created during spilling.

The spill weight is not recomputed for an unspillable register - it stays infinite.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128490 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
eb29157d80847c207b77910bcd40a6a6c91ca5c5 28-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Drop interference reassignment in favor of eviction.

The reassignment phase was able to move interference with a higher spill weight,
but it didn't happen very often and it was fairly expensive.

The existing interference eviction picks up the slack.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128397 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
c1655e1a3c3a566b91b0513b56d61b58da1e36ba 20-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add debug output.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127959 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
1d5b84508173b93faf513032b3847152e6060791 16-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add a LiveRangeEdit delegate callback before shrinking a live range.

The register allocator needs to adjust its live interval unions when that happens.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127774 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
c46570dc05851395829bef904bb6ddb1260400d1 16-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Clarify debugging output.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127771 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
7792e980c43536814ea42448db9799b4da32fef6 13-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Tell the register allocator about new unused virtual registers.

This allows the allocator to free any resources used by the virtual register,
including physical register assignments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127560 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
47dbf6cef761c25cfeb0aa7d624a6f98288bb96a 10-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Change the Spiller interface to take a LiveRangeEdit reference.

This makes it possible to register delegates and get callbacks when the spiller
edits live ranges.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127389 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
38f6bd0fc8095ef79a89b3db15ff6dc734ac90e7 10-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Make SpillIs an optional pointer. Avoid creating a bunch of temporary SmallVectors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127388 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
92a55f4bdd120cdd3bb5a004c792d4d24a940311 09-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add a LiveRangeEdit::Delegate protocol.

This will we used for keeping register allocator data structures up to date
while LiveRangeEdit is trimming live intervals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127300 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
1973b3e2541f95c87e4acb7e134362ff306ec9ed 07-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Make the UselessRegs argument optional in the LiveRangeEdit constructor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127181 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
874be74179b087be36a6e7869f3aa8b70732aca1 05-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Rework the global split cost calculation.

The global cost is the sum of block frequencies for spill code that must be
inserted because preferences weren't met.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127062 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
96dcd95a45968de6cb05864cf91aae33169cf179 05-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Compute the constraints for global live range splitting from an interference pattern.

This simplifies the code and makes it faster too.

The interference patterns are saved for each candidate register. It will be
reused for actually executing the split. Work in progress.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127054 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
8b6a933498299773243a6b4e05513d6dc11e4d32 04-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Extract a method. No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127040 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d17924b1bd0329acb8be2d7dfc5fc4434c24b832 04-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Go back to comparing spill weights when deciding if interference can be evicted.

It gives better results. Sometimes, a live range can be large and still have
high spill weight. Such a range should not be spilled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127036 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
fb69810a2b617d888b6ea7c6a69fee7364fe233b 04-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Tweak debug output. No functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127006 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
40a42a2ccaaa19a109667ed7abf224cc8733cd9c 04-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Precompute block frequencies, pow() isn't free.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126975 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
36d61863bc83bd2301e0224adc560098b35ec0dc 03-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Cache basic block bounds instead of asking SlotIndexes::getMBBRange all the time.

This speeds up the greedy register allocator by 15%.
DenseMap is not as fast as one might hope.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126921 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
bece06f0c6936527e2b1c72d09f7d3a949af9a47 03-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Change the SplitEditor interface to a single instance can be shared for multiple splits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126912 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
1841d14eff2b30a28c8fe951e27da13ec63417e2 02-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Drop RAGreedy::trySpillInterferences().

This is a waste of time since we already know how to evict all interferences
which is a better approach anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126798 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
22a1df6bf24c188dd637a0bb2cf9a2648806b6b1 01-Mar-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Keep track of which stage produced a live range, and bypass earlier stages when revisiting.

This effectively disables the 'turbo' functionality of the greedy register
allocator where all new live ranges created by splitting would be reconsidered
as if they were originals.

There are two reasons for doing this, 1. It guarantees that the algorithm
terminates. Early versions were prone to infinite looping in certain corner
cases. 2. It is a 2x speedup. We can skip a lot of unnecessary interference
checks that won't lead to good splitting anyway.

The problem is that region splitting only gets one shot, so it should probably
be changed to target multiple physical registers at once.

Local live range splitting is still 'turbo' enabled. It only accounts for a
small fraction of compile time, so it is probably not necessary to do anything
about that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126781 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
57f1e2cee06f9b57995727d786aeb1031c5376bd 25-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Try harder to get the hint by preferring to evict hint interference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126463 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
107d366df762c18294dc00f5de916f62672353ff 25-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Tweak the register allocator priority queue some more.

New live ranges are assigned in long -> short order, but live ranges that have
been evicted at least once are deferred and assigned in short -> long order.

Also disable splitting and spilling for live ranges seen for the first time.

The intention is to create a realistic interference pattern from the heavy live
ranges before starting splitting and spilling around it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126451 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d2a50734234a80893ad71da90d9f32032c47e000 23-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Keep track of how many times a live range has been dequeued, and prioritize new ranges.

When a large live range is evicted, it will usually be split when it comes
around again. By deferring evicted live ranges, the splitting happens at a time
when the interference pattern is more realistic. This prevents repeated
splitting and evictions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126282 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
417df0129146e299e9fd273becab824887c384e9 23-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Fix a bug in determining if there is only a single interfering register.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126277 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
98c8141b6d8fcbb9bd258ebcdd4171f55c5a8e9d 23-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Be more aggressive about evicting interference.

Use interval sizes instead of spill weights to determine if it is legal to evict
interference. A smaller interval can evict interference if all interfering live
ranges are larger.

Allow multiple interferences to be evicted as along as they are all larger than
the live range being allocated.

Spill weights are still used to select the preferred eviction candidate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126276 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
98d9648de7d571b2e6d139b65961a70d1833b0d7 23-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Change the RAGreedy register assignment order so large live ranges are allocated first.

This is based on the observation that long live ranges are more difficult to
allocate, so there is a better chance of solving the puzzle by handling the big
pieces first. The allocator will evict and split long alive ranges when they get
in the way.

RABasic is still using spill weights for its priority queue, so the interface to
the queue has been virtualized.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126259 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
06c0f25499fd502668ca720b0fea4a4dfe6eb44a 22-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add SplitKit::isOriginalEndpoint and use it to force live range splitting to terminate.

An original endpoint is an instruction that killed or defined the original live
range before any live ranges were split.

When splitting global live ranges, avoid creating local live ranges without any
original endpoints. We may still create global live ranges without original
endpoints, but such a range won't be split again, and live range splitting still
terminates.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126151 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
1b847deb26b52051de39f4cbecd224c9fbd0d1c2 19-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Give SplitAnalysis a VRM member to access VirtRegMap::getOriginal().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126005 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
a2ebf60ef2c434428af7f810b13327ab50245a67 19-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Separate timers for local and global splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126001 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
ba05c01dabc40373760a20c874103fc58d4377f0 18-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add VirtRegMap::rewrite() and use it in the new register allocators.

The rewriter works almost identically to -rewriter=trivial, except it also
eliminates any identity copies.

This makes the new register allocators independent of VirtRegRewriter.cpp which
will be going away at the same time as RegAllocLinearScan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125967 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
0db841f9c2b9a25fb5ecb36e350d3a802c35654c 17-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add basic register allocator statistics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125789 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
034a80d065358b412cdd270e08fb6f1986e65e50 17-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Split local live ranges.

A local live range is live in a single basic block. If such a range fails to
allocate, try to find a sub-range that would get a larger spill weight than its
interference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125764 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
23cd57c29926189ad9d7b2b208024645870884ad 10-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Simplify using the new leaveIntvBefore()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125238 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
f0ac26c51173a9a1d6e5b5794107dccc4c5b5792 09-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Move calcLiveBlockInfo() and the BlockInfo struct into SplitAnalysis.

No functional changes intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125231 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
2710638db2eb84cd7eefb8bb9a1b7e5c49413d45 09-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Evict a lighter single interference before attempting to split a live range.

Registers are not allocated strictly in spill weight order when live range
splitting and spilling has created new shorter intervals with higher spill
weights.

When one of the new heavy intervals conflicts with a single lighter interval,
simply evict the old interval instead of trying to split the heavy one.

The lighter interval is a better candidate for splitting, it has a smaller use
density.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125151 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
8a2bbdeee24b40da6187199658646d04329c139e 09-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Fix one more case of splitting after the last split point.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125137 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
a50c539b7a9e74597da34bfaea5429a48481f18b 09-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Reorganize interference code to check LastSplitPoint first.

The last split point can be anywhere in the block, so it interferes with the
strictly monotonic requirements of advanceTo().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125132 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d08d77318a095c5f85c077899caa3594a7767113 08-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Also handle the situation where an indirect branch is the first (and last)
instruction in a basic block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125116 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
8a61da8a689ee95874c833af4c7aa965fab5c0a9 08-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add LiveIntervals::addKillFlags() to recompute kill flags after register allocation.

This is a lot easier than trying to get kill flags right during live range
splitting and rematerialization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125113 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
124e423ccec42e54a8b069e1c2ef9adfaa1e553a 08-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Trim debug spew

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125109 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
5c716bdccce2fa504e1aa0b67226165d181d2459 08-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add SplitEditor::overlapIntv() to create small ranges where both registers are live.

If a live range is used by a terminator instruction, and that live range needs
to leave the block on the stack or in a different register, it can be necessary
to have both sides of the split live at the terminator instruction.

Example:

%vreg2 = COPY %vreg1
JMP %vreg1

Becomes after spilling %vreg2:

SPILL %vreg1
JMP %vreg1

The spill doesn't kill the register as is normally the case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125102 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
fe3f99f95c7c9ceaac3ceebbea31e40cfbc157e3 05-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Be more strict about the first/last interference-free use.

If the interference overlaps the instruction, we cannot separate it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124918 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
de71095a1a930eee81696d5770cdce46d3e19a61 05-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add assertions to verify that the new interval is clear of the interference.

If these inequalities don't hold, we are creating a live range split that won't
allocate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124917 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
63935420ef1c323b9d9276eadc0ab74ee86a25b5 04-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Be more accurate about live range splitting at the end of blocks.

If interference reaches the last split point, it is effectively live out and
should be marked as 'MustSpill'.

This can make a difference when the terminator uses a register. There is no way
that register can be reused in the outgoing CFG bundle, even if it isn't live
out.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124900 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
9b3d24bf3d4663bfaf98eb97a94081e07a3f62da 04-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Verify that one of the ranges produced by region splitting is allocatable.

We should not be attempting a region split if it won't lead to at least one
directly allocatable interval. That could cause infinite splitting loops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124893 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
45139874a776f4fad581fc3ef81ab77b34b4f593 04-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Also compute interference intervals for blocks with no uses.

When the live range is live through a block that doesn't use the register, but
that has interference, region splitting wants to split at the top and bottom of
the basic block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124839 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
2dfbb3e9125aa0a66feab7a7638815b57da85968 03-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Ensure that the computed interference intervals actually overlap their basic blocks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124815 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
207c868c9210663d401b7f5ce5cae7c3e0943849 03-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Return live range end points from SplitEditor::enter*/leave*.

These end points come from the inserted copies, and can be passed directly to
useIntv. This simplifies the coloring code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124799 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
0f43811903f10394f7088f4634c0b4f9668cbac0 03-Feb-2011 Eric Christopher <echristo@apple.com> Reapply this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124779 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
463a2977b1d9e6679f859db9f32e9e783b075c10 03-Feb-2011 Eric Christopher <echristo@apple.com> Temporarily revert 124765 in an attempt to find the cycle breaking bootstrap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124778 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
2cd21119593becfa1962cfaca0319fd67913f545 03-Feb-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Defer SplitKit value mapping until all defs are available.

The greedy register allocator revealed some problems with the value mapping in
SplitKit. We would sometimes start mapping values before all defs were known,
and that could change a value from a simple 1-1 mapping to a multi-def mapping
that requires ssa update.

The new approach collects all defs and register assignments first without
filling in any live intervals. Only when finish() is called, do we compute
liveness and mapped values. At this time we know with certainty which values map
to multiple values in a split range.

This also has the advantage that we can compute live ranges based on the
remaining uses after rematerializing at split points.

The current implementation has many opportunities for compile time optimization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124765 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
c0de99571297720a37ae405c77fb2ef4aaf00ccd 20-Jan-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> SplitKit requires that all defs are in place before calling useIntv().

The value mapping gets confused about which original values have multiple new
definitions so they may need phi insertions.

This could probably be simplified by letting enterIntvBefore() take a live range
to be added following the instruction. As long as the range stays inside the
same basic block, value mapping shouldn't be a problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123926 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
92e6939d29d206b5f094e0dcc4febf909f77a134 20-Jan-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Don't accidentally leave small gaps in the live ranges when leaving the active
interval after an instruction. The leaveIntvAfter() method only adds liveness
from the instruction's boundary index to the inserted copy.

Ideally, SplitKit should be smarter about this, perhaps by combining useIntv()
and leaveIntvAfter() into one method that guarantees continuity.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123858 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
ccdb3fcef9aeb9f683cd738afbe1cd961bb0c1ef 19-Jan-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Implement RAGreedy::splitAroundRegion and remove loop splitting.

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
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b5fa9333431673aac2ced8dea80152349a85cf6f 18-Jan-2011 Jakob Stoklund Olesen <stoklund@2pi.dk> Add RAGreedy methods for splitting live ranges around regions.

Analyze the live range's behavior entering and leaving basic blocks. Compute an
interference pattern for each allocation candidate, and use SpillPlacement to
find an optimal region where that register can be live.

This code is still not enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123774 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
2aea490e163b53e966d693285c17c1a934db5e8d 28-Dec-2010 Duncan Sands <baldrick@free.fr> Pacify the compiler. BestWeight cannot in fact be used uninitialized
in this function, but the compiler was warning that it might be when
doing a release build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122595 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
770d42de3b7643b2b4f835f32e3a16275b9fbdba 22-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> When RegAllocGreedy decides to spill the interferences of the current register,
pick the victim with the lowest total spill weight.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122445 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
87c6d25c71b028695641642d86d0cf4a3ff22096 18-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Tweak debug spew.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122132 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
bb1744ec1531fff3fd22fdfcd65f0f72d99c4fa5 18-Dec-2010 Nick Lewycky <nicholas@mxc.ca> Fix GCC warning:
lib/CodeGen/RegAllocGreedy.cpp:311: error: unused variable 'PhysReg' [-Wunused-variable]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122122 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
89cab93fe999f6d81b4b99a71ac797b7ecfec277 18-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Pass a Banner argument to the machine code verifier both from
createMachineVerifierPass and MachineFunction::verify.

The banner is printed before the machine code dump, just like the printer pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122113 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
af24964251e27c2dd863239ba66ffd967b593be5 18-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Make the -verify-regalloc command line option available to base classes as
RegAllocBase::VerifyEnabled.

Run the machine code verifier in a few interesting places during RegAllocGreedy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122107 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
f428eb6c1b09a2322b7a577b0bf2e49dd107bcea 18-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Enable loop splitting in RegAllocGreedy.

The heuristics split around the largest loop where the current register may be
allocated without interference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122106 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d0bb5e2ca05d9c942223bf05e5940bb0c6cc9d3f 16-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Start using SplitKit and MachineLoopRanges in RegAllocGreedy in preparation of
live range splitting around loops guided by register pressure.

So far, trySplit() simply prints a lot of debug output.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121918 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
257c556d85ba949a1ccff99cd7d1e58417aa6e33 15-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Simplify RegAllocGreedy's use of register aliases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121807 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
3ef9f3da397d27e2340742274a7f6e8b8f1149cf 14-Dec-2010 Matt Beaumont-Gay <matthewbg@google.com> Move debugging code entirely within DEBUG(). Silences an unused variable
warning in the opt build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121791 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
bfce678de7b509a497ac6d91f29e749adab7e40c 14-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Add LiveIntervalUnion print methods, RegAllocGreedy::trySplit debug spew.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121783 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d84de8cf62991597c15e948ecb121ad0233ba4ec 14-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Q.seenAllInterferences() must be called after Q.collectInterferingVRegs().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121774 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
885b3283eacb01bf281245ed0c19ae8ccca1fc8a 14-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Remove unused vector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121741 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
46c83c80c5737743c955ff007fa6409804a7abf0 14-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Try reassigning all virtual register interferences, not just those with lower
spill weight. Filter out fixed registers instead.

Add support for reassigning an interference that was assigned to an alias.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121737 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b64d92e29f38002e52a22fe36ea2d488968e3537 14-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Add stub for RAGreedy::trySplit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121736 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
533f58ecdd8a4732c2f0e149387c4d8d8d4142de 11-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Add named timer groups for the different stages of register allocation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121604 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
4680dec5fb3a1b624f13ca9b2a555ca90a07973e 11-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Move MRI into RegAllocBase. Clean up debug output a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121599 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
a0bb037283341912c680cc9a82f3586c763345f9 11-Dec-2010 Nick Lewycky <nicholas@mxc.ca> Remove extraneous close parenthesis.
Fix build breakage.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121596 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
5a4308bca86728767ea5d9e5df8d8e3351e33c9a 11-Dec-2010 Nick Lewycky <nicholas@mxc.ca> Move variable that's unused in an NDEBUG build inside the DEBUG() macro, fixing
lib/CodeGen/RegAllocGreedy.cpp:233: error: unused variable 'TRC' [-Wunused-variable]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121594 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
f6dff84d4e44d6c4a46c4f8a18e13c78f804547c 10-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Force the greedy register allocator to always use the inline spiller.

Soon, RegAllocGreedy will start splitting live ranges, and then deferred
spilling won't work anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121591 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
dd479e9769eceee9fcc34e2173376024f3aa3c5f 10-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Use AllocationOrder in RegAllocGreedy, fix a bug in the hint calculation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121584 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
6ce219ec64088fc4ee550afbb6cd30621fbba27e 10-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Fix miscompilation caused by trivial logic error in the reassignVReg()
interference check.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121519 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
ff092faffb85410b0013fb70bc991bb98b5663a5 09-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Remember to filter out reserved rergisters from the allocation order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121411 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
b853e6c3702149cdbbd6fa404334e3ba0055641a 09-Dec-2010 Andrew Trick <atrick@apple.com> Added register reassignment prototype to RAGreedy. It's a simple
heuristic to reshuffle register assignments when we can't find an
available reg.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121388 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
9b0c4f8af3e303c85ddb5ff0ee2c8e27a4d77203 09-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Properly deal with empty intervals when checking for interference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121319 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
90c1d7ddfc65654f7efe72d56cad65d1af9e6b2a 08-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Implement very primitive hinting support in RegAllocGreedy.

The hint is simply tried first and then forgotten if it couldn't be allocated
immediately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121306 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
d0bec3e62c98b1f0ef3a41db8f95599b2014c131 08-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Store (priority,regnum) pairs in the priority queue instead of providing an
abstract priority queue interface in subclasses that want to override the
priority calculations.

Subclasses must provide a getPriority() implementation instead.

This approach requires less code as long as priorities are expressable as simple
floats, and it avoids the dangers of defining potentially expensive priority
comparison functions.

It also should speed up priority_queue operations since they no longer have to
chase pointers when comparing registers. This is not measurable, though.

Preferably, we shouldn't use floats to guide code generation. The use of floats
here is derived from the use of floats for spill weights. Spill weights have a
dynamic range that doesn't lend itself easily to a fixpoint implementation.

When someone invents a stable spill weight representation, it can be reused for
allocation priorities.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121294 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
753936602ef6c5e97aba29e89606087b51a6c886 08-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Trim includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121283 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp
cba2e06d525b723849cd8e1f083eb1e59a494b4e 08-Dec-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Stub out RegAllocGreedy.

This new register allocator is initially identical to RegAllocBasic, but it will
receive all of the tricks that RegAllocBasic won't get.

RegAllocGreedy will eventually replace linear scan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121234 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/CodeGen/RegAllocGreedy.cpp