[llvm] r278348 - [MCJIT] Improve documentation and error handling for MCJIT::runFunction.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 08:56:24 PDT 2016
Author: lhames
Date: Thu Aug 11 10:56:23 2016
New Revision: 278348
URL: http://llvm.org/viewvc/llvm-project?rev=278348&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=278348&r1=278347&r2=278348&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Thu Aug 11 10:56:23 2016
@@ -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;
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=278348&r1=278347&r2=278348&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Thu Aug 11 10:56:23 2016
@@ -587,7 +587,10 @@ GenericValue MCJIT::runFunction(Function
}
}
- 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) {
More information about the llvm-commits
mailing list