[PATCH] Make dead return statement detection more robust against changes in the CFG.

Manuel Klimek klimek at google.com
Fri May 23 09:36:27 PDT 2014


On Thu, May 22, 2014 at 6:42 PM, Jordan Rose <jordan_rose at apple.com> wrote:

> Okay, I think I understand now. If the first dead statement is the first
> expression in a return statement, and then there's a temporary destructors
> block, and then the return statement, then we'd still want to treat that as
> part of the return statement. And that happens right now because we don't
> optimize out the case with no control flow.
>
> I'm worried, though, that this will catch something in a dead else block
> and go sailing off the end to look for a return statement,


Btw, with the current implementation we will not sail off the end of
else-blocks:
+      if (Current->pred_size() > 1) {
+        // If there is more than one predecessor, we're dealing with
incoming
+        // control flow - if the return statement is in that block, it
might
+        // well be reachable via a different control flow, thus it's not
dead.
+        return false;
       }

Let me know if you want me to change anything, or if you have an idea for a
fundamentally different approach.

build a parent map, and then not actually find anything (of course). It
> seems like a fair amount of extra work. Then again, we have already decided
> to emit a diagnostic at this point, so I guess it's okay.
>
> http://reviews.llvm.org/D3638
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140523/635d118e/attachment.html>


More information about the cfe-commits mailing list