virtual Instruction *clone() const { return new CallInst(*this); }
bool mayWriteToMemory() const { return true; }
- const Function *getCalledFunction() const {
- return dyn_cast<Function>(Operands[0].get());
- }
- Function *getCalledFunction() {
- return dyn_cast<Function>(Operands[0].get());
- }
+ // FIXME: These methods should be inline once we eliminate
+ // ConstantPointerRefs!
+ const Function *getCalledFunction() const;
+ Function *getCalledFunction();
// getCalledValue - Get a pointer to a method that is invoked by this inst.
inline const Value *getCalledValue() const { return Operands[0]; }
bool mayWriteToMemory() const { return true; }
- // getCalledFunction - Return the function called, or null if this is an
- // indirect function invocation...
- //
- inline const Function *getCalledFunction() const {
- return dyn_cast<Function>(Operands[0].get());
- }
- inline Function *getCalledFunction() {
- return dyn_cast<Function>(Operands[0].get());
- }
+ /// getCalledFunction - Return the function called, or null if this is an
+ /// indirect function invocation...
+ ///
+ /// FIXME: These should be inlined once we get rid of ConstantPointerRefs!
+ ///
+ const Function *getCalledFunction() const;
+ Function *getCalledFunction();
// getCalledValue - Get a pointer to a function that is invoked by this inst.
inline const Value *getCalledValue() const { return Operands[0]; }
#include "llvm/iOther.h"
#include "llvm/iTerminators.h"
+#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
Operands.push_back(Use(CI.Operands[i], this));
}
+const Function *CallInst::getCalledFunction() const {
+ if (const Function *F = dyn_cast<Function>(Operands[0]))
+ return F;
+ if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Operands[0]))
+ return cast<Function>(CPR->getValue());
+ return 0;
+}
+Function *CallInst::getCalledFunction() {
+ if (Function *F = dyn_cast<Function>(Operands[0]))
+ return F;
+ if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Operands[0]))
+ return cast<Function>(CPR->getValue());
+ return 0;
+}
+
+
//===----------------------------------------------------------------------===//
// InvokeInst Implementation
//===----------------------------------------------------------------------===//
Operands.push_back(Use(CI.Operands[i], this));
}
+const Function *InvokeInst::getCalledFunction() const {
+ if (const Function *F = dyn_cast<Function>(Operands[0]))
+ return F;
+ if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Operands[0]))
+ return cast<Function>(CPR->getValue());
+ return 0;
+}
+Function *InvokeInst::getCalledFunction() {
+ if (Function *F = dyn_cast<Function>(Operands[0]))
+ return F;
+ if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Operands[0]))
+ return cast<Function>(CPR->getValue());
+ return 0;
+}