[llvm-commits] [PATCH] Linear scan allocator

Krister Wombell kuwerty at gmail.com
Tue Dec 14 19:25:55 PST 2010


I've come across a bug in RALinScan::assignRegOrStackSlotAtInterval that
occurs when:

- an interval conflicts with all physical registers in it's class
- and one of the phys regs has a lower spill weight then the interval being
assigned
- and there are no active or inactive intervals (or no entries of an
overlapping reg class)

findIntervalsToSplit then runs but won't be able to find the best candidate
as it fails to find a anything suitable in the 'active_' or 'inactive_'
lists. The code asserts that there's nothing to spill.

It's a fairly obscure set of circumstances but can happen if there is a
register class with no callee saved registers and a call instruction (that
implicitly defines all registers in that class).  It (probably?) also
requires that the interval being assigned is itself the result of spilling
as both the spill weight needs to be quite high.

I've attached a fix that spills the current interval if findIntervalsToSplit
returns nothing.

e.g.
BB#1;  %reg16418 is a fresh interval resuting from a spill, no other
interval is active
... = ADD %reg16418  ; DTR:%reg16418  ; should remat here
CALL ... ; imp-def of all regs in DTR
... = SUB %reg16418  ; DTR:%reg16418  ; should remat here

Krister
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101215/081cc773/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linscan.patch
Type: text/x-patch
Size: 1965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101215/081cc773/attachment.bin>


More information about the llvm-commits mailing list