Add 'kOnlySingleReturn' complexity type to the Inliner.

This can be used in followup CLs to test various forms of inliner
simplification. (More info: http://go/optimization-in-sksl-inliner )

Change-Id: Icd12a1ae1481c9aeacf3f11e85872fecfa972ec3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/384836
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index 011c443..90c5fad 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -200,12 +200,14 @@
                 return (fNumReturns >= fLimit) || INHERITED::visitStatement(stmt);
             }
             case Statement::Kind::kVarDeclaration: {
+                ++fNumNonReturnStatements;
                 if (fScopedBlockDepth > 1) {
                     fVariablesInBlocks = true;
                 }
                 return INHERITED::visitStatement(stmt);
             }
             case Statement::Kind::kBlock: {
+                // Don't count Block as a statement.
                 int depthIncrement = stmt.as<Block>().isScope() ? 1 : 0;
                 fScopedBlockDepth += depthIncrement;
                 bool result = INHERITED::visitStatement(stmt);
@@ -219,12 +221,18 @@
                 }
                 return result;
             }
+            case Statement::Kind::kNop:
+            case Statement::Kind::kInlineMarker:
+                // Don't count no-op statements.
+                return false;
             default:
+                ++fNumNonReturnStatements;
                 return INHERITED::visitStatement(stmt);
         }
     }
 
     int fNumReturns = 0;
+    int fNumNonReturnStatements = 0;
     int fDeepestReturn = 0;
     int fLimit = 0;
     int fScopedBlockDepth = 0;
@@ -246,7 +254,10 @@
     if (counter.fVariablesInBlocks && counter.fDeepestReturn > 1) {
         return ReturnComplexity::kScopedReturns;
     }
-    return ReturnComplexity::kSingleSafeReturn;
+    if (counter.fNumNonReturnStatements > 0) {
+        return ReturnComplexity::kSingleSafeReturn;
+    }
+    return ReturnComplexity::kOnlySingleReturn;
 }
 
 void Inliner::ensureScopedBlocks(Statement* inlinedBody, Statement* parentStmt) {