forked from OSchip/llvm-project
Added function IsLeafMethod to identify leaf methods.
This will use the CallGraph only if one is provided. llvm-svn: 950
This commit is contained in:
parent
4e594bebba
commit
5dab57de99
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue