[llvm-commits] [llvm] r43373 - in /llvm/trunk: include/llvm/Bitcode/Deserialize.h lib/Bitcode/Reader/Deserialize.cpp

Ted Kremenek kremenek at apple.com
Thu Oct 25 16:40:35 PDT 2007


Author: kremenek
Date: Thu Oct 25 18:40:35 2007
New Revision: 43373

URL: http://llvm.org/viewvc/llvm-project?rev=43373&view=rev
Log:
Updated backpatching during object deserialization to support "smart"
pointers that employ unused bits in a pointer to store extra data.

Modified:
    llvm/trunk/include/llvm/Bitcode/Deserialize.h
    llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp

Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Deserialize.h?rev=43373&r1=43372&r2=43373&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Deserialize.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Deserialize.h Thu Oct 25 18:40:35 2007
@@ -20,6 +20,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/DataTypes.h"
 #include <vector>
 
 namespace llvm {
@@ -40,8 +41,11 @@
   
   struct BPatchNode {
     BPatchNode* const Next;
-    void*& PtrRef;    
-    BPatchNode(BPatchNode* n, void*& pref) : Next(n), PtrRef(pref) {}
+    uintptr_t& PtrRef;
+    BPatchNode(BPatchNode* n, void*& pref) 
+      : Next(n), PtrRef(reinterpret_cast<uintptr_t&>(pref)) {
+        PtrRef = 0;
+      }
   };
   
   struct BPatchEntry {

Modified: llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp?rev=43373&r1=43372&r2=43373&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp Thu Oct 25 18:40:35 2007
@@ -126,7 +126,9 @@
     assert (Entry.Ptr && "No pointer found for backpatch.");
     
     for (BPatchNode* N = Entry.Head; N != NULL; N = N->Next)
-      N->PtrRef = Entry.Ptr;
+      // Bitwise-OR in the pointer to support "smart" pointers that use
+      // unused bits to store extra data.
+      N->PtrRef |= reinterpret_cast<uintptr_t>(Entry.Ptr);
     
     Entry.Head = NULL;
   }





More information about the llvm-commits mailing list