[llvm] 8fb73ce - [Coroutines] Make sure that async coroutine context size is a multiple of the alignment requirement
Arnold Schwaighofer via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 14 05:09:37 PST 2020
Author: Arnold Schwaighofer
Date: 2020-11-14T04:56:56-08:00
New Revision: 8fb73cecfd1a1c0367759721566a91d320f76d8b
URL: https://github.com/llvm/llvm-project/commit/8fb73cecfd1a1c0367759721566a91d320f76d8b
DIFF: https://github.com/llvm/llvm-project/commit/8fb73cecfd1a1c0367759721566a91d320f76d8b.diff
LOG: [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
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/test/Transforms/Coroutines/coro-async.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 27064d2da5da..dec3f072262d 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -791,8 +791,11 @@ static StructType *buildFrameType(Function &F, coro::Shape &Shape,
case coro::ABI::Async: {
Shape.AsyncLowering.FrameOffset =
alignTo(Shape.AsyncLowering.ContextHeaderSize, Shape.FrameAlign);
+ // Also make the final context size a multiple of the context alignment to
+ // make allocation easier for allocators.
Shape.AsyncLowering.ContextSize =
- Shape.AsyncLowering.FrameOffset + Shape.FrameSize;
+ alignTo(Shape.AsyncLowering.FrameOffset + Shape.FrameSize,
+ Shape.AsyncLowering.getContextAlignment());
if (Shape.AsyncLowering.getContextAlignment() < Shape.FrameAlign) {
report_fatal_error(
"The alignment requirment of frame variables cannot be higher than "
diff --git a/llvm/test/Transforms/Coroutines/coro-async.ll b/llvm/test/Transforms/Coroutines/coro-async.ll
index 35b23bb33a6e..0faff4aed2e0 100644
--- a/llvm/test/Transforms/Coroutines/coro-async.ll
+++ b/llvm/test/Transforms/Coroutines/coro-async.ll
@@ -99,8 +99,8 @@ entry:
}
; Make sure we update the async function pointer
-; CHECK: @my_async_function_fp = constant <{ i32, i32 }> <{ {{.*}}, i32 168 }
-; CHECK: @my_async_function2_fp = constant <{ i32, i32 }> <{ {{.*}}, i32 168 }
+; CHECK: @my_async_function_fp = constant <{ i32, i32 }> <{ {{.*}}, i32 176 }
+; CHECK: @my_async_function2_fp = constant <{ i32, i32 }> <{ {{.*}}, i32 176 }
; CHECK-LABEL: define swiftcc void @my_async_function(i8* %async.ctxt, %async.task* %task, %async.actor* %actor) {
; CHECK: entry:
More information about the llvm-commits
mailing list