<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 - [coroutines] CoroSplit fails to add musttaill under -O2"
   href="https://bugs.llvm.org/show_bug.cgi?id=43070">43070</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[coroutines] CoroSplit fails to add musttaill under -O2
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Transformation Utilities
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gornishanov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22405" name="attach_22405" title="repro of a failure to add musttail to symmetric coroutine transfer">attachment 22405</a> <a href="attachment.cgi?id=22405&action=edit" title="repro of a failure to add musttail to symmetric coroutine transfer">[details]</a></span>
repro of a failure to add musttail to symmetric coroutine transfer

CoroSplit.cpp:simplifyTerminatorLeadingToRet function is deficient and does not
add musttail under -O2 for this simple example (also see attached musttail.ll
reproducer).

<a href="https://godbolt.org/z/7T_YnR">https://godbolt.org/z/7T_YnR</a>

// -O2 -stdlib=libc++ -std=c++2a -fstack-protector-all
// <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Need to add product version numbers"
   href="show_bug.cgi?id=1">Bug#1</a>, fails to insert musttail under -O2 (this-bug)
// <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Customize Bugzilla to have some LLVM flavah"
   href="show_bug.cgi?id=2">Bug#2</a>, fstack-protector-all interactions prevent tail call ([coroutines]
musttail and -fstack-protector-all interactions don't mix well)
#include <experimental/coroutine>
using namespace std::experimental;

struct coro {
  struct promise_type {
    suspend_always initial_suspend() { return {}; }
    suspend_always final_suspend() { return {}; }
    void return_void() {}
    void unhandled_exception(){}
    coro get_return_object() { return{};}
  };
};
coroutine_handle<> h;
struct sym {
  bool await_ready() { return false; }
  void await_resume() {}
  auto await_suspend(coroutine_handle<>) { return h; }
};
coro f() { co_await sym{}; }</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>