[MCJIT] Improve documentation and error handling for MCJIT::runFunction.

ExecutionEngine::runFunction is supposed to allow execution of arbitrary
function types, but MCJIT can only reasonably support a limited subset of
main-linke function types. This patch documents this limitation, and fixes
MCJIT::runFunction to abort with a meaningful error at runtime if called with
an unsupported function type.

llvm-svn: 278348
This commit is contained in:
Lang Hames 2016-08-11 15:56:23 +00:00
parent def4d1cdf6
commit cbcf36402c
2 changed files with 11 additions and 1 deletions

View File

@ -214,6 +214,13 @@ public:
/// runFunction - Execute the specified function with the specified arguments,
/// and return the result.
///
/// For MCJIT execution engines, clients are encouraged to use the
/// "GetFunctionAddress" method (rather than runFunction) and cast the
/// returned uint64_t to the desired function pointer type. However, for
/// backwards compatibility MCJIT's implementation can execute 'main-like'
/// function (i.e. those returning void or int, and taking either no
/// arguments or (int, char*[])).
virtual GenericValue runFunction(Function *F,
ArrayRef<GenericValue> ArgValues) = 0;

View File

@ -587,7 +587,10 @@ GenericValue MCJIT::runFunction(Function *F, ArrayRef<GenericValue> ArgValues) {
}
}
llvm_unreachable("Full-featured argument passing not supported yet!");
report_fatal_error("MCJIT::runFunction does not support full-featured "
"argument passing. Please use "
"ExecutionEngine::getFunctionAddress and cast the result "
"to the desired function pointer type.");
}
void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) {