[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)
Chuanqi Xu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 20 19:31:22 PDT 2021
ChuanqiXu added a comment.
There is something I am still confused about these two patch. Maybe I don't get the problem right.
The example problem shows if user uses `alignas` to specify the alignment for promise_type, the actual alignment for the promise isn't correctly due to compiler didn't call `new` method with alignment which isn't specified in the spec.
Then these two patches are trying to add paddings to the frame type to make the alignment of promise_type right. Here is a gap, in fact the problem comes from the alignment promise. But we want to solve it by over align the frame. It is odd for me.
I wonder if it is possible to simply adjust the alignment for the alloca of promise, like:
%promise = alloca %promise_type, align 64
================
Comment at: clang/docs/LanguageExtensions.rst:2689
- size_t __builtin_coro_size()
+ size_t __builtin_coro_size(bool alloc)
void *__builtin_coro_frame()
----------------
ychen wrote:
> lxfind wrote:
> > Do we need to change __builtin_coro_size? The argument will always be 1, right?
> > It only starts to change in LLVM intrinsics, if I read the impl correctly.
> Yeah, It is always 1 for Clang until the spec is fixed (then we could revert it back to 0). Other clients using `__builtin_coro_size` may use 0 if the client doesn't care about overaligned frame or it could handle overaligned frame by itself.
BTW, is it OK to edit the `builtin`s directly? Since builtin is different with intrinsic which is only visible in the internal of compiler, builtin could be used by any end users. Although I know there should be little users who would use `__builtin_coro` APIs, I worry if there is any guide principle for editing the `builtin`s.
================
Comment at: llvm/docs/Coroutines.rst:961
+ declare i32 @llvm.coro.align.i32()
+ declare i64 @llvm.coro.align.i64()
+
----------------
Maybe I was missing something. I think these two intrinsic should take one i8* argument to specify the coroutine handle. Otherwise, it may be confusing if there are some coroutines get inlined into other coroutine.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100739/new/
https://reviews.llvm.org/D100739
More information about the cfe-commits
mailing list