r303714 - [coroutines] Fix leak in CGCoroutine.cpp

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Mon May 29 12:11:36 PDT 2017


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?)

(also bracing seems off - could you run your changes through clang-format?
I'd expect '} else {' on the same line.

On Tue, May 23, 2017 at 6:54 PM Gor Nishanov via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: gornishanov
> Date: Tue May 23 20:54:37 2017
> New Revision: 303714
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303714&view=rev
> Log:
> [coroutines] Fix leak in CGCoroutine.cpp
>
> FinalBB need to be emitted even when unused to make sure it is deleted
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGCoroutine.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=303714&r1=303713&r2=303714&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Tue May 23 20:54:37 2017
> @@ -430,6 +430,10 @@ void CodeGenFunction::EmitCoroutineBody(
>        CurCoro.Data->CurrentAwaitKind = AwaitKind::Final;
>        EmitStmt(S.getFinalSuspendStmt());
>      }
> +    else {
> +      // We don't need FinalBB. Emit it to make sure the block is deleted.
> +      EmitBlock(FinalBB, /*IsFinished=*/true);
> +    }
>    }
>
>    EmitBlock(RetBB);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170529/0b960752/attachment.html>


More information about the cfe-commits mailing list