-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[Coroutines] Coroutine frame allocated with a wrong alignment #53148
Comments
Yeah, this is a known issue that the alignment requirement couldn't be satisfied if the alignment requirement of elements is large than 16... This issue shows we would better handle this in middle end since there are other users for switch based coroutine intrinsics. |
In our particular MLIR example the problem is in unaligned |
This is lowered assembly. Could you offer the generated LLVM IR from MLIR? |
@d0k do you have a LLVM IR from your debugging session? |
I don't have that IR anymore, but it happens whenever an AVX2 |
If it lacks a LLVM IR, I could only assume the problem in the case is same with the problem in C++ (The alignment of elements couldn't large than15). BTW, it should be possible to fix the above problem in frontend. For example, the frontend could call |
We don't emit |
Oh, it surprises me. I never knew the coro passes would insert call to |
MLIR calls malloc directly instead of
|
Yeah, it should be the frontend to generate calls to allocation functions (no matter
Yeah, now it lacks an intrinsic that the frontend could get the value of the alignment. I would try to provide one recently. |
Coroutine lowering always takes the natural alignment when spilling to the frame (issue #53148) so using AVX2 or AVX512 in a coroutine doesn't work. Always overalign to 64 bytes to avoid this issue until we have a better solution. Differential Revision: https://reviews.llvm.org/D117501
Now we sent https://reviews.llvm.org/D117542 to offer llvm.coro.align intrinsic. So we should be able to solve the problem by fulfilling the corresponding alignment to aligned_alloc when emitting LLVM IR. |
This should be fixed in: dbbe010 |
Example: https://godbolt.org/z/Ea8rPzG18
If a value is used across suspension points and it is stored into the coroutine frame, it might have an invalid alignment. It seems that memory for the coroutine frame is allocated with a plain call to
operator new(size)
.We stumbled upon this problem when generating LLVM IR from MLIR, but it's easy to reproduce it with C++20 coroutines as well.
output:
The text was updated successfully, but these errors were encountered: