llvm-mirror/test/Transforms/Coroutines
Xun Li 10e1d5734d [Coroutines] Optimize the lifespan of temporary co_await object
Summary:
If we ever assign co_await to a temporary variable, such as foo(co_await expr),
we generate AST that looks like this: MaterializedTemporaryExpr(CoawaitExpr(...)).
MaterializedTemporaryExpr would emit an intrinsics that marks the lifetime start of the
temporary storage. However such temporary storage will not be used until co_await is ready
to write the result. Marking the lifetime start way too early causes extra storage to be
put in the coroutine frame instead of the stack.
As you can see from https://godbolt.org/z/zVx_eB, the frame generated for get_big_object2 is 12K, which contains a big_object object unnecessarily.
After this patch, the frame size for get_big_object2 is now only 8K. There are still room for improvements, in particular, GCC has a 4K frame for this function. But that's a separate problem and not addressed in this patch.

The basic idea of this patch is during CoroSplit, look for every local variable in the coroutine created through AllocaInst, identify all the lifetime start/end markers and the use of the variables, and sink the lifetime.start maker to the places as close to the first-ever use as possible.

Reviewers: lewissbaker, modocache, junparser

Reviewed By: junparser

Subscribers: hiraditya, llvm-commits, rsmith, ChuanqiXu, cfe-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D82314
2020-06-28 10:18:15 -07:00
..
ArgAddr.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-alloc-with-param-O0.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-alloc-with-param-O2.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-catchswitch.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-cleanup-lowering.ll [Coroutines][4/6] New pass manager: coro-cleanup 2020-02-19 00:30:27 -05:00
coro-cleanup.ll [Coroutines][5/6] Add coroutine passes to pipeline 2020-02-19 00:57:14 -05:00
coro-debug-frame-variable.ll [Coroutines] Use dbg.declare for frame variables 2020-03-03 17:13:46 -05:00
coro-debug.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-early.ll [Coroutines][1/6] New pass manager: coro-early 2020-02-17 13:27:48 -05:00
coro-eh-aware-edge-split-00.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-eh-aware-edge-split-01.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-eh-aware-edge-split-02.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-elide.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-frame-arrayalloca.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-frame-unreachable.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-frame.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-heap-elide.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-materialize.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-padding.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-param-copy.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-retcon-alloca.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-retcon-frame.ll CoroSplit: Fix coroutine splitting for retcon and retcon.once 2020-06-03 12:10:58 -07:00
coro-retcon-once-value2.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-retcon-once-value.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-retcon-resume-values2.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-retcon-resume-values.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-retcon-value.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-retcon.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-spill-after-phi.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-spill-corobegin.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
coro-split-00.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-split-01.ll [Coroutines][5/6] Add coroutine passes to pipeline 2020-02-19 00:57:14 -05:00
coro-split-02.ll [Coroutines] Optimize the lifespan of temporary co_await object 2020-06-28 10:18:15 -07:00
coro-split-alloc.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-split-dbg.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-split-eh-00.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-split-eh-01.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-split-hidden.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-split-musttail1.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-split-musttail2.ll [Coroutines] Remove alignment check in shouldBeMustTail 2020-04-07 09:07:34 +08:00
coro-split-musttail3.ll [Coroutines 2/2] Improve symmetric control transfer feature 2020-03-30 09:53:09 +08:00
coro-split-musttail.ll Re-land new pass manager coro-split and coro-elide 2020-02-19 00:11:23 -05:00
coro-split-sink-lifetime.ll [Coroutines] Optimize the lifespan of temporary co_await object 2020-06-28 10:18:15 -07:00
coro-swifterror.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
ex0.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
ex1.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
ex2.ll [Coroutines][New pass manager] Move CoroElide pass to right position 2020-03-01 21:48:24 +08:00
ex3.ll [Coroutines][New pass manager] Move CoroElide pass to right position 2020-03-01 21:48:24 +08:00
ex4.ll [Coroutines][5/6] Add coroutine passes to pipeline 2020-02-19 00:57:14 -05:00
ex5.ll Use optimal layout and preserve alloca alignment in coroutine frames. 2020-03-26 00:51:09 -04:00
no-suspend.ll [Coroutines] Fix PR45130 2020-03-20 11:27:08 +08:00
phi-coro-end.ll [Coroutines][5/6] Add coroutine passes to pipeline 2020-02-19 00:57:14 -05:00
restart-trigger.ll [Coroutines][5/6] Add coroutine passes to pipeline 2020-02-19 00:57:14 -05:00
smoketest.ll [Coroutines][5/6] Add coroutine passes to pipeline 2020-02-19 00:57:14 -05:00