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

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 17 11:25:14 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL300471: [IR] Put the Use list waymarking bits in the bit positions documentation says… (authored by ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D31733?vs=94307&id=95464#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31733

Files:
  llvm/trunk/include/llvm/IR/Use.h


Index: llvm/trunk/include/llvm/IR/Use.h
===================================================================
--- llvm/trunk/include/llvm/IR/Use.h
+++ llvm/trunk/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.95464.patch
Type: text/x-patch
Size: 1604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170417/bc21309b/attachment.bin>


More information about the llvm-commits mailing list