<div dir="ltr"><div dir="ltr">





<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-kerning:none">Gor,</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-kerning:none"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-kerning:none">Thanks for the reply!</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-kerning:none"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-kerning:none"><font face="arial, helvetica, sans-serif">><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>I am curious, what are you trying to achieve using the structural coroutine builtins directly?</font></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-kerning:none"><font face="arial, helvetica, sans-serif"><br></font></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><span class="gmail-s1" style="color:rgb(0,0,0);font-kerning:none"><font face="arial, helvetica, sans-serif">I actually wasn't trying to use these at all. What I was trying to do was learn more about how to write builtins for clang. I was adding a simple test builtin under </font></span><font color="#000000" face="arial, helvetica, sans-serif">__builtin_coro_size, and was modeling my builtin after it because it seemed like it was a simple enough way to return an integer. Anyway, long story short my builtin crashed clang so I did some investigating and found that many of the coroutine builtins also crashed clang. </font></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><font color="#000000" face="arial, helvetica, sans-serif"><br></font></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">I agree that it is probably a good idea to pull them because it doesn't look like they are used anywhere in either clang or libc++. If they are only for internal use, it is probably not I high priority though. It would be good to figure out what the issue was so that we can make sure it doesn't effect any other (more important) builtins. </p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><br></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">Best,</p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">Zoe</p></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 18, 2019 at 9:32 AM Gor Nishanov <<a href="mailto:gorn@microsoft.com">gorn@microsoft.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi Zoe, </div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thank you for the problem report.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I am curious, w<span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">hat are you trying to achieve using the structural coroutine builtins directly?</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
There are library builtins such as:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
__builtin_coro_resume, destroy, done and promise that are meant to be used by libraries to implement standard library support for coroutines.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Others, like __builtin_coro_begin, __builtin_coro_size, and are structural coroutine builtins (or more precisely their llvm equivalents) that are used by the front-ends to describe the coroutine structure and
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">
mostly<span> </span></span>were useful during coroutine development when we already had an llvm support, but, front-end work was not done, so, we used them to create simple coroutines in C by calling those builtins.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Going forward, we may pull structural builtins from clang altogether unless there are strong use cases that will justify their existence.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Cheers,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Gor</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_8810041390696173273appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_8810041390696173273divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Zoe Carver <<a href="mailto:z.zoelec2@gmail.com" target="_blank">z.zoelec2@gmail.com</a>><br>
<b>Sent:</b> Friday, March 15, 2019 7:18 PM<br>
<b>To:</b> Gor Nishanov; <a href="mailto:modocache@gmail.com" target="_blank">modocache@gmail.com</a><br>
<b>Cc:</b> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<b>Subject:</b> Clang crashing unexpectedly</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">
<div>I found that clang crashes when it should not. I brought up the issue in the LLVM IRC channel earlier and was told to send an email describing the problem (the LLVM Bugzilla has not verified me yet).</div>
<div><br>
</div>
<div>Here is a simple example of a program which crashes:</div>
<div><br>
</div>
<div>
<div style="color:rgb(0,0,0);background-color:rgb(255,255,254)">
<p class="gmail-m_8810041390696173273x_gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Courier">
<span class="gmail-m_8810041390696173273x_gmail-s1" style="font-variant-ligatures:no-common-ligatures">int main () {</span></p>
<p class="gmail-m_8810041390696173273x_gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Courier">
<span class="gmail-m_8810041390696173273x_gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-m_8810041390696173273x_gmail-Apple-tab-span" style="white-space:pre-wrap"></span>return __builtin_coro_size();</span></p>
<p class="gmail-m_8810041390696173273x_gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Courier">
<span class="gmail-m_8810041390696173273x_gmail-s1" style="font-variant-ligatures:no-common-ligatures">}</span></p>
</div>
</div>
<div><br>
</div>
<div>This behavior happens with many of the <span style="color:rgb(0,0,0);font-family:SFProText-Regular;font-size:12px">coroutine builtins. Take another example:</span></div>
<div>
<p class="gmail-m_8810041390696173273x_gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Courier">
<span class="gmail-m_8810041390696173273x_gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br>
</span></p>
<p class="gmail-m_8810041390696173273x_gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Courier">
<span class="gmail-m_8810041390696173273x_gmail-s1" style="font-variant-ligatures:no-common-ligatures">void* alloc = malloc(1024);</span></p>
<p class="gmail-m_8810041390696173273x_gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Courier">
<span class="gmail-m_8810041390696173273x_gmail-s1" style="font-variant-ligatures:no-common-ligatures">void* ptr = __builtin_coro_begin(alloc);</span></p>
<p class="gmail-m_8810041390696173273x_gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Courier">
<span class="gmail-m_8810041390696173273x_gmail-s1" style="font-variant-ligatures:no-common-ligatures">return __builtin_coro_free(ptr);</span></p>
<p class="gmail-m_8810041390696173273x_gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Courier">
<span class="gmail-m_8810041390696173273x_gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br>
</span></p>
</div>
<div>Here is a Godbolt to help demonstrate the problem: <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgodbolt.org%2Fz%2FL1v1rs&data=02%7C01%7Cgorn%40microsoft.com%7C8ecd3663aa914615972308d6a9b5a4c4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636882994952295430&sdata=m8mQetPJN77OIZZxob8ash73Zw%2FPuk%2FVKCdoEERMMj8%3D&reserved=0" target="_blank">https://godbolt.org/z/L1v1rs</a></div>
<div><br>
</div>
<div>I <i>think </i>(but totally might be wrong)<i> </i>that the issue has to do with clang ("CGBuiltin.cpp") returning a different type than was specified in "Builtins.def". </div>
<div><br>
</div>
<div>Anyway, let me know if you have questions. Hope this helps. </div>
</div>
</div>
</div>
</div>

</blockquote></div>