diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-10-22 13:55:46 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-10-22 13:55:46 +0000 |
commit | a7edb1888ce8050ba05bcb7743f6a76b6e564741 (patch) | |
tree | 18b04eefec15fa3c4316eea49289de7231d5f97c /lib/Analysis/IPA | |
parent | ac0ec4795753caa8d2b5b8186a05d700998688ae (diff) | |
download | external_llvm-a7edb1888ce8050ba05bcb7743f6a76b6e564741.zip external_llvm-a7edb1888ce8050ba05bcb7743f6a76b6e564741.tar.gz external_llvm-a7edb1888ce8050ba05bcb7743f6a76b6e564741.tar.bz2 |
Added function IsLeafMethod to identify leaf methods.
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
Diffstat (limited to 'lib/Analysis/IPA')
-rw-r--r-- | lib/Analysis/IPA/CallGraph.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 3f997a9..51072e7 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -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; + } +} + + |