This is an archive of the discontinued LLVM Phabricator instance.

Emulate TrackingVH using WeakVH
ClosedPublic

Authored by sanjoy on Apr 27 2017, 11:47 PM.

Details

Summary

This frees up one slot in the HandleBaseKind enum, which I will use
later to add a new kind of value handle. The size of the
HandleBaseKind enum is important because we store a HandleBaseKind in
the low two bits of a (in the worst case) 4 byte aligned pointer.

Event Timeline

sanjoy created this revision.Apr 27 2017, 11:47 PM
chandlerc added inline comments.Apr 30 2017, 6:15 PM
include/llvm/IR/ValueHandle.h
285–286

I think we should allow assigning over the TrackingVH as well, much like we would with a moved-from object.

With this change...

290

... we can remove the 'null-is-allowed' aspect of the entire class.

Specifically the CheckValidity call can go awoy from setValPtr and instead is only needed for getValPtr.

I don't think this really reduces the utility of the handle in any way and it makes it much simpler IMO.

308

And I think this should go back to checking ValueHandleBase::isValid which handles things like trying to extract the value pointer from a densemap key.

chandlerc requested changes to this revision.Apr 30 2017, 8:45 PM
This revision now requires changes to proceed.Apr 30 2017, 8:45 PM
sanjoy updated this revision to Diff 97267.May 1 2017, 12:37 AM
sanjoy edited edge metadata.

Address review.

After this TrackingVH is a simple wrapper on WeakVH with two extra checks on access.

chandlerc accepted this revision.May 1 2017, 12:46 AM

LGTM, this looks like a nice simplification and frees up the useful bit to support non-tracking VHs. Tiny nit below, but feel free to submit this and the non-tracking weak stuff when you're ready.

include/llvm/IR/ValueHandle.h
314

stray space before the '.

This revision is now accepted and ready to land.May 1 2017, 12:46 AM
This revision was automatically updated to reflect the committed changes.
davide edited edge metadata.May 1 2017, 12:27 PM

It looks Chandler reviewed this thoroughly. I have no additional comments.