Improve control-flow support in early-return detection.

Previously, early-return detection worked by ensuring that a function
had a maximum of one return statement, positioned at the end of the
function. However, this technique did not support if-else statements:

   if (a) { ...; return x; } else { ...; return y; }

This meant that many simple cases were unnecessarily wrapped in a do-
while loop to handle control flow issues that didn't actually occur.

Our early-return detection logic is now more flexible and looks for any
return statements that aren't at an exit point in the control flow,
instead of looking for exactly one return at the end of the code.

Change-Id: Iffe71adf2b9349ce8de42ba8301ccc52abe2882b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313418
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2 files changed