[llvm-commits] [poolalloc] r59310 - in /poolalloc/trunk: include/dsa/DSGraph.h include/dsa/DSNode.h lib/DSA/DataStructure.cpp lib/DSA/Local.cpp lib/DSA/TopDownClosure.cpp

John Criswell criswell at uiuc.edu
Fri Nov 14 08:27:11 PST 2008


Author: criswell
Date: Fri Nov 14 10:27:10 2008
New Revision: 59310

URL: http://llvm.org/viewvc/llvm-project?rev=59310&view=rev
Log:
Added support for the llvm.returnaddress() intrinsic.
Fixed support for the llvm.vastart() intrinsic; it returns void.
Added a "vararg" flag to the DSNode to track which memory objects magically
appear from the llvm.vastart() intrinsic.
Added support in the Top-Down DSA pass to mark "vararg" DSNodes as Incomplete
since we can't tell what their format is or to what they're pointing.

Modified:
    poolalloc/trunk/include/dsa/DSGraph.h
    poolalloc/trunk/include/dsa/DSNode.h
    poolalloc/trunk/lib/DSA/DataStructure.cpp
    poolalloc/trunk/lib/DSA/Local.cpp
    poolalloc/trunk/lib/DSA/TopDownClosure.cpp

Modified: poolalloc/trunk/include/dsa/DSGraph.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSGraph.h?rev=59310&r1=59309&r2=59310&view=diff

==============================================================================
--- poolalloc/trunk/include/dsa/DSGraph.h (original)
+++ poolalloc/trunk/include/dsa/DSGraph.h Fri Nov 14 10:27:10 2008
@@ -450,7 +450,8 @@
   //
   enum MarkIncompleteFlags {
     MarkFormalArgs = 1, IgnoreFormalArgs = 0,
-    IgnoreGlobals = 2, MarkGlobalsIncomplete = 0
+    IgnoreGlobals = 2, MarkGlobalsIncomplete = 0,
+    MarkVAStart = 4
   };
   void markIncompleteNodes(unsigned Flags);
 

Modified: poolalloc/trunk/include/dsa/DSNode.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=59310&r1=59309&r2=59310&view=diff

==============================================================================
--- poolalloc/trunk/include/dsa/DSNode.h (original)
+++ poolalloc/trunk/include/dsa/DSNode.h Fri Nov 14 10:27:10 2008
@@ -95,9 +95,10 @@
     ExternalNode    = 1 << 8,   // This node comes from an external source
     IntToPtrNode    = 1 << 9,   // This node comes from an int cast
     PtrToIntNode    = 1 << 10,  // This node excapes to an int cast
+    VAStartNode     = 1 << 11,  // This node excapes to an int cast
 
     //#ifndef NDEBUG
-    DeadNode        = 1 << 11,   // This node is dead and should not be pointed to
+    DeadNode        = 1 << 12,   // This node is dead and should not be pointed to
     //#endif
 
     Composition = AllocaNode | HeapNode | GlobalNode | UnknownNode
@@ -353,6 +354,7 @@
   bool isExternalNode()   const { return NodeType & ExternalNode;  }
   bool isIntToPtrNode()   const { return NodeType & IntToPtrNode;  }
   bool isPtrToIntNode()   const { return NodeType & PtrToIntNode;  }
+  bool isVAStartNode()    const { return NodeType & VAStartNode;   }
 
   DSNode* setAllocaMarker()     { NodeType |= AllocaNode;     return this; }
   DSNode* setHeapMarker()       { NodeType |= HeapNode;       return this; }
@@ -365,6 +367,7 @@
   DSNode* setExternalMarker()   { NodeType |= ExternalNode;   return this; }
   DSNode* setIntToPtrMarker()   { NodeType |= IntToPtrNode;   return this; }
   DSNode* setPtrToIntMarker()   { NodeType |= PtrToIntNode;   return this; }
+  DSNode* setVAStartMarker()    { NodeType |= VAStartNode;    return this; }
 
   void makeNodeDead() {
     Globals.clear();

Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=59310&r1=59309&r2=59310&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Fri Nov 14 10:27:10 2008
@@ -1985,6 +1985,13 @@
       if (!GV->hasInitializer() ||    // Always mark external globals incomp.
           (!GV->isConstant() && (Flags & DSGraph::IgnoreGlobals) == 0))
         markIncompleteNode(ScalarMap[GV].getNode());
+
+  // Mark any node with the VAStart flag as incomplete.
+  if (Flags & DSGraph::MarkVAStart) {
+    for (node_iterator i=node_begin(); i != node_end(); ++i) {
+      markIncompleteNode(i);
+    }
+  }
 }
 
 static inline void killIfUselessEdge(DSNodeHandle &Edge) {

Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=59310&r1=59309&r2=59310&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Fri Nov 14 10:27:10 2008
@@ -520,9 +520,37 @@
 /// returns true if the intrinsic is handled
 bool GraphBuilder::visitIntrinsic(CallSite CS, Function *F) {
   switch (F->getIntrinsicID()) {
-  case Intrinsic::vastart:
-    getValueDest(*CS.getInstruction()).getNode()->setAllocaMarker();
+  case Intrinsic::vastart: {
+    // Mark the memory written by the vastart intrinsic as incomplete
+    DSNodeHandle RetNH = getValueDest(**CS.arg_begin());
+    if (DSNode *N = RetNH.getNode()) {
+      N->setModifiedMarker()->setAllocaMarker()->setIncompleteMarker()
+       ->setVAStartMarker()->setUnknownMarker()->foldNodeCompletely();
+    }
+
+    if (RetNH.hasLink(0)) {
+      DSNodeHandle Link = RetNH.getLink(0);
+      if (DSNode *N = Link.getNode()) {
+        N->setModifiedMarker()->setAllocaMarker()->setIncompleteMarker()
+         ->setVAStartMarker()->setUnknownMarker()->foldNodeCompletely();
+      }
+    } else {
+      //
+      // Sometimes the argument to the vastart is casted and has no DSNode.
+      // Peer past the cast.
+      //
+      Value * Operand = CS.getInstruction()->getOperand(1);
+      if (CastInst * CI = dyn_cast<CastInst>(Operand))
+        Operand = CI->getOperand (0);
+      RetNH = getValueDest(*Operand);
+      if (DSNode *N = RetNH.getNode()) {
+        N->setModifiedMarker()->setAllocaMarker()->setIncompleteMarker()
+         ->setVAStartMarker()->setUnknownMarker()->foldNodeCompletely();
+      }
+    }
+
     return true;
+  }
   case Intrinsic::vacopy:
     getValueDest(*CS.getInstruction()).
       mergeWith(getValueDest(**(CS.arg_begin())));
@@ -611,6 +639,18 @@
   case Intrinsic::eh_typeid_for_i64:
     return true;
 
+  //
+  // The return address aliases with the stack, is type-unknown, and should
+  // have the unknown flag set since we don't know where it goes.
+  //
+  case Intrinsic::returnaddress: {
+    DSNode * Node = createNode();
+    Node->setAllocaMarker()->setIncompleteMarker()->setUnknownMarker();
+    Node->foldNodeCompletely();
+    setDestTo (*(CS.getInstruction()), Node);
+    return true;
+  }
+
   default: {
     //ignore pointer free intrinsics
     if (!isa<PointerType>(F->getReturnType())) {

Modified: poolalloc/trunk/lib/DSA/TopDownClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TopDownClosure.cpp?rev=59310&r1=59309&r2=59310&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/TopDownClosure.cpp Fri Nov 14 10:27:10 2008
@@ -261,7 +261,8 @@
   // Recompute the Incomplete markers.  Depends on whether args are complete
   unsigned Flags
     = HasIncompleteArgs ? DSGraph::MarkFormalArgs : DSGraph::IgnoreFormalArgs;
-  DSG->markIncompleteNodes(Flags | DSGraph::IgnoreGlobals);
+  Flags |= DSGraph::IgnoreGlobals | DSGraph::MarkVAStart;
+  DSG->markIncompleteNodes(Flags);
 
   // Delete dead nodes.  Treat globals that are unreachable as dead also.
   DSG->removeDeadNodes(DSGraph::RemoveUnreachableGlobals);





More information about the llvm-commits mailing list