[llvm] r222804 - Make sure that the go bindings call LLVMInitializeMCJITCompilerOptions
Eric Christopher
echristo at gmail.com
Tue Nov 25 18:27:46 PST 2014
Author: echristo
Date: Tue Nov 25 20:27:46 2014
New Revision: 222804
URL: http://llvm.org/viewvc/llvm-project?rev=222804&view=rev
Log:
Make sure that the go bindings call LLVMInitializeMCJITCompilerOptions
so that they initialize the code generation model to the correct
(non-zero) default model.
Modified:
llvm/trunk/bindings/go/llvm/executionengine.go
llvm/trunk/bindings/go/llvm/executionengine_test.go
Modified: llvm/trunk/bindings/go/llvm/executionengine.go
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/executionengine.go?rev=222804&r1=222803&r2=222804&view=diff
==============================================================================
--- llvm/trunk/bindings/go/llvm/executionengine.go (original)
+++ llvm/trunk/bindings/go/llvm/executionengine.go Tue Nov 25 20:27:46 2014
@@ -30,11 +30,9 @@ type GenericValue struct {
type ExecutionEngine struct {
C C.LLVMExecutionEngineRef
}
+
type MCJITCompilerOptions struct {
- OptLevel uint
- CodeModel CodeModel
- NoFramePointerElim bool
- EnableFastISel bool
+ C C.struct_LLVMMCJITCompilerOptions
}
// helpers
@@ -96,15 +94,19 @@ func NewInterpreter(m Module) (ee Execut
return
}
+func NewMCJITCompilerOptions() MCJITCompilerOptions {
+ var options C.struct_LLVMMCJITCompilerOptions
+ C.LLVMInitializeMCJITCompilerOptions(&options, C.size_t(unsafe.Sizeof(C.struct_LLVMMCJITCompilerOptions{})))
+ return MCJITCompilerOptions{options}
+}
+
+func SetMCJITOptimizationLevel(options MCJITCompilerOptions, level uint) {
+ options.C.OptLevel = C.uint(level)
+}
+
func NewMCJITCompiler(m Module, options MCJITCompilerOptions) (ee ExecutionEngine, err error) {
var cmsg *C.char
- copts := C.struct_LLVMMCJITCompilerOptions{
- OptLevel: C.unsigned(options.OptLevel),
- CodeModel: C.LLVMCodeModel(options.CodeModel),
- NoFramePointerElim: boolToLLVMBool(options.NoFramePointerElim),
- EnableFastISel: boolToLLVMBool(options.EnableFastISel),
- }
- fail := C.LLVMCreateMCJITCompilerForModule(&ee.C, m.C, &copts, C.size_t(unsafe.Sizeof(copts)), &cmsg)
+ fail := C.LLVMCreateMCJITCompilerForModule(&ee.C, m.C, &options.C, C.size_t(unsafe.Sizeof(C.struct_LLVMMCJITCompilerOptions{})), &cmsg)
if fail != 0 {
ee.C = nil
err = errors.New(C.GoString(cmsg))
Modified: llvm/trunk/bindings/go/llvm/executionengine_test.go
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/executionengine_test.go?rev=222804&r1=222803&r2=222804&view=diff
==============================================================================
--- llvm/trunk/bindings/go/llvm/executionengine_test.go (original)
+++ llvm/trunk/bindings/go/llvm/executionengine_test.go Tue Nov 25 20:27:46 2014
@@ -66,7 +66,9 @@ func TestFactorial(t *testing.T) {
return
}
- engine, err := NewMCJITCompiler(mod, MCJITCompilerOptions{OptLevel: 2})
+ options := NewMCJITCompilerOptions()
+ SetMCJITOptimizationLevel(options, 2)
+ engine, err := NewMCJITCompiler(mod, options)
if err != nil {
t.Errorf("Error creating JIT: %s", err)
return
More information about the llvm-commits
mailing list