From bc539434c5ab3b537336cc2a6212d0f24d8f791d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 31 Oct 2003 18:38:06 +0000 Subject: [PATCH] Did I mention that I _HATE_ CPRs? git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9639 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CallSite.h | 5 ++--- 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 21d30f3ecbd..4f4ae965e32 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(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 fcaa1e19300..b99c9e7bb3f 100644 --- a/lib/VMCore/iCall.cpp +++ b/lib/VMCore/iCall.cpp @@ -143,3 +143,15 @@ Function *InvokeInst::getCalledFunction() { return cast(CPR->getValue()); return 0; } + +#include "llvm/Support/CallSite.h" + +Function *CallSite::getCalledFunction() const { + Value *Callee = getCalledValue(); + if (Function *F = dyn_cast(Callee)) + return F; + if (ConstantPointerRef *CPR = dyn_cast(Callee)) + return cast(CPR->getValue()); + return 0; +} + -- 2.34.1