<div dir="ltr">It is not known in advance whether the final block is needed or not. It will become known once the user-authored body of the coroutine is emitted. I cannot defer creation of it up until that point, since final bb acts as a jump target for co_returns which could be in the user authored body and I need it to set up a jump destination beforehand.<div><br>Ack on formatting change.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 29, 2017 at 12:11 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Could you avoid creating the FinalBB unless it's needed rather than creating it and then adding it so it can be removed? (or, if the creation can't be avoided, maybe it's OK to 'delete FinalBB' here, rather than adding it for it to be removed later?)<br><br>(also bracing seems off - could you run your changes through clang-format? I'd expect '} else {' on the same line.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, May 23, 2017 at 6:54 PM Gor Nishanov via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: gornishanov<br>
Date: Tue May 23 20:54:37 2017<br>
New Revision: 303714<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=303714&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=303714&view=rev</a><br>
Log:<br>
[coroutines] Fix leak in CGCoroutine.cpp<br>
<br>
FinalBB need to be emitted even when unused to make sure it is deleted<br>
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/<wbr>CGCoroutine.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/<wbr>CGCoroutine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=303714&r1=303713&r2=303714&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/CodeGen/<wbr>CGCoroutine.cpp?rev=303714&r1=<wbr>303713&r2=303714&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/CodeGen/<wbr>CGCoroutine.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/<wbr>CGCoroutine.cpp Tue May 23 20:54:37 2017<br>
@@ -430,6 +430,10 @@ void CodeGenFunction::<wbr>EmitCoroutineBody(<br>
       CurCoro.Data-><wbr>CurrentAwaitKind = AwaitKind::Final;<br>
       EmitStmt(S.<wbr>getFinalSuspendStmt());<br>
     }<br>
+    else {<br>
+      // We don't need FinalBB. Emit it to make sure the block is deleted.<br>
+      EmitBlock(FinalBB, /*IsFinished=*/true);<br>
+    }<br>
   }<br>
<br>
   EmitBlock(RetBB);<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</blockquote></div><br></div>