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

Use i8* instead of void* for generated LLVM IR #8

Open
sampsyo opened this issue May 16, 2017 · 2 comments
Open

Use i8* instead of void* for generated LLVM IR #8

sampsyo opened this issue May 16, 2017 · 2 comments

Comments

@sampsyo
Copy link
Collaborator

sampsyo commented May 16, 2017

It looks like LLVM doesn't like using void* for opaque pointers. Trying to compile some LLVM IR actually gave me a useful hint:

$ /usr/local/Cellar/llvm/4.0.0_1/bin/opt add.ll             
/usr/local/Cellar/llvm/4.0.0_1/bin/opt: add.ll:6:22: error: pointers to void are invalid - use i8* instead
define i32 @main(void*) {

Apparently, at least until opaque pointer types come to LLVM IR, the right type to use for this sort of thing is a pointer to 8-bit integers.

One easy way to do this would be to define a constant for the i8* type (called FUNCTION_ENV_TYPE?) and then use it wherever we currently have llvm.PointerType.create(llvm.VoidType.create(), 0).

@rhenwood39
Copy link
Collaborator

Got it! I'll try fixing that within the next day or two a put in a new pull request.

If you remember, I mentioned the other day that there was also a bug where the function environment function pointer was not being initialized properly. So I'll try including the fix for that in my pull request as well.

@sampsyo
Copy link
Collaborator Author

sampsyo commented May 21, 2017

Cool! I'd be happy to take a look at that separately too if it would be helpful.

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