[llvm-commits] [poolalloc] r115273 - /poolalloc/trunk/lib/DSA/DataStructure.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Thu Sep 30 20:25:17 PDT 2010


Author: aggarwa4
Date: Thu Sep 30 22:25:16 2010
New Revision: 115273

URL: http://llvm.org/viewvc/llvm-project?rev=115273&view=rev
Log:
Fixed bug for IntToPtr and PtrToInt markers.
If a node has an offset, which has an integer type and a pointer type
associated with it, it must set these markers, on the node pointed to.

Occurs in case of unions, and when nodes get collapsed.

Modified:
    poolalloc/trunk/lib/DSA/DataStructure.cpp

Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=115273&r1=115272&r2=115273&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Thu Sep 30 22:25:16 2010
@@ -337,6 +337,31 @@
   if (Offset >= getSize()) growSize(Offset+1);
 
   TyMap[Offset] = getParentGraph()->getTypeSS().getOrCreate(TyMap[Offset], NewTy);
+
+  // check if the types merged have both int and pointer at the same offset,
+  // If yes, the IntToPtr and PtrToInt flag must be set on the node pointed to at
+  // that offset. If no such node exists, it is created.
+ 
+  bool pointerTy = false;
+  bool integerTy = false;
+  for (svset<const Type*>::const_iterator ni = TyMap[Offset]->begin(),
+       ne = TyMap[Offset]->end(); ni != ne; ++ni) {
+    if((*ni)->isPointerTy()) {
+      pointerTy = true;
+    }
+    if((*ni)->isIntegerTy()) {
+      integerTy = true;
+    }
+  }
+  if(pointerTy && integerTy) {
+    if(!hasLink(Offset)) {
+      const DSNodeHandle &NH  = new DSNode(getParentGraph());
+      addEdgeTo(Offset, NH);
+    }
+    DSNodeHandle &Edge = getLink(Offset);
+    assert(!Edge.isNull());
+    Edge.getNode()->setUnknownMarker()->setIntToPtrMarker()->setPtrToIntMarker();
+  }
   assert(TyMap[Offset]);
 }
 
@@ -354,6 +379,31 @@
     S.insert(TyIt->begin(), TyIt->end());
     TyMap[Offset] = getParentGraph()->getTypeSS().getOrCreate(S);
   }
+  
+  // check if the types merged have both int and pointer at the same offset,
+  // If yes, the IntToPtr and PtrToInt flag must be set on the node pointed to at
+  // that offset. If no such node exists, it is created.
+  bool pointerTy = false;
+  bool integerTy = false;
+  for (svset<const Type*>::const_iterator ni = TyMap[Offset]->begin(),
+       ne = TyMap[Offset]->end(); ni != ne; ++ni) {
+    if((*ni)->isPointerTy()) {
+      pointerTy = true;
+    }
+    if((*ni)->isIntegerTy()) {
+      integerTy = true;
+    }
+  }
+  if(pointerTy && integerTy) {
+    if(!hasLink(Offset)) {
+      const DSNodeHandle &NH  = new DSNode(getParentGraph());
+      addEdgeTo(Offset, NH);
+    }
+    DSNodeHandle &Edge = getLink(Offset);
+    assert(!Edge.isNull());
+    Edge.getNode()->setUnknownMarker()->setIntToPtrMarker()->setPtrToIntMarker();
+  }
+
   assert(TyMap[Offset]);
 }
 





More information about the llvm-commits mailing list