[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters
Gor Nishanov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 2 15:01:42 PDT 2017
GorNishanov updated this revision to Diff 101282.
GorNishanov added a comment.
test updated to use %[[copy_x]] instead of %x1
https://reviews.llvm.org/D33797
Files:
lib/Sema/CoroutineStmtBuilder.h
lib/Sema/SemaCoroutine.cpp
lib/Sema/TreeTransform.h
test/CodeGenCoroutines/coro-params.cpp
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 <typename T>
+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{});
+}
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: 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/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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33797.101282.patch
Type: text/x-patch
Size: 2292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170602/ddbb9b62/attachment.bin>
More information about the cfe-commits
mailing list