This is an archive of the discontinued LLVM Phabricator instance.

[GreedyRA] Add support for invoke statepoint with tied-defs.
ClosedPublic

Authored by skatkov on Apr 23 2021, 3:11 AM.

Details

Summary
statepoint instruction uses tied-def registers to represent live gc value which
is use and def at the same time on a call.
At the same time invoke statepoint instruction is a last split point which can throw and
jump to landing pad.
As a result we have instructon which is last split point with tied-defs registers and
we need to teach Greedy RA to work with it.

The option -use-registers-for-gc-values-in-landing-pad controls whether statepoint lowering
will generate tied-defs for invoke statepoint and is off by default now.

To resolve all issues the following changes has been done.
1) Last Split point for invoke statepoint should be statepoint itself

If statepoint has a def it is a relocated gc pointer and it should be available in landing pad.
So we cannot split interval after statepoint at end of basic block.

2) Do not split interval on tied-def

If end of interval for overlap utility is a use which has tied-def we
should not split interval on this instruction due to in this case use
and def may have different registers and it breaks tied-def property.

3) Take into account Last Split Point for enterIntvAtEnd

If the use after Last Split Point is a def so it should be tied-def and
we can take the def of the tied-use as ParentVNI and thus
tied-use and tied-def will be live in resulting interval.

4) Handle the case when def is after LIP in InlineSpiller

If def of LI is after last insertion point of basic block we cannot hoist in this BB.

The example of such instruction is invoke statepoint where def represents the
relocated live gc pointer. Invoke is a last insertion point and its def is located after it.
In this case there is no place to insert spill and we bail out.

5) Fix removeBackCopies to account empty copies

RegAssignMap cannot hold empty interval, so do not set stop
to kill value if it produces empty interval.

This can happen if we remove back-copy and right before that we have another
back-copy.

For example, for parent %0 we can get
%1 = COPY %0
%2 = COPY %0
while we removing %2 we cannot set kill for %1 due to its empty.

6) Do not hoist copy to BB if its def is after LSP

If the parent def is a LastSplitPoint or later we cannot hoist copy to this basic block
because inserted copy (or re-materialization) will be located before the def.

All parts have been reviewed separately as follows:
https://reviews.llvm.org/D100747
https://reviews.llvm.org/D100748
https://reviews.llvm.org/D100750
https://reviews.llvm.org/D100927
https://reviews.llvm.org/D100945
https://reviews.llvm.org/D101028

Diff Detail

Event Timeline

skatkov created this revision.Apr 23 2021, 3:11 AM
skatkov requested review of this revision.Apr 23 2021, 3:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2021, 3:11 AM
skatkov updated this revision to Diff 341483.Apr 29 2021, 5:31 AM

Update tests.

skatkov updated this revision to Diff 342647.May 3 2021, 10:39 PM
skatkov edited the summary of this revision. (Show Details)
skatkov accepted this revision.May 4 2021, 9:13 PM

Accept basing on accept of all individual patches.

This revision is now accepted and ready to land.May 4 2021, 9:13 PM
This revision was landed with ongoing or failed builds.May 4 2021, 9:25 PM
This revision was automatically updated to reflect the committed changes.