Implement the "unknown flag" which mainly consists of aligning printing code
authorChris Lattner <sabre@nondot.org>
Sat, 2 Nov 2002 00:36:03 +0000 (00:36 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 2 Nov 2002 00:36:03 +0000 (00:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4490 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DSNode.h
include/llvm/Analysis/DataStructure/DSNode.h
lib/Analysis/DataStructure/Local.cpp
lib/Analysis/DataStructure/Printer.cpp

index 0d5a0dfa38674f588bfa34a1e9ef0bb4abbcbccc..74fd5afe532c3fa15eec50764c9e7ee8b7f2a0e7 100644 (file)
@@ -61,13 +61,14 @@ class DSNode {
   void operator=(const DSNode &); // DO NOT IMPLEMENT
 public:
   enum NodeTy {
-    ShadowNode = 0,        // Nothing is known about this node...
-    AllocaNode = 1 << 0,   // This node was allocated with alloca
-    NewNode    = 1 << 1,   // This node was allocated with malloc
-    GlobalNode = 1 << 2,   // This node was allocated by a global var decl
-    Incomplete = 1 << 3,   // This node may not be complete
-    Modified   = 1 << 4,   // This node is modified in this context
-    Read       = 1 << 5,   // This node is read in this context
+    ShadowNode  = 0,        // Nothing is known about this node...
+    AllocaNode  = 1 << 0,   // This node was allocated with alloca
+    NewNode     = 1 << 1,   // This node was allocated with malloc
+    GlobalNode  = 1 << 2,   // This node was allocated by a global var decl
+    UnknownNode = 1 << 3,   // This node points to unknown allocated memory 
+    Incomplete  = 1 << 4,   // This node may not be complete
+    Modified    = 1 << 5,   // This node is modified in this context
+    Read        = 1 << 6,   // This node is read in this context
   };
   
   /// NodeType - A union of the above bits.  "Shadow" nodes do not add any flags
index 0d5a0dfa38674f588bfa34a1e9ef0bb4abbcbccc..74fd5afe532c3fa15eec50764c9e7ee8b7f2a0e7 100644 (file)
@@ -61,13 +61,14 @@ class DSNode {
   void operator=(const DSNode &); // DO NOT IMPLEMENT
 public:
   enum NodeTy {
-    ShadowNode = 0,        // Nothing is known about this node...
-    AllocaNode = 1 << 0,   // This node was allocated with alloca
-    NewNode    = 1 << 1,   // This node was allocated with malloc
-    GlobalNode = 1 << 2,   // This node was allocated by a global var decl
-    Incomplete = 1 << 3,   // This node may not be complete
-    Modified   = 1 << 4,   // This node is modified in this context
-    Read       = 1 << 5,   // This node is read in this context
+    ShadowNode  = 0,        // Nothing is known about this node...
+    AllocaNode  = 1 << 0,   // This node was allocated with alloca
+    NewNode     = 1 << 1,   // This node was allocated with malloc
+    GlobalNode  = 1 << 2,   // This node was allocated by a global var decl
+    UnknownNode = 1 << 3,   // This node points to unknown allocated memory 
+    Incomplete  = 1 << 4,   // This node may not be complete
+    Modified    = 1 << 5,   // This node is modified in this context
+    Read        = 1 << 6,   // This node is read in this context
   };
   
   /// NodeType - A union of the above bits.  "Shadow" nodes do not add any flags
index 456eb2f3335e4ee620480efcec584f86aecced0c..0d6046d13d3f5ed9c0d94ef49e0f3447b1f63efb 100644 (file)
@@ -369,12 +369,17 @@ void GraphBuilder::visitCallInst(CallInst &CI) {
 
 /// Handle casts...
 void GraphBuilder::visitCastInst(CastInst &CI) {
-  if (isPointerType(CI.getType())) {
-    if (isPointerType(CI.getOperand(0)->getType()))
+  if (isPointerType(CI.getType()))
+    if (isPointerType(CI.getOperand(0)->getType())) {
+      // Cast one pointer to the other, just act like a copy instruction
       setDestTo(CI, getValueDest(*CI.getOperand(0)));
-    else
-      ; // FIXME: "Other" node
-  }
+    } else {
+      // Cast something (floating point, small integer) to a pointer.  We need
+      // to track the fact that the node points to SOMETHING, just something we
+      // don't know about.  Make an "Unknown" node.
+      //
+      setDestTo(CI, createNode(DSNode::UnknownNode));
+    }
 }
 
 
index fd6006c2a5dbd5c474c81de285222955fb9fc886..26424bed0701de073e6c539739b8ec1986f25c3e 100644 (file)
@@ -36,12 +36,13 @@ static string getCaption(const DSNode *N, const DSGraph *G) {
     OS << "\n";
   }
 
-  if (N->NodeType & DSNode::AllocaNode) OS << "A";
-  if (N->NodeType & DSNode::NewNode   ) OS << "N";
-  if (N->NodeType & DSNode::GlobalNode) OS << "G";
-  if (N->NodeType & DSNode::Incomplete) OS << "I";
-  if (N->NodeType & DSNode::Modified  ) OS << "M";
-  if (N->NodeType & DSNode::Read      ) OS << "R";
+  if (N->NodeType & DSNode::AllocaNode ) OS << "A";
+  if (N->NodeType & DSNode::NewNode    ) OS << "N";
+  if (N->NodeType & DSNode::GlobalNode ) OS << "G";
+  if (N->NodeType & DSNode::UnknownNode) OS << "U";
+  if (N->NodeType & DSNode::Incomplete ) OS << "I";
+  if (N->NodeType & DSNode::Modified   ) OS << "M";
+  if (N->NodeType & DSNode::Read       ) OS << "R";
 
   for (unsigned i = 0, e = N->getGlobals().size(); i != e; ++i) {
     WriteAsOperand(OS, N->getGlobals()[i], false, true, M);