-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ error with no verbose output #433
Comments
Thanks for the report. Do you have a reproducer ? |
I can give a zip of my entire code (around 1000 lines) if that works, it happens consistently. |
Sorry for the delay, here's the files to make this work. Simply run |
@stuartarchibald any update on this? |
Think the IR generated is invalid. The define i32 @"mul7126777023838580747"(i32 %"a", i32 %"b")
{
entry:
%".4" = alloca i32
store i32 %"a", i32* %".4"
%".6" = alloca i32
store i32 %"b", i32* %".6"
%"retval" = alloca i32
; there should be a terminator here!
exit:
%".8" = load i32, i32* %"retval"
ret i32 %".8"
} then in the def compile_ir(engine, llvm_ir):
"""
Compile the LLVM IR string with the given engine.
The compiled module object is returned.
"""
# Create a LLVM module object from the IR
import llvmlite.binding as llvm
mod = llvm.parse_assembly(llvm_ir)
mod.verify()
# Now add the module and make sure it is ready for execution
engine.add_module(mod)
engine.finalize_object()
engine.run_static_constructors()
return mod
def wrap_function(func, engine):
module = compile_ir(engine, str(func))
args = func.type.pointee.args
ret_type = func.type.pointee.return_type
ret_ctype = wrap_type(ret_type)
args_ctypes = map(wrap_type, args)
functype = ctypes.CFUNCTYPE(ret_ctype, *args_ctypes)
fptr = engine.get_function_address(func.name)
cfunc = functype(fptr)
cfunc.__name__ = func.name
return cfunc |
Thank you, that makes the C++ error go away. I also see the issue you pointed out (which is now being reported as shown below), however I'm not sure how to fix it. I ported this code from llvmpy, which I believe used to handle exiting on its own. How would I fix this? new error: Traceback (most recent call last):
File ".\core.py", line 145, in <module>
print(f"10*20={mul(10, 20)}")
File ".\core.py", line 66, in _wrapper
pyfunc = wrap_module(argtys, llfunc)
File "U:\Downloads\files\type_map.py", line 22, in wrap_module
pfunc = wrap_function(llfunc, engine)
File "U:\Downloads\files\type_map.py", line 43, in wrap_function
module = compile_ir(engine, str(func))
File "U:\Downloads\files\type_map.py", line 33, in compile_ir
mod = llvm.parse_assembly(llvm_ir)
File "U:\Downloads\Python\lib\site-packages\llvmlite\binding\module.py", line 26, in parse_assembly
raise RuntimeError("LLVM IR parsing error\n{0}".format(errmsg))
RuntimeError: LLVM IR parsing error
<string>:9:1: error: expected instruction opcode
exit:
^ |
No problem. At the end of the |
Sadly due to lack of verbosity I have no clue what part of my code causes this.
The text was updated successfully, but these errors were encountered: