<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [Coroutine] Coroutine collect unneeded variables to coroutine frame."
href="https://bugs.llvm.org/show_bug.cgi?id=50372">50372</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Coroutine] Coroutine collect unneeded variables to coroutine frame.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++2a
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>yedeng.yd@linux.alibaba.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>I am not sure if it is OK to mark this with a bug. It is like a feature more to
me. I mark this with bugzilla since I found this:
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - [coroutines] coroutine frame layout doesn't reuse storage for local variables with non-overlapping lifetimes"
href="show_bug.cgi?id=45566">https://bugs.llvm.org/show_bug.cgi?id=45566</a>, which tells an optimization
instead of a bug.
The motivation example comes from: <a href="https://godbolt.org/z/c4zx9fE88">https://godbolt.org/z/c4zx9fE88</a>.
The key codes is:
```
cppcoro::task<int> simple() noexcept {
// 552 byte coroutine frame
char dummy[500];
for (int i = 0;i < 500; i++)
dummy[i] = rand()%8;
consume(dummy[rand()%500]);
co_await std::experimental::suspend_always{};
co_return 10;
}
```
Here we can find that the `dummy` isn't used across suspend point. So the dummy
could show as a stack variable. If compilers could optimize this, we could get
a smaller coroutine frame.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>