clspv icon indicating copy to clipboard operation
clspv copied to clipboard

Support void pointer in function argument

Open rjodinchr opened this issue 3 years ago • 2 comments

At the moment void pointers are not supported in a function argument.

We could implement a pass that looks at the kernel prototype, to change the type of void pointer to byte pointer (void * => char *).

It would also need to change all usage of it. Which should just be cast operations (bitcast, ptrtoint).

And finally inlines all non-kernel called functions, so that we are capable of resolving the void pointer (if possible) to its real origin.

rjodinchr avatar Jul 28 '22 09:07 rjodinchr

Hi @rjodinchr, I took a quick look at this as it's tangentially related to printf which I'm working on. It seems like void pointers already work as-is by just removing the void pointer type check from the frontend.

Clang already uses i8* to represent void pointers and handles the required casts to/from the real types (plus the move to opaque pointers should make this much simpler). I'm assuming that the check in clspv was added a while ago when support for bitcast, ptrtoint, etc wasn't as robust as it is now. The argument reflection also seems to handle the void* type correctly.

Are there are any cases where you think the support might need more work? If not I'm happy to open up a PR to remove the check and add a few tests.

callumfare avatar Aug 10 '22 15:08 callumfare

I did not get that far, so if you feel like not much work is needed there, it is good news! Go for it

rjodinchr avatar Aug 10 '22 16:08 rjodinchr