aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/DataStructure
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2003-07-16 21:25:17 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2003-07-16 21:25:17 +0000
commit2e1de5ed593b7236db9da3df27111a5539db2340 (patch)
tree2e4590489f7bcf7e15272dba0323d1bccb78a8a7 /lib/Analysis/DataStructure
parentdfbfc57d78b74084ede5aa3ff8b380d64cb4d27e (diff)
downloadexternal_llvm-2e1de5ed593b7236db9da3df27111a5539db2340.zip
external_llvm-2e1de5ed593b7236db9da3df27111a5539db2340.tar.gz
external_llvm-2e1de5ed593b7236db9da3df27111a5539db2340.tar.bz2
Factor out the test for unresolvable external functions into
isUnresolvableFunc() (I thought I needed this externally. I don't, but it's still nicer this way.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7186 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure')
-rw-r--r--lib/Analysis/DataStructure/DSCallSiteIterator.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/Analysis/DataStructure/DSCallSiteIterator.h b/lib/Analysis/DataStructure/DSCallSiteIterator.h
index 62a1515..499e2c8 100644
--- a/lib/Analysis/DataStructure/DSCallSiteIterator.h
+++ b/lib/Analysis/DataStructure/DSCallSiteIterator.h
@@ -28,13 +28,27 @@ struct DSCallSiteIterator {
CallSite = FCs->size(); CallSiteEntry = 0;
}
+ static bool isVAHackFn(const Function *F) {
+ return F->getName() == "printf" || F->getName() == "sscanf" ||
+ F->getName() == "fprintf" || F->getName() == "open" ||
+ F->getName() == "sprintf" || F->getName() == "fputs" ||
+ F->getName() == "fscanf" || F->getName() == "bzero" ||
+ F->getName() == "memset";
+ }
+
+ // isUnresolvableFunction - Return true if this is an unresolvable
+ // external function. A direct or indirect call to this cannot be resolved.
+ //
+ static bool isUnresolvableFunc(const Function* callee) {
+ return callee->isExternal() && !isVAHackFn(callee);
+ }
+
void advanceToValidCallee() {
while (CallSite < FCs->size()) {
if ((*FCs)[CallSite].isDirectCall()) {
if (CallSiteEntry == 0 && // direct call only has one target...
- (!(*FCs)[CallSite].getCalleeFunc()->isExternal() ||
- isVAHackFn((*FCs)[CallSite].getCalleeFunc()))) // If not external
- return;
+ ! DSCallSite::isUnresolvableFunc((*FCs)[CallSite].getCalleeFunc()))
+ return; // and not an unresolvable external func
} else {
DSNode *CalleeNode = (*FCs)[CallSite].getCalleeNode();
if (CallSiteEntry || isCompleteNode(CalleeNode)) {
@@ -50,14 +64,6 @@ struct DSCallSiteIterator {
++CallSite;
}
}
-
- static bool isVAHackFn(const Function *F) {
- return F->getName() == "printf" || F->getName() == "sscanf" ||
- F->getName() == "fprintf" || F->getName() == "open" ||
- F->getName() == "sprintf" || F->getName() == "fputs" ||
- F->getName() == "fscanf" || F->getName() == "bzero" ||
- F->getName() == "memset";
- }
// isCompleteNode - Return true if we know all of the targets of this node,
// and if the call sites are not external.
@@ -66,9 +72,8 @@ struct DSCallSiteIterator {
if (N->isIncomplete()) return false;
const std::vector<GlobalValue*> &Callees = N->getGlobals();
for (unsigned i = 0, e = Callees.size(); i != e; ++i)
- if (Callees[i]->isExternal())
- if (!isVAHackFn(cast<Function>(Callees[i])))
- return false; // External function found...
+ if (isUnresolvableFunc(cast<Function>(Callees[i])))
+ return false; // Unresolvable external function found...
return true; // otherwise ok
}