Skip to content

Commit 8fb73ce

Browse files
committed
[Coroutines] Make sure that async coroutine context size is a multiple of the alignment requirement
This simplifies the code the allocator has to executed Differential Revision: https://reviews.llvm.org/D91471
1 parent db6f7e0 commit 8fb73ce

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,11 @@ static StructType *buildFrameType(Function &F, coro::Shape &Shape,
791791
case coro::ABI::Async: {
792792
Shape.AsyncLowering.FrameOffset =
793793
alignTo(Shape.AsyncLowering.ContextHeaderSize, Shape.FrameAlign);
794+
// Also make the final context size a multiple of the context alignment to
795+
// make allocation easier for allocators.
794796
Shape.AsyncLowering.ContextSize =
795-
Shape.AsyncLowering.FrameOffset + Shape.FrameSize;
797+
alignTo(Shape.AsyncLowering.FrameOffset + Shape.FrameSize,
798+
Shape.AsyncLowering.getContextAlignment());
796799
if (Shape.AsyncLowering.getContextAlignment() < Shape.FrameAlign) {
797800
report_fatal_error(
798801
"The alignment requirment of frame variables cannot be higher than "

llvm/test/Transforms/Coroutines/coro-async.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ entry:
9999
}
100100

101101
; Make sure we update the async function pointer
102-
; CHECK: @my_async_function_fp = constant <{ i32, i32 }> <{ {{.*}}, i32 168 }
103-
; CHECK: @my_async_function2_fp = constant <{ i32, i32 }> <{ {{.*}}, i32 168 }
102+
; CHECK: @my_async_function_fp = constant <{ i32, i32 }> <{ {{.*}}, i32 176 }
103+
; CHECK: @my_async_function2_fp = constant <{ i32, i32 }> <{ {{.*}}, i32 176 }
104104

105105
; CHECK-LABEL: define swiftcc void @my_async_function(i8* %async.ctxt, %async.task* %task, %async.actor* %actor) {
106106
; CHECK: entry:

0 commit comments

Comments
 (0)