[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-26 Thread Lewis Baker via Phabricator via cfe-commits
lewissbaker added a comment. > There are still room for improvements, in particular, GCC has a 4K frame > for this function. I think GCC having a smaller coroutine frame is probably because it does not yet implement the allocation-elision optimisation which inlines the nested coroutine frame

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-24 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 273173. lxfind added a comment. Remove unused variable Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82314/new/ https://reviews.llvm.org/D82314 Files: llvm/lib/Transforms/Coroutines/CoroSplit.cpp llvm/test/

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-24 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 273171. lxfind added a comment. A few unintended changes Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82314/new/ https://reviews.llvm.org/D82314 Files: llvm/lib/Transforms/Coroutines/CoroSplit.cpp llvm/tes

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-24 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 273169. lxfind added a comment. Actually it seems pretty easy to handle the case of multiple BitCastInst, so did it here. Also added a test. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82314/new/ https://revi

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-24 Thread Xun Li via Phabricator via cfe-commits
lxfind marked an inline comment as done. lxfind added inline comments. Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:1286 +continue; + if (CastInst) { +// If we have multiple cast instructions for the alloca, don't junparser wrote:

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-24 Thread JunMa via Phabricator via cfe-commits
junparser added a comment. @lxfind, Thank you! And could you please add some testcases? Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:1286 +continue; + if (CastInst) { +// If we have multiple cast instructions for the alloca, don't -

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-24 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 272916. lxfind added a comment. Address test failures Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82314/new/ https://reviews.llvm.org/D82314 Files: llvm/lib/Transforms/Coroutines/CoroSplit.cpp llvm/test/T

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-23 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 272904. lxfind added a comment. Herald added subscribers: llvm-commits, hiraditya. Herald added a project: LLVM. Tackle this problem inside CoroSplit as an optimization. Instead of only handling one particular case, we now look at every local variable in the

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-23 Thread JunMa via Phabricator via cfe-commits
junparser added a comment. In D82314#2109437 , @lxfind wrote: > In D82314#2107910 , @junparser wrote: > > > Rather than doing it here, can we build await_resume call expression with > > MaterializedTemporaryExpr wh

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-23 Thread JunMa via Phabricator via cfe-commits
junparser added a comment. In D82314#2109893 , @rsmith wrote: > In D82314#2109728 , @lxfind wrote: > > > @rsmith Thanks. That's a good point. Do you know if there already exists > > optimization passes in LLVM that

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment. In D82314#2109728 , @lxfind wrote: > @rsmith Thanks. That's a good point. Do you know if there already exists > optimization passes in LLVM that attempts to shrink the range of lifetime > intrinsics? If so, I am curious why that d

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-23 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment. @rsmith Thanks. That's a good point. Do you know if there already exists optimization passes in LLVM that attempts to shrink the range of lifetime intrinsics? If so, I am curious why that does not help in this case. Or is it generally unsafe to move the lifetime intrinsi

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment. In D82314#2109437 , @lxfind wrote: > In D82314#2107910 , @junparser wrote: > > > Rather than doing it here, can we build await_resume call expression with > > MaterializedTemporaryExpr when

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-23 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment. In D82314#2107910 , @junparser wrote: > Rather than doing it here, can we build await_resume call expression with > MaterializedTemporaryExpr when expand the coawait expression. That's how gcc > does. There doesn't appear to be

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-22 Thread JunMa via Phabricator via cfe-commits
junparser added a comment. Rather than doing it here, can we build await_resume call expression with MaterializedTemporaryExpr when expand the coawait expression. That's how gcc does. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82314/new/ https

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-22 Thread Xun Li via Phabricator via cfe-commits
lxfind created this revision. lxfind added reviewers: lewissbaker, modocache, junparser. Herald added a project: clang. Herald added a subscriber: cfe-commits. If we ever assign co_await to a temporary variable, such as foo(co_await expr), we generate AST that looks like this: MaterializedTempora