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

Remove redundant bitcast in builtin dynamic alloca codegen #554

Open
orbiri opened this issue Apr 20, 2024 · 0 comments
Open

Remove redundant bitcast in builtin dynamic alloca codegen #554

orbiri opened this issue Apr 20, 2024 · 0 comments

Comments

@orbiri
Copy link
Contributor

orbiri commented Apr 20, 2024

AllocaOp verifies that the returned address type is the pointer of the allocated type, e.g. u64 * and u64. The dynamic allocation builtins, in general, are allocating buffers of size size bytes and returning void * pointers. To support this in #547, we introduced an AllocaOp of type u8, and had to later on bitcast the return address to void *. Usually right afterwards, the user of the builtin dynamic alloca will cast the operation to its intended value, e.g.

int *a = (int *)__builtin_alloca(sizeof(int) * size);

We should define a method to remove this redundant bitcasts by either (or both):

  • Allowing AllocaOp to have different address type than allocation type
  • Remove this redundancy later in CastOp::fold.
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

1 participant