Correct problem that allows indirect function calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1179 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 3541eb8..41948c5 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -806,7 +806,11 @@
for (unsigned i = 1; i < I->getNumOperands(); ++i)
ArgVals.push_back(getOperandValue(I->getOperand(i), SF));
- callMethod(I->getCalledMethod(), ArgVals);
+ // To handle indirect calls, we must get the pointer value from the argument
+ // and treat it as a method pointer.
+ GenericValue SRC = getOperandValue(I->getCalledValue(), SF);
+
+ callMethod((Method*)SRC.PointerVal, ArgVals);
}
static void executePHINode(PHINode *I, ExecutionContext &SF) {