diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-31 18:38:06 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-31 18:38:06 +0000 |
commit | bc539434c5ab3b537336cc2a6212d0f24d8f791d (patch) | |
tree | 4db401c2df30a066081ef6f7fd4e314a156dcd96 | |
parent | 94082397d28b172830ba5f449b9dab301e47e5b7 (diff) |
Did I mention that I _HATE_ CPRs?
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9639 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Support/CallSite.h | 5 | ||||
-rw-r--r-- | lib/VMCore/iCall.cpp | 12 |
2 files changed, 14 insertions, 3 deletions
diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h index 21d30f3ecb..4f4ae965e3 100644 --- a/include/llvm/Support/CallSite.h +++ b/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/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp index fcaa1e1930..b99c9e7bb3 100644 --- a/lib/VMCore/iCall.cpp +++ b/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; +} + |