This is an archive of the discontinued LLVM Phabricator instance.

[StatepointLowering] Reuse stack slots across basic blocks
ClosedPublic

Authored by igor-laevsky on Jun 4 2015, 11:39 AM.

Details

Summary

During statepoint lowering we can sometimes avoid spilling of the value if we know that it was already spilled for previous statepoint.
We were doing this by checking if incoming statepoint value was lowered into load from stack slot. This was working only in boundaries of one basic block.

But instead of looking at the lowered node we can look directly at the llvm-ir value and if it was gc.relocate (or some simple modification of it) look up stack slot for it's derived pointer and reuse stack slot from it. This allows us to look across basic block boundaries.

Diff Detail

Repository
rL LLVM

Event Timeline

igor-laevsky retitled this revision from to [StatepointLowering] Reuse stack slots across basic blocks.
igor-laevsky updated this object.
igor-laevsky edited the test plan for this revision. (Show Details)
igor-laevsky added reviewers: reames, sanjoy.
igor-laevsky set the repository for this revision to rL LLVM.
igor-laevsky added a subscriber: Unknown Object (MLST).
sanjoy accepted this revision.Jun 8 2015, 11:46 PM
sanjoy edited edge metadata.

LGTM with comments.

lib/CodeGen/SelectionDAG/StatepointLowering.cpp
135 ↗(On Diff #27137)

When does this happen (derived pointer is not in SpillMap)?

141 ↗(On Diff #27137)

The { is redundant here.

Also, is it okay to look through addrspacecasts? Perhaps we should just look through bitcasts for now and later generalize if needed.

171 ↗(On Diff #27137)

Nit: Unfortunately

172 ↗(On Diff #27137)

Nit: completely

183 ↗(On Diff #27137)

Nit: careful

524 ↗(On Diff #27137)

The braces are now unnecessary.

This revision is now accepted and ready to land.Jun 8 2015, 11:46 PM

Thanks for the comments!

lib/CodeGen/SelectionDAG/StatepointLowering.cpp
135 ↗(On Diff #27137)

It could happen if we have not visited this statepoint. For example if we looking through the loop backedge.

141 ↗(On Diff #27137)

I would prefer to keep braces here, if you don't mind. They make this case more visually distinctive from other cases.

I think you right about addrspace casts, theirs semantic is target dependant and they could be lowered into complicated expressions. I'll fix this case to look only through bitcasts. Anyway they should be a most common case.

This revision was automatically updated to reflect the committed changes.