Fix a problem where we not marking incoming arguments to functions with
authorChris Lattner <sabre@nondot.org>
Tue, 29 Mar 2005 19:16:59 +0000 (19:16 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 29 Mar 2005 19:16:59 +0000 (19:16 +0000)
external linkage as incomplete.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20927 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/DataStructure.cpp
lib/Analysis/DataStructure/Steensgaard.cpp

index 6460287ac7198b2ede41cb9a1f019be28892c949..7bad52ac3c987f0fe9ea70f0cc5733ebfd9c60de 100644 (file)
@@ -1657,7 +1657,8 @@ void DSGraph::markIncompleteNodes(unsigned Flags) {
     for (ReturnNodesTy::iterator FI = ReturnNodes.begin(), E =ReturnNodes.end();
          FI != E; ++FI) {
       Function &F = *FI->first;
-      for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I)
+      for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end();
+           I != E; ++I)
         if (isPointerType(I->getType()))
           markIncompleteNode(getNodeForValue(I).getNode());
       markIncompleteNode(FI->second.getNode());
index aa7f54b8904f08cf0db326e0fea0eb937c3670f3..747ae2fc4b75488a554c208dace01fbc71f008e1 100644 (file)
@@ -167,14 +167,22 @@ bool Steens::runOnModule(Module &M) {
     }
   }
 
-  // Remove our knowledge of what the return values of the functions are.
-  ResultGraph->getReturnNodes().clear();
+  // Remove our knowledge of what the return values of the functions are, except
+  // for functions that are externally visible from this module (e.g. main).  We
+  // keep these functions so that their arguments are marked incomplete.
+  for (DSGraph::ReturnNodesTy::iterator I =
+         ResultGraph->getReturnNodes().begin(),
+         E = ResultGraph->getReturnNodes().end(); I != E; )
+    if (I->first->hasInternalLinkage())
+      ResultGraph->getReturnNodes().erase(I++);
+    else
+      ++I;
 
   // Update the "incomplete" markers on the nodes, ignoring unknownness due to
   // incoming arguments...
   ResultGraph->maskIncompleteMarkers();
-  ResultGraph->markIncompleteNodes(DSGraph::IgnoreFormalArgs |
-                                   DSGraph::IgnoreGlobals);
+  ResultGraph->markIncompleteNodes(DSGraph::IgnoreGlobals |
+                                   DSGraph::MarkFormalArgs);
 
   // Remove any nodes that are dead after all of the merging we have done...
   // FIXME: We should be able to disable the globals graph for steens!