This is an archive of the discontinued LLVM Phabricator instance.

[IR] Put the Use list waymarking bits in the bit positions documentation says they are using
ClosedPublic

Authored by craig.topper on Apr 5 2017, 4:22 PM.

Details

Summary

The documentation for the waymarking algorithm says that we use the lower 2 bits of Use::Prev to store the way marking bits. But because we use a PointerIntPair with the default PointerLikeTypeTraits, we're using bits 2:1 on 64-bit targets.

There's also a trick employed for distinguishing Users that have Uses stored with them and Users that have Uses stored in a separate array. The documentation says we use the LSB of the first byte of the real User object or the User* that occurs at the end of the Use array. But again due to the PointerLikeTypeTraits we're really using bit 2(64-bit) or bit 1(32-bit) and not the LSB. This is a little worrying because the first byte of the User object is the vtable ptr so we're assuming the vtable has 8 byte or 4 byte alignment where what is documented would only require 2 byte alignment.

This patch provides a custom traits override for these two cases to put the bits where the documentation says they are. It also has the side effect of removing some shifts from the waymarking traversal implementation.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 5 2017, 4:22 PM
mehdi_amini added inline comments.Apr 5 2017, 4:56 PM
include/llvm/IR/Use.h
64

I'd document the motivation for the traits (i.e. for using the LSB independently of the platform IIUC).

77

same here :)

Add additional comments.

craig.topper marked 2 inline comments as done.Apr 5 2017, 5:07 PM
rnk accepted this revision.Apr 17 2017, 10:56 AM

lgtm

This revision is now accepted and ready to land.Apr 17 2017, 10:56 AM
This revision was automatically updated to reflect the committed changes.