Skip to content
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

Setting function attributes fails with OverflowError #9

Open
cgrenz opened this issue Apr 10, 2017 · 2 comments
Open

Setting function attributes fails with OverflowError #9

cgrenz opened this issue Apr 10, 2017 · 2 comments

Comments

@cgrenz
Copy link
Contributor

cgrenz commented Apr 10, 2017

Setting a function attribute with add_attribute_at_index() and AttributeFunctionIndex fails with

OverflowError: can't convert negative number to unsigned

This seems to be because the LLVM headers define LLVMAttributeFunctionIndex as -1, but LLVMAttributeIndex is a typedef for unsigned and CFFI doesn't allow negative values for unsigned integer parameters.

Test Case:

from llvmcpy import llvm

kind = llvm.get_enum_attribute_kind_for_name('noinline', len('noinline'))
attr = llvm.get_global_context().create_enum_attribute(kind, 0)
module = llvm.module_create_with_name('testmodule')
func = module.add_function('testfunction', llvm.void_type().function([], False))

func.add_attribute_at_index(llvm.AttributeFunctionIndex, attr)
@aleclearmind
Copy link
Contributor

I guess the only way to handle this is to convert each integer argument to the correct type before forwarding it to the CFFI wrapper. A bit annoying, but doable.

Thanks for reporting this.

@aleclearmind
Copy link
Contributor

Any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants