@@ -234,7 +234,7 @@ class FrameTypeBuilder {
234234 // / Side Effects: Because We sort the allocas, the order of allocas in the
235235 // / frame may be different with the order in the source code.
236236 void addFieldForAllocas (const Function &F, FrameDataInfo &FrameData,
237- coro::Shape &Shape);
237+ coro::Shape &Shape, bool OptimizeFrame );
238238
239239 // / Add a field to this structure.
240240 [[nodiscard]] FieldIDType addField (Type *Ty, MaybeAlign MaybeFieldAlignment,
@@ -336,7 +336,8 @@ void FrameDataInfo::updateLayoutIndex(FrameTypeBuilder &B) {
336336
337337void FrameTypeBuilder::addFieldForAllocas (const Function &F,
338338 FrameDataInfo &FrameData,
339- coro::Shape &Shape) {
339+ coro::Shape &Shape,
340+ bool OptimizeFrame) {
340341 using AllocaSetType = SmallVector<AllocaInst *, 4 >;
341342 SmallVector<AllocaSetType, 4 > NonOverlapedAllocas;
342343
@@ -350,7 +351,7 @@ void FrameTypeBuilder::addFieldForAllocas(const Function &F,
350351 }
351352 });
352353
353- if (!Shape. OptimizeFrame ) {
354+ if (!OptimizeFrame) {
354355 for (const auto &A : FrameData.Allocas ) {
355356 AllocaInst *Alloca = A.Alloca ;
356357 NonOverlapedAllocas.emplace_back (AllocaSetType (1 , Alloca));
@@ -860,7 +861,8 @@ static void buildFrameDebugInfo(Function &F, coro::Shape &Shape,
860861// ... spills ...
861862// };
862863static StructType *buildFrameType (Function &F, coro::Shape &Shape,
863- FrameDataInfo &FrameData) {
864+ FrameDataInfo &FrameData,
865+ bool OptimizeFrame) {
864866 LLVMContext &C = F.getContext ();
865867 const DataLayout &DL = F.getDataLayout ();
866868 StructType *FrameTy = [&] {
@@ -905,7 +907,7 @@ static StructType *buildFrameType(Function &F, coro::Shape &Shape,
905907
906908 // Because multiple allocas may own the same field slot,
907909 // we add allocas to field here.
908- B.addFieldForAllocas (F, FrameData, Shape);
910+ B.addFieldForAllocas (F, FrameData, Shape, OptimizeFrame );
909911 // Add PromiseAlloca to Allocas list so that
910912 // 1. updateLayoutIndex could update its index after
911913 // `performOptimizedStructLayout`
@@ -2056,7 +2058,7 @@ void coro::normalizeCoroutine(Function &F, coro::Shape &Shape,
20562058 rewritePHIs (F);
20572059}
20582060
2059- void coro::BaseABI::buildCoroutineFrame () {
2061+ void coro::BaseABI::buildCoroutineFrame (bool OptimizeFrame ) {
20602062 SuspendCrossingInfo Checker (F, Shape.CoroSuspends , Shape.CoroEnds );
20612063 doRematerializations (F, Checker, IsMaterializable);
20622064
@@ -2087,7 +2089,7 @@ void coro::BaseABI::buildCoroutineFrame() {
20872089
20882090 // Build frame
20892091 FrameDataInfo FrameData (Spills, Allocas);
2090- Shape.FrameTy = buildFrameType (F, Shape, FrameData);
2092+ Shape.FrameTy = buildFrameType (F, Shape, FrameData, OptimizeFrame );
20912093 Shape.FramePtr = Shape.CoroBegin ;
20922094 // For now, this works for C++ programs only.
20932095 buildFrameDebugInfo (F, Shape, FrameData);
0 commit comments