This is an archive of the discontinued LLVM Phabricator instance.

[StatepointLowering] Don't create temporary instructions. NFCI.
ClosedPublic

Authored by sanjoy on May 4 2015, 10:43 AM.

Details

Summary

Instead of creating a temporary call instruction and lowering that, use
SelectionDAGBuilder::lowerCallOperands.

Diff Detail

Repository
rL LLVM

Event Timeline

sanjoy updated this revision to Diff 24895.May 4 2015, 10:43 AM
sanjoy retitled this revision from to [StatepointLowering] Don't create temporary instructions. NFCI..
sanjoy updated this object.
sanjoy edited the test plan for this revision. (Show Details)
sanjoy added a reviewer: reames.
sanjoy added a subscriber: Unknown Object (MLST).
reames requested changes to this revision.May 5 2015, 3:30 PM
reames edited edge metadata.

Meta comment: I can't tell if this code is wrong, but it's not obviously correct. Your mixing renames, code motion, and restructuring unnecessarily. This makes it much harder to review for correctness.

lib/CodeGen/SelectionDAG/StatepointLowering.cpp
225 ↗(On Diff #24895)

To simplify review, please place the new code into the same helper. (I think the helper should be there regardless, but it also reduces the diff.)

526 ↗(On Diff #24895)

This block looks like code which could and should be commoned into a helper function for statepoints and patchpoints. possible: findCallNode?

537 ↗(On Diff #24895)

I would prefer the glue node changes go in separately. You do not need further review for them, but they're unrelated to the tricky part of this review and should be separated.

571 ↗(On Diff #24895)

Use getGluedNode please.

580 ↗(On Diff #24895)

You're missing a check on whether the underlying call produces a value.

591 ↗(On Diff #24895)

I'm pretty sure using the entry point of the chain here is wrong. I don't understand the motivation for this change. Can you please separate or revert this part?

This revision now requires changes to proceed.May 5 2015, 3:30 PM
sanjoy added inline comments.May 5 2015, 3:46 PM
lib/CodeGen/SelectionDAG/StatepointLowering.cpp
225 ↗(On Diff #24895)

will do.

526 ↗(On Diff #24895)

I'll do that once this is in, if you're okay with that.

537 ↗(On Diff #24895)

Will do.

571 ↗(On Diff #24895)

Sure.

580 ↗(On Diff #24895)

Yes. I wonder why this didn't break any tests.

591 ↗(On Diff #24895)

The node copying the return value to a virtual register has a data dependence on the call, and it can thus be scheduled anywhere after the call and before the terminator instruction, but otherwise has no control dependencies. Adding it to PendingExports takes care of the latter.

SelectionDAGBuilder::CopyValueToVirtualRegister does the same thing.

sanjoy updated this revision to Diff 24996.May 5 2015, 5:03 PM
sanjoy edited edge metadata.

This reduces the non-semantic noise in the change by keeping most of
the tricky parts of the change inside lowerCallFromStatepoint.

reames added a comment.May 5 2015, 5:43 PM

LGTM w/the requirement that you write a test which would have failed with your previous version and include it with the submission.

lib/CodeGen/SelectionDAG/StatepointLowering.cpp
281 ↗(On Diff #24996)

I would prefer you kept this comment in the new code. I regularly use it to remind myself what's going on here.

reames accepted this revision.May 5 2015, 5:44 PM
reames edited edge metadata.
This revision is now accepted and ready to land.May 5 2015, 5:44 PM
This revision was automatically updated to reflect the committed changes.
pgavlin added inline comments.
llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
277

Can SelectionDAGBuilder::removeValue be removed now that this code no longer uses it? AFAICT this is the only user of that method (indeed, a comment inside that method indicates as much).