Index: lib/Sema/CoroutineStmtBuilder.h =================================================================== --- lib/Sema/CoroutineStmtBuilder.h +++ lib/Sema/CoroutineStmtBuilder.h @@ -51,6 +51,9 @@ /// name lookup. bool buildDependentStatements(); + /// \brief Build just parameter moves. To use for rebuilding in TreeTransform. + bool buildParameterMoves(); + bool isInvalid() const { return !this->IsValid; } private: Index: lib/Sema/SemaCoroutine.cpp =================================================================== --- lib/Sema/SemaCoroutine.cpp +++ lib/Sema/SemaCoroutine.cpp @@ -822,6 +822,12 @@ return this->IsValid; } +bool CoroutineStmtBuilder::buildParameterMoves() { + assert(this->IsValid && "coroutine already invalid"); + assert(this->ParamMoves.empty() && "param moves already built"); + return this->IsValid = makeParamMoves(); +} + bool CoroutineStmtBuilder::buildDependentStatements() { assert(this->IsValid && "coroutine already invalid"); assert(!this->IsPromiseDependentType && Index: lib/Sema/TreeTransform.h =================================================================== --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -6959,6 +6959,7 @@ Builder.ReturnStmt = Res.get(); } } + Builder.buildParameterMoves(); return getDerived().RebuildCoroutineBodyStmt(Builder); } Index: test/CodeGenCoroutines/coro-params.cpp =================================================================== --- test/CodeGenCoroutines/coro-params.cpp +++ test/CodeGenCoroutines/coro-params.cpp @@ -93,3 +93,26 @@ // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]] // CHECK-NEXT: call i8* @llvm.coro.free( } + +// CHECK-LABEL: void @_Z16dependent_paramsI1AEvT_(%struct.A* %x +template +void dependent_params(T x) { + // CHECK: %[[x_copy:.+]] = alloca %struct.A + + // CHECK: call i8* @llvm.coro.begin + // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %[[x_copy]], %struct.A* dereferenceable(512) %x) + // CHECK-NEXT: invoke void @_ZNSt12experimental16coroutine_traitsIJv1AEE12promise_typeC1Ev + + co_return; +} + +struct A { + int WontFitIntoRegisterForSure[128]; + A() noexcept; + A(A&&) noexcept; + ~A(); +}; + +void call_dependent_params() { + dependent_params(A{}); +}