summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/ExecutionEngineBindings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ExecutionEngine/ExecutionEngineBindings.cpp')
-rw-r--r--lib/ExecutionEngine/ExecutionEngineBindings.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngineBindings.cpp b/lib/ExecutionEngine/ExecutionEngineBindings.cpp
index f66dc1dfea..f9b08a01ea 100644
--- a/lib/ExecutionEngine/ExecutionEngineBindings.cpp
+++ b/lib/ExecutionEngine/ExecutionEngineBindings.cpp
@@ -154,18 +154,29 @@ LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT,
return 1;
}
-LLVMBool LLVMCreateMCJITCompilerForModule(LLVMExecutionEngineRef *OutJIT,
- LLVMModuleRef M,
- LLVMMCJITCompilerOptions *PassedOptions,
- size_t SizeOfPassedOptions,
- char **OutError) {
+void LLVMInitializeMCJITCompilerOptions(LLVMMCJITCompilerOptions *PassedOptions,
+ size_t SizeOfPassedOptions) {
+ LLVMMCJITCompilerOptions options;
+ options.OptLevel = 0;
+ options.CodeModel = LLVMCodeModelJITDefault;
+ options.NoFramePointerElim = false;
+ options.EnableFastISel = false;
+
+ memcpy(PassedOptions, &options,
+ std::min(sizeof(options), SizeOfPassedOptions));
+}
+
+LLVMBool LLVMCreateMCJITCompilerForModule(
+ LLVMExecutionEngineRef *OutJIT, LLVMModuleRef M,
+ LLVMMCJITCompilerOptions *PassedOptions, size_t SizeOfPassedOptions,
+ char **OutError) {
LLVMMCJITCompilerOptions options;
// If the user passed a larger sized options struct, then they were compiled
// against a newer LLVM. Tell them that something is wrong.
if (SizeOfPassedOptions > sizeof(options)) {
*OutError = strdup(
- "Refusing to use options struct that is larger than my own; assuming LLVM "
- "library mismatch.");
+ "Refusing to use options struct that is larger than my own; assuming "
+ "LLVM library mismatch.");
return 1;
}
@@ -173,11 +184,12 @@ LLVMBool LLVMCreateMCJITCompilerForModule(LLVMExecutionEngineRef *OutJIT,
// any fields they didn't see are cleared. We must defend against fields being
// set to the bitwise equivalent of zero, and assume that this means "do the
// default" as if that option hadn't been available.
- memset(&options, 0, sizeof(options));
+ LLVMInitializeMCJITCompilerOptions(&options, sizeof(options));
memcpy(&options, PassedOptions, SizeOfPassedOptions);
TargetOptions targetOptions;
targetOptions.NoFramePointerElim = options.NoFramePointerElim;
+ targetOptions.EnableFastISel = options.EnableFastISel;
std::string Error;
EngineBuilder builder(unwrap(M));
@@ -185,6 +197,7 @@ LLVMBool LLVMCreateMCJITCompilerForModule(LLVMExecutionEngineRef *OutJIT,
.setErrorStr(&Error)
.setUseMCJIT(true)
.setOptLevel((CodeGenOpt::Level)options.OptLevel)
+ .setCodeModel(unwrap(options.CodeModel))
.setTargetOptions(targetOptions);
if (ExecutionEngine *JIT = builder.create()) {
*OutJIT = wrap(JIT);
@@ -300,7 +313,8 @@ LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
return 1;
}
-void *LLVMRecompileAndRelinkFunction(LLVMExecutionEngineRef EE, LLVMValueRef Fn) {
+void *LLVMRecompileAndRelinkFunction(LLVMExecutionEngineRef EE,
+ LLVMValueRef Fn) {
return unwrap(EE)->recompileAndRelinkFunction(unwrap<Function>(Fn));
}