OSDN Git Service

[IR] Put the Use list waymarking bits in the bit positions documentation says they...
authorCraig Topper <craig.topper@gmail.com>
Mon, 17 Apr 2017 18:12:30 +0000 (18:12 +0000)
committerCraig Topper <craig.topper@gmail.com>
Mon, 17 Apr 2017 18:12:30 +0000 (18:12 +0000)
commit1ba7d1942889596b2d4e9fb106a15c1c6f91d81e
tree9bf19a962ac682e59c9e9b7e590dceb8b7526876
parent82b3362feae87748cb6e5bbd997d9ce182d65329
[IR] Put the Use list waymarking bits in the bit positions documentation says they are using

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.

Differential Revision: https://reviews.llvm.org/D31733

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300471 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/Use.h