summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-31 18:38:06 +0000
committerChris Lattner <sabre@nondot.org>2003-10-31 18:38:06 +0000
commit9157ec025bb075c5a988f4f334046cf5d4527d2e (patch)
tree2c99ccefb1dbb8032fc5f9d93108bda6ad85bbc9
parentff9194087998eb0d64bbe1a17bee6fe6ec68fc1f (diff)
downloadbcm5719-llvm-9157ec025bb075c5a988f4f334046cf5d4527d2e.tar.gz
bcm5719-llvm-9157ec025bb075c5a988f4f334046cf5d4527d2e.zip
Did I mention that I _HATE_ CPRs?
llvm-svn: 9639
-rw-r--r--llvm/include/llvm/Support/CallSite.h5
-rw-r--r--llvm/lib/VMCore/iCall.cpp12
2 files changed, 14 insertions, 3 deletions
diff --git a/llvm/include/llvm/Support/CallSite.h b/llvm/include/llvm/Support/CallSite.h
index 21d30f3ecbd..4f4ae965e32 100644
--- a/llvm/include/llvm/Support/CallSite.h
+++ b/llvm/include/llvm/Support/CallSite.h
@@ -58,9 +58,8 @@ public:
/// getCalledFunction - Return the function being called if this is a direct
/// call, otherwise return null (if it's an indirect call).
///
- Function *getCalledFunction() const {
- return dyn_cast<Function>(getCalledValue());
- }
+ /// FIXME: This should be inlined once ConstantPointerRefs are gone. :(
+ Function *getCalledFunction() const;
/// setCalledFunction - Set the callee to the specified value...
///
diff --git a/llvm/lib/VMCore/iCall.cpp b/llvm/lib/VMCore/iCall.cpp
index fcaa1e19300..b99c9e7bb3f 100644
--- a/llvm/lib/VMCore/iCall.cpp
+++ b/llvm/lib/VMCore/iCall.cpp
@@ -143,3 +143,15 @@ Function *InvokeInst::getCalledFunction() {
return cast<Function>(CPR->getValue());
return 0;
}
+
+#include "llvm/Support/CallSite.h"
+
+Function *CallSite::getCalledFunction() const {
+ Value *Callee = getCalledValue();
+ if (Function *F = dyn_cast<Function>(Callee))
+ return F;
+ if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Callee))
+ return cast<Function>(CPR->getValue());
+ return 0;
+}
+
OpenPOWER on IntegriCloud