This is an archive of the discontinued LLVM Phabricator instance.

[RewriteStatepointsForGC] Use an actual liveness algorithm
ClosedPublic

Authored by reames on Mar 27 2015, 2:43 PM.

Details

Summary

When rewriting statepoints to make relocations explicit, we need to have a conservative but consistent notion of where a particular pointer is live at a particular site. The old code just used dominance, which is correct, but decidedly more conservative then it needed to be. This patch implements a simple dataflow algorithm that's run one per function (well, twice counting fixup after base pointer insertion). There's still lots of room to make this faster, but it's fast enough for all practical purposes today.

p.s. This patch was build on top of http://reviews.llvm.org/D8671 and might not apply cleanly without it.

Diff Detail

Event Timeline

reames updated this revision to Diff 22822.Mar 27 2015, 2:43 PM
reames retitled this revision from to [RewriteStatepointsForGC] Use an actual liveness algorithm.
reames updated this object.
reames edited the test plan for this revision. (Show Details)
reames added reviewers: sanjoy, swaroop.sridhar.
reames updated this object.
reames added a subscriber: Unknown Object (MLST).
reames edited the test plan for this revision. (Show Details)Mar 27 2015, 2:51 PM
sanjoy accepted this revision.Mar 27 2015, 5:00 PM
sanjoy edited edge metadata.

I think this is okay to check in as-is and the review comments addressed post-commit. I have a mild preference running clang-format on the diff pre-checkin (that way the history stays clean), but I'd be okay with that done post-commit as well (maybe over the entire file even).

lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
93

I don't understand the comment "Exclusive of this in KillSet.".

Also, is this a subset of LiveIn? Or do you not count X in cases like

X = def()
use(X)
1937

Why not call this ComputeLiveInValues or something like that? computeGCPtrLiveness is somewhat vague.

1953

I think you can just do for (Value *V : I->operands()) {

1967

The whitespace here (and elsewhere) looks weird. Please run this change through clang-format before checking in.

2022

Minor: I'd pass in true for TermOkay only if it was a GC pointer typed invoke, to make the checks more precise.

2029

Can we use a SetVector here?

2046

Minor: I'd use .clear() here.

2076

? Please actually add an assert. :)

2092

? Please actually add an assert. :)

2127

fixup is too generic, IMO. Maybe calls this AdjustLivenessForBasePointers or something similar?

This revision is now accepted and ready to land.Mar 27 2015, 5:00 PM
swaroop.sridhar accepted this revision.Apr 1 2015, 1:52 PM
swaroop.sridhar edited edge metadata.

I'm about to submit this with the minor fixes you mentioned applied. The change of data structure will go in separately and I haven't added the expensive asserts yet. (Let me know if you want these.)

lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
2076

Checking this makes Release+Asserts *really* slow. I can put an assert under expensive asserts if you'd like. I see the main value is the documentation, not the actual check.

This revision was automatically updated to reflect the committed changes.