Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit a219ca16 authored by Juan Wajnerman's avatar Juan Wajnerman
Browse files

Fix assertion errors with MCJIT during codegen tests

parent b9a699b9
Branches
Tags
No related merge requests found
...@@ -39,6 +39,7 @@ describe "Code gen: declare var" do ...@@ -39,6 +39,7 @@ describe "Code gen: declare var" do
end end
Foo.new.x Foo.new.x
nil
") ")
end end
......
...@@ -44,13 +44,20 @@ module Crystal ...@@ -44,13 +44,20 @@ module Crystal
def evaluate(node) def evaluate(node)
llvm_mod = build(node, BuildOptions.single_module)[""] llvm_mod = build(node, BuildOptions.single_module)[""]
llvm_mod.verify main = llvm_mod.functions[MAIN_NAME]
engine = LLVM::JITCompiler.new(llvm_mod) wrapper = llvm_mod.functions.add("__evaluate_wrapper", [] of LibLLVM::TypeRef, main.return_type) do |func|
func.append_basic_block("entry") do |builder|
argc = LLVM.int(LLVM::Int32, 0)
argv = LLVM.null(LLVM.pointer_type(LLVM::VoidPointer))
ret = builder.call(main, [argc, argv])
node.type.void? ? builder.ret : builder.ret(ret)
end
end
argc = LibLLVM.create_generic_value_of_int(LLVM::Int32, 0_u64, 1) llvm_mod.verify
argv = LibLLVM.create_generic_value_of_pointer(nil)
engine.run_function llvm_mod.functions[MAIN_NAME], [argc, argv] engine = LLVM::JITCompiler.new(llvm_mod)
engine.run_function wrapper, [] of LibLLVM::GenericValueRef
end end
def build(node, build_options) def build(node, build_options)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment