This is an archive of the discontinued LLVM Phabricator instance.

[coroutines] Fix rebuilding of dependent coroutine parameters
ClosedPublic

Authored by EricWF on Jun 1 2017, 1:03 PM.

Details

Summary

We were not handling correctly rebuilding of parameter and were not creating copies for them.
Now we will always rebuild parameter moves in TreeTransform's TransformCoroutineBodyStmt.

Diff Detail

Event Timeline

GorNishanov created this revision.Jun 1 2017, 1:03 PM
GorNishanov added inline comments.Jun 2 2017, 2:11 PM
test/CodeGenCoroutines/coro-params.cpp
103

use %[[x_copy]] instead of %x1 here

GorNishanov edited the summary of this revision. (Show Details)Jun 2 2017, 2:20 PM
EricWF edited edge metadata.Jun 2 2017, 2:35 PM

@GorNishanov I think we should be transforming the move parameters, instead of re-building them entirely. I'll put together a different set of changes.

test updated to use %[[copy_x]] instead of %x1

GorNishanov marked an inline comment as done.Jun 2 2017, 3:02 PM
EricWF commandeered this revision.Jun 2 2017, 4:31 PM
EricWF updated this revision to Diff 101291.
EricWF edited reviewers, added: GorNishanov; removed: EricWF.
  • Diagnose non-moveable but otherwise unnamed parameters.
  • Have TreeTransform.h check if building the move params is successful.
lib/Sema/SemaCoroutine.cpp
1285

@rsmith Is there a better way to check if the move would be valid for unnamed parameters without building up these expressions?

rsmith added inline comments.Jun 2 2017, 4:43 PM
lib/Sema/SemaCoroutine.cpp
1285

We could wire through a flag to tell AddInitializerToDecl to build the InitializationSequence but not Perform it, but I don't think it's worth the effort. In fact, I'd prefer that we store the copy statement in the AST regardless, and make the choice to elide the copy from within CodeGen. (Sema shouldn't be dropping parts of the AST just because CodeGen doesn't need them; for example, a tool that wants to identify all potential callers of the move constructor should be able to find this call.)

I think we should also disable elision of parameter copies under -fno-elide-constructors.

EricWF updated this revision to Diff 101293.Jun 2 2017, 4:58 PM
  • No longer unnamed parameters from the AST.
rsmith accepted this revision.Jun 2 2017, 5:08 PM
This revision is now accepted and ready to land.Jun 2 2017, 5:08 PM
EricWF added inline comments.Jun 2 2017, 5:21 PM
lib/Sema/SemaCoroutine.cpp
1285

Makes sense that we shouldn't drop this from the AST. I'll fix that.

EricWF closed this revision.Jun 2 2017, 5:22 PM