[CalcSpillWeights] Propagate the fact that a live-interval is not spillable
authorQuentin Colombet <qcolombet@apple.com>
Thu, 16 Jul 2020 00:26:37 +0000 (17:26 -0700)
committerQuentin Colombet <qcolombet@apple.com>
Thu, 16 Jul 2020 00:57:36 +0000 (17:57 -0700)
commit294be6b5d32e1fe44d0b36cd46b2931c5f0634c4
tree09a1b7f21ea8a50d264b4bbfddf04759936c68bb
parent76a0c0ee6ffa9c38485776921948d8f930109674
[CalcSpillWeights] Propagate the fact that a live-interval is not spillable

When we calculate the weight of a live-interval, add some code to
check if the original live-interval was markied as not spillable and
if so, progagate that information down to the new interval.

Previously we would just recompute a weight for the new interval,
thus, we could in theory just spill live-intervals marked as not
spillable by just splitting them. That goes against the spirit of
a non-spillable live-interval.

E.g., previously we could do:
v1 =  // v1 must not be spilled
...
= v1

Split:
v1 = // v1 must not be spilled
...
v2 = v1 // v2 can be spilled
...
v3 = v2 // v3 can be spilled
= v3

There's no test case for that one as we would need to split a
non-spillable live-interval without using LiveRangeEdit to see this
happening.
RegAlloc inserts non-spillable intervals only as part of the spilling
mechanism, thus at this point the intervals are not splittable anymore.
On top of that, RegAlloc uses the LiveRangeEdit API, which already
properly propagate that information.

In other words, this could only happen if a target was to mark
a live-interval as not spillable before register allocation and
split it without using LRE, e.g., through
LiveIntervals::splitSeparateComponent.
llvm/lib/CodeGen/CalcSpillWeights.cpp