Added function IsLeafMethod to identify leaf methods.
authorVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 22 Oct 2001 13:55:46 +0000 (13:55 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 22 Oct 2001 13:55:46 +0000 (13:55 +0000)
This will use the CallGraph only if one is provided.

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

include/llvm/Analysis/CallGraph.h
lib/Analysis/IPA/CallGraph.cpp

index 3c6f7cc4660a9a951f22ad51b123d41ff465f810..5f259d593346a858a579e5b5a377031e1faa2f03 100644 (file)
@@ -89,4 +89,18 @@ private:   // Implementation of CallGraph construction
 
 }  // end namespace cfg
 
+
+//******************* Externally Visible Functions *************************/
+
+
+// Checks if a method contains any call instructions.
+// Note that this uses the call graph only if one is provided.
+// It does not build the call graph.
+// 
+bool   IsLeafMethod       (const Method* method,
+                            const cfg::CallGraph* callGraph = NULL);
+
+
+//**************************************************************************/
+
 #endif
index 3f997a9dd40c3c8815b495d4cbfea3e317cb6e13..51072e77abd9b6dcb2122ece0b1a137189f6072b 100644 (file)
@@ -70,3 +70,26 @@ void cfg::WriteToOutput(const CallGraph &CG, ostream &o) {
   for (CallGraph::const_iterator I = CG.begin(), E = CG.end(); I != E; ++I)
     o << I->second;
 }
+
+
+
+// 
+// Checks if a method contains any call instructions.
+// Note that this uses the call graph only if one is provided.
+// It does not build the call graph.
+// 
+bool IsLeafMethod(const Method* M, const cfg::CallGraph* CG) {
+  if (CG) {
+    const cfg::CallGraphNode *cgn = (*CG)[M];
+    return (cgn->begin() == cgn->end());
+  }
+  else {
+    for (Method::inst_const_iterator I = M->inst_begin(), E = M->inst_end();
+         I != E; ++I)
+      if ((*I)->getOpcode() == Instruction::Call)
+        return false;
+    return true;
+  }
+}
+
+