Did I mention that I _HATE_ CPRs?
authorChris Lattner <sabre@nondot.org>
Fri, 31 Oct 2003 18:38:06 +0000 (18:38 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 31 Oct 2003 18:38:06 +0000 (18:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9639 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/CallSite.h
lib/VMCore/iCall.cpp

index 21d30f3ecbd8b00293ea5750550e898fdb56b72c..4f4ae965e32a9f5beff73f85702cacb12b0838cf 100644 (file)
@@ -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...
   ///
index fcaa1e19300240b5283e2ee50699fcb05b45e37f..b99c9e7bb3f7483c7220efba2affa8d5a2df7614 100644 (file)
@@ -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;
+}
+