<div class="__aliyun_email_body_block"><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Hi all,</span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;">Background: </div><div  style="clear:both;">    Recently I am trying to enable the Coroutine Heap Elision in some code bases. Here is the introduction for Coroutine Heap Elision: <a  href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0981r0.html" target="_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0981r0.html</a>.</div><div  style="clear:both;">    Then in LLVM, we decide to elide one coroutine if we can prove coro.id, which marks a coroutine, passes coro.destroy for every path to exit entry of the current function.</div><div  style="clear:both;">    For example (uses if-else for simplicity):</div><div  style="clear:both;">```</div><div  style="clear:both;">coro foo() {</div><div  style="clear:both;">    %handle = call i8* @llvm.coro.id(...) </div><div  style="clear:both;">    ; some works</div><div  style="clear:both;">    if (...)</div><div  style="clear:both;">        call void @llvm.coro.destroy(%handle)</div><div  style="clear:both;">    else {</div><div  style="clear:both;">       other works</div><div  style="clear:both;">       <span  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;float:none;display:inline;">call void @llvm.coro.destroy(%handle)</span></div><div  style="clear:both;">    }</div><div  style="clear:both;">}</div><div  style="clear:both;">```</div><div  style="clear:both;">    And it would be elided.</div><div  style="clear:both;">    And if:</div><div  style="clear:both;">```</div><div  style="clear:both;"><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;clear:both;">coro foo() {</div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;clear:both;">    %handle = call i8* @llvm.coro.id(...) </div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;clear:both;">    ; some works</div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;clear:both;">    if (<span  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;float:none;display:inline;">%handle</span>)</div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;clear:both;">        call void @llvm.coro.destroy(%handle)</div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;clear:both;">}</div></div><div  style="clear:both;">```</div><div  style="clear:both;">   It wouldn't be elided. And I want to add a builtin to makr the corresponding coroutine is already dead. Let me call it `__builtin_coro_dead`. Then we can write:</div><div  style="clear:both;">```</div><div  style="clear:both;"><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;text-decoration:none;caret-color:#000000;color:#000000;background-color:#ffffff;clear:both;">coro foo() {</div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;text-decoration:none;caret-color:#000000;color:#000000;background-color:#ffffff;clear:both;">    %handle = call i8* @llvm.coro.id(...) </div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;text-decoration:none;caret-color:#000000;color:#000000;background-color:#ffffff;clear:both;">    ; some works</div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;text-decoration:none;caret-color:#000000;color:#000000;background-color:#ffffff;clear:both;">    if (<span  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;float:none;display:inline;">%handle</span>)</div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;text-decoration:none;caret-color:#000000;color:#000000;background-color:#ffffff;clear:both;">        call void @llvm.coro.destroy(%handle)</div></div><div  style="clear:both;"><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;text-decoration:none;caret-color:#000000;color:#000000;background-color:#ffffff;clear:both;">    call void @<span  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="caret-color:#000000;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;background-color:#ffffff;text-decoration:none;float:none;display:inline;">__builtin_coro_dead</span>(%handle)</div></div><div  style="clear:both;"><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;text-decoration:none;caret-color:#000000;color:#000000;background-color:#ffffff;clear:both;"></div><div  class=" __aliyun_node_has_color __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:.0px;text-transform:none;text-decoration:none;caret-color:#000000;color:#000000;background-color:#ffffff;clear:both;">}</div></div><div  style="clear:both;">```</div><div  style="clear:both;">    And it would be elided now.</div><div  style="clear:both;"><br ></div><div  style="clear:both;">Question:</div><div  style="clear:both;">    The described above is just a background. This thread doesn't aim to ask for whether it is good to use `__builtin_coro_dead` to solve the problems.</div><div  style="clear:both;">We could discuss it in another thread. Here my question is what's the principle to judge whether should we to add new builtins. Since the end users could</div><div  style="clear:both;">touch builtins while I can't search builtin in the Standard of C++ (N4878). So if we could add new builtins arbitrarily, it means the compiler writers could</div><div  style="clear:both;">change the language without changing the standard document, which is very very odd for me. I can't find related rules. So here to ask for your suggestion.</div><div  style="clear:both;"><br ></div><div  style="clear:both;">Thanks,</div><div  style="clear:both;">Chuanqi</div></div>