[PATCH] D31733: [IR] Put the Use list waymarking bits in the bit positions documentation says they are using
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 5 17:07:01 PDT 2017
craig.topper updated this revision to Diff 94307.
craig.topper added a comment.
Add additional comments.
https://reviews.llvm.org/D31733
Files:
include/llvm/IR/Use.h
Index: include/llvm/IR/Use.h
===================================================================
--- include/llvm/IR/Use.h
+++ include/llvm/IR/Use.h
@@ -61,9 +61,29 @@
/// that also works with less standard-compliant compilers
void swap(Use &RHS);
+ /// Pointer traits for the UserRef PointerIntPair. This ensures we always
+ /// use the LSB regardless of pointer alignment on different targets.
+ struct UserRefPointerTraits {
+ static inline void *getAsVoidPointer(User *P) { return P; }
+ static inline User *getFromVoidPointer(void *P) {
+ return (User *)P;
+ }
+ enum { NumLowBitsAvailable = 1 };
+ };
+
// A type for the word following an array of hung-off Uses in memory, which is
// a pointer back to their User with the bottom bit set.
- typedef PointerIntPair<User *, 1, unsigned> UserRef;
+ typedef PointerIntPair<User *, 1, unsigned, UserRefPointerTraits> UserRef;
+
+ /// Pointer traits for the Prev PointerIntPair. This ensures we always use
+ /// the two LSBs regardless of pointer alignment on different targets.
+ struct PrevPointerTraits {
+ static inline void *getAsVoidPointer(Use **P) { return P; }
+ static inline Use **getFromVoidPointer(void *P) {
+ return (Use **)P;
+ }
+ enum { NumLowBitsAvailable = 2 };
+ };
private:
/// Destructor - Only for zap()
@@ -115,7 +135,7 @@
Value *Val;
Use *Next;
- PointerIntPair<Use **, 2, PrevPtrTag> Prev;
+ PointerIntPair<Use **, 2, PrevPtrTag, PrevPointerTraits> Prev;
void setPrev(Use **NewPrev) { Prev.setPointer(NewPrev); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31733.94307.patch
Type: text/x-patch
Size: 1571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170406/f70645df/attachment.bin>
More information about the llvm-commits
mailing list