Fix spelling and grammar in a comment.
[oota-llvm.git] / lib / Analysis / IPA / CallGraph.cpp
index ad6c898540e870ff1a80e8949747cbedfd03f12c..19d0fd5190798068df7626d1b8d1c6aceb7a9d7a 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -26,9 +26,7 @@ using namespace llvm;
 /// takes the address of the function.
 static bool isOnlyADirectCall(Function *F, CallSite CS) {
   if (!CS.getInstruction()) return false;
-  for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); I != E; ++I)
-    if (*I == F) return false;
-  return true;
+  return !CS.hasArgument(F);
 }
 
 namespace {
@@ -51,7 +49,7 @@ class VISIBILITY_HIDDEN BasicCallGraph : public CallGraph, public ModulePass {
   CallGraphNode *CallsExternalNode;
 
 public:
-  static const int ID; // Class identification, replacement for typeinfo
+  static char ID; // Class identification, replacement for typeinfo
   BasicCallGraph() : ModulePass((intptr_t)&ID), Root(0), 
     ExternalCallingNode(0), CallsExternalNode(0) {}
 
@@ -136,7 +134,7 @@ private:
 
     // If this function is not defined in this translation unit, it could call
     // anything.
-    if (F->isDeclaration() && !F->getIntrinsicID())
+    if (F->isDeclaration() && !F->isIntrinsic())
       Node->addCalledFunction(CallSite(), CallsExternalNode);
 
     // Loop over all of the users of the function... looking for callers...
@@ -190,15 +188,15 @@ private:
   }
 };
 
-
-RegisterAnalysisGroup<CallGraph> X("Call Graph");
-RegisterPass<BasicCallGraph> Y("basiccg", "Basic CallGraph Construction");
-RegisterAnalysisGroup<CallGraph, true> Z(Y);
-
 } //End anonymous namespace
 
-const int CallGraph::ID = 0;
-const int BasicCallGraph::ID = 0;
+static RegisterAnalysisGroup<CallGraph> X("Call Graph");
+static RegisterPass<BasicCallGraph>
+Y("basiccg", "Basic CallGraph Construction", false, true);
+static RegisterAnalysisGroup<CallGraph, true> Z(Y);
+
+char CallGraph::ID = 0;
+char BasicCallGraph::ID = 0;
 
 void CallGraph::initialize(Module &M) {
   Mod = &M;
@@ -294,6 +292,20 @@ void CallGraphNode::removeCallEdgeTo(CallGraphNode *Callee) {
   }
 }
 
+/// removeCallEdgeFor - This method removes the edge in the node for the
+/// specified call site.  Note that this method takes linear time, so it
+/// should be used sparingly.
+void CallGraphNode::removeCallEdgeFor(CallSite CS) {
+  for (unsigned i = CalledFunctions.size(); ; --i) {
+    assert(i && "Cannot find callee to remove!");
+    if (CalledFunctions[i-1].first == CS) {
+      CalledFunctions.erase(CalledFunctions.begin()+i-1);
+      return;
+    }
+  }
+}
+
+
 // removeAnyCallEdgeTo - This method removes any call edges from this node to
 // the specified callee function.  This takes more time to execute than
 // removeCallEdgeTo, so it should not be used unless necessary.