Skip to content

Commit 37d9b4b

Browse files
committed
Also update CoroFrame
1 parent a288ae5 commit 37d9b4b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ class FrameTypeBuilder {
290290
return Fields.size() - 1;
291291
}
292292

293-
/// Finish the layout and set the body on the given type.
294-
void finish(StructType *Ty);
293+
/// Finish the layout and create the struct type with the given name.
294+
StructType *finish(StringRef Name);
295295

296296
uint64_t getStructSize() const {
297297
assert(IsFinished && "not yet finished!");
@@ -464,7 +464,7 @@ void FrameTypeBuilder::addFieldForAllocas(const Function &F,
464464
});
465465
}
466466

467-
void FrameTypeBuilder::finish(StructType *Ty) {
467+
StructType *FrameTypeBuilder::finish(StringRef Name) {
468468
assert(!IsFinished && "already finished!");
469469

470470
// Prepare the optimal-layout field array.
@@ -526,7 +526,7 @@ void FrameTypeBuilder::finish(StructType *Ty) {
526526
LastOffset = Offset + F.Size;
527527
}
528528

529-
Ty->setBody(FieldTypes, Packed);
529+
StructType *Ty = StructType::create(Context, FieldTypes, Name, Packed);
530530

531531
#ifndef NDEBUG
532532
// Check that the IR layout matches the offsets we expect.
@@ -538,6 +538,8 @@ void FrameTypeBuilder::finish(StructType *Ty) {
538538
#endif
539539

540540
IsFinished = true;
541+
542+
return Ty;
541543
}
542544

543545
static void cacheDIVar(FrameDataInfo &FrameData,
@@ -866,11 +868,6 @@ static StructType *buildFrameType(Function &F, coro::Shape &Shape,
866868
bool OptimizeFrame) {
867869
LLVMContext &C = F.getContext();
868870
const DataLayout &DL = F.getDataLayout();
869-
StructType *FrameTy = [&] {
870-
SmallString<32> Name(F.getName());
871-
Name.append(".Frame");
872-
return StructType::create(C, Name);
873-
}();
874871

875872
// We will use this value to cap the alignment of spilled values.
876873
std::optional<Align> MaxFrameAlignment;
@@ -931,7 +928,12 @@ static StructType *buildFrameType(Function &F, coro::Shape &Shape,
931928
FrameData.setFieldIndex(S.first, Id);
932929
}
933930

934-
B.finish(FrameTy);
931+
StructType *FrameTy = [&] {
932+
SmallString<32> Name(F.getName());
933+
Name.append(".Frame");
934+
return B.finish(Name);
935+
}();
936+
935937
FrameData.updateLayoutIndex(B);
936938
Shape.FrameAlign = B.getStructAlign();
937939
Shape.FrameSize = B.getStructSize();

0 commit comments

Comments
 (0)