Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,13 +907,17 @@ static StructType *buildFrameType(Function &F, coro::Shape &Shape,
// Create an entry for every spilled value.
for (auto &S : FrameData.Spills) {
Type *FieldType = S.first->getType();
MaybeAlign MA;
// For byval arguments, we need to store the pointed value in the frame,
// instead of the pointer itself.
if (const Argument *A = dyn_cast<Argument>(S.first))
if (A->hasByValAttr())
if (const Argument *A = dyn_cast<Argument>(S.first)) {
if (A->hasByValAttr()) {
FieldType = A->getParamByValType();
FieldIDType Id = B.addField(FieldType, std::nullopt, false /*header*/,
true /*IsSpillOfValue*/);
MA = A->getParamAlign();
}
}
FieldIDType Id =
B.addField(FieldType, MA, false /*header*/, true /*IsSpillOfValue*/);
FrameData.setFieldIndex(S.first, Id);
}

Expand Down
5 changes: 3 additions & 2 deletions llvm/test/Transforms/Coroutines/coro-byval-param.ll
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ coro.ret: ; preds = %coro.free, %cleanup
ret ptr %call2
}

; check that the frame contains the entire struct, instead of just the struct pointer
; CHECK: %foo.Frame = type { ptr, ptr, %promise_type, %struct.A, i1 }
; check that the frame contains the entire struct, instead of just the struct pointer,
; and that the alignment is taken into account.
; CHECK: %foo.Frame = type { ptr, ptr, %promise_type, i1, [6 x i8], %struct.A }

; Function Attrs: argmemonly nounwind readonly
declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1
Expand Down