Migrate SkSL inliner tests to golden files.

Our lack of proper caps-bits controls in skslc affects the outcome of
one test: "InlinerWrapsEarlyReturnsWithDoWhileBlock" does not actually
emit the do-while block because the standalone caps bits don't enable
do-while support. This will be fixed in a followup CL that adds caps-bit
support to our tests.

A few tests were renamed for consistency, a few were simplified slightly
and one test was removed because it was simply redundant (there was a
second test that covered the exact same ground as
`ForWithReturnInsideCannotBeInlined`).

Change-Id: I2e3b97cb3aea331b6d806bdb865aa78c35c7a6b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316997
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni
index 6d5214c..8a21c28 100644
--- a/gn/sksl_tests.gni
+++ b/gn/sksl_tests.gni
@@ -59,5 +59,34 @@
   "$_tests/sksl/glsl/VectorConstructors.sksl",
   "$_tests/sksl/glsl/VectorFolding.sksl",
   "$_tests/sksl/glsl/VertexID.vert",
+  "$_tests/sksl/inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl",
+  "$_tests/sksl/inliner/DoWhileTestCannotBeInlined.sksl",
+  "$_tests/sksl/inliner/ForBodyMustBeInlinedIntoAScope.sksl",
+  "$_tests/sksl/inliner/ForInitializerExpressionsCanBeInlined.sksl",
+  "$_tests/sksl/inliner/ForWithReturnInsideCannotBeInlined.sksl",
+  "$_tests/sksl/inliner/ForWithoutReturnInsideCanBeInlined.sksl",
+  "$_tests/sksl/inliner/IfBodyMustBeInlinedIntoAScope.sksl",
+  "$_tests/sksl/inliner/IfElseBodyMustBeInlinedIntoAScope.sksl",
+  "$_tests/sksl/inliner/IfElseChainWithReturnsCanBeInlined.sksl",
+  "$_tests/sksl/inliner/IfTestCanBeInlined.sksl",
+  "$_tests/sksl/inliner/IfWithReturnsCanBeInlined.sksl",
+  "$_tests/sksl/inliner/InlineKeywordOverridesThreshold.sksl",
+  "$_tests/sksl/inliner/InlineThreshold.sksl",
+  "$_tests/sksl/inliner/InlineWithInoutArgument.sksl",
+  "$_tests/sksl/inliner/InlineWithModifiedArgument.sksl",
+  "$_tests/sksl/inliner/InlineWithNestedBigCalls.sksl",
+  "$_tests/sksl/inliner/InlineWithNestedCalls.sksl",
+  "$_tests/sksl/inliner/InlineWithUnmodifiedArgument.sksl",
+  "$_tests/sksl/inliner/InlineWithUnnecessaryBlocks.sksl",
   "$_tests/sksl/inliner/InlinerAvoidsVariableNameOverlap.sksl",
+  "$_tests/sksl/inliner/InlinerManglesNames.sksl",
+  "$_tests/sksl/inliner/InlinerWrapsEarlyReturnsWithDoWhileBlock.sksl",
+  "$_tests/sksl/inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl",
+  "$_tests/sksl/inliner/SwitchWithCastCanBeInlined.sksl",
+  "$_tests/sksl/inliner/SwitchWithReturnInsideCannotBeInlined.sksl",
+  "$_tests/sksl/inliner/SwitchWithoutReturnInsideCanBeInlined.sksl",
+  "$_tests/sksl/inliner/TernaryResultsCannotBeInlined.sksl",
+  "$_tests/sksl/inliner/TernaryTestCanBeInlined.sksl",
+  "$_tests/sksl/inliner/WhileBodyMustBeInlinedIntoAScope.sksl",
+  "$_tests/sksl/inliner/WhileTestCannotBeInlined.sksl",
 ]
diff --git a/gn/tests.gni b/gn/tests.gni
index 749bc7c..5ac9e8f 100644
--- a/gn/tests.gni
+++ b/gn/tests.gni
@@ -262,7 +262,6 @@
   "$_tests/SkSLErrorTest.cpp",
   "$_tests/SkSLFPTest.cpp",
   "$_tests/SkSLGLSLTest.cpp",
-  "$_tests/SkSLInlinerTest.cpp",
   "$_tests/SkSLInterpreterTest.cpp",
   "$_tests/SkSLMemoryLayoutTest.cpp",
   "$_tests/SkSLMetalTest.cpp",
diff --git a/tests/SkSLInlinerTest.cpp b/tests/SkSLInlinerTest.cpp
deleted file mode 100644
index ecbcdf3..0000000
--- a/tests/SkSLInlinerTest.cpp
+++ /dev/null
@@ -1,1240 +0,0 @@
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "src/sksl/SkSLCompiler.h"
-
-#include "tests/Test.h"
-
-// Note that the optimizer will aggressively kill dead code and substitute constants in place of
-// variables, so we have to jump through a few hoops to ensure that the code in these tests has the
-// necessary side-effects to remain live. In some cases we rely on the optimizer not (yet) being
-// smart enough to optimize around certain constructs; as the optimizer gets smarter it will
-// undoubtedly end up breaking some of these tests. That is a good thing, as long as the new code is
-// equivalent!
-
-static void test(skiatest::Reporter* r, const SkSL::Program::Settings& settings,
-                 const char* src, const char* expectedGLSL, SkSL::Program::Inputs* inputs,
-                 SkSL::Program::Kind kind = SkSL::Program::kFragment_Kind) {
-    SkSL::Compiler compiler;
-    SkSL::String output;
-    std::unique_ptr<SkSL::Program> program = compiler.convertProgram(kind, SkSL::String(src),
-                                                                     settings);
-    if (!program) {
-        SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
-    }
-    REPORTER_ASSERT(r, program);
-    if (program) {
-        *inputs = program->fInputs;
-        REPORTER_ASSERT(r, compiler.toGLSL(*program, &output));
-        if (program) {
-            SkSL::String skExpected(expectedGLSL);
-            if (output != skExpected) {
-                SkDebugf("GLSL MISMATCH:\nsource:\n%s\n\nexpected:\n'%s'\n\nreceived:\n'%s'",
-                         src, expectedGLSL, output.c_str());
-            }
-            REPORTER_ASSERT(r, output == skExpected);
-        }
-    }
-}
-
-static void test(skiatest::Reporter* r, const GrShaderCaps& caps,
-                 const char* src, const char* expectedGLSL,
-                 SkSL::Program::Kind kind = SkSL::Program::kFragment_Kind) {
-    SkSL::Program::Settings settings;
-    settings.fCaps = &caps;
-    SkSL::Program::Inputs inputs;
-    test(r, settings, src, expectedGLSL, &inputs, kind);
-}
-
-DEF_TEST(SkSLFunctionInlineThreshold, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         "void tooBig(inout int x) {"
-         "    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;"
-         "    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;"
-         "}"
-         "void main() { int x = 0; tooBig(x); tooBig(x); }",
-         "#version 400\n"
-         "void tooBig(inout int x) {\n"
-         "    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n"
-         "    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n"
-         "    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n"
-         "    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n    ++x;\n"
-         "    ++x;\n    ++x;\n"
-         "}\n"
-         "void main() {\n"
-         "    int x = 0;\n"
-         "    tooBig(x);\n"
-         "    tooBig(x);\n"
-         "}\n"
-         );
-}
-
-DEF_TEST(SkSLFunctionInlineKeywordOverridesThreshold, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         "inline void tooBig(inout int x) {"
-         "    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;"
-         "    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;"
-         "}"
-         "void main() { int y = 0; tooBig(y); }",
-         R"__GLSL__(#version 400
-void main() {
-    int y = 0;
-    {
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-        ++y;
-    }
-
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFunctionUnableToInlineReturnsInsideLoop, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         "inline void cantActuallyInline(inout int x) {"
-         "    for (;;) {"
-         "        ++x;"
-         "        if (x > 10) return;"
-         "    }"
-         "}"
-         "void main() { int x = 0; cantActuallyInline(x); }",
-         "#version 400\n"
-         "void cantActuallyInline(inout int x) {\n"
-         "    for (; ; ) {\n"
-         "        ++x;\n"
-         "        if (x > 10) return;\n"
-         "    }\n"
-         "}\n"
-         "void main() {\n"
-         "    int x = 0;\n"
-         "    cantActuallyInline(x);\n"
-         "}\n");
-}
-
-DEF_TEST(SkSLFunctionInlineWithUnmodifiedArgument, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         "half basic(half x) {"
-         "    return x * 2;"
-         "}"
-         "void main() {"
-         "    sk_FragColor.x = basic(1);"
-         "    half y = 2;"
-         "    sk_FragColor.y = basic(y);"
-         "}",
-         "#version 400\n"
-         "out vec4 sk_FragColor;\n"
-         "void main() {\n"
-         "    sk_FragColor.x = 2.0;\n"
-         "\n"
-         "    sk_FragColor.y = 4.0;\n"
-         "\n"
-         "}\n");
-}
-
-DEF_TEST(SkSLFunctionInlineWithModifiedArgument, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         "half parameterWrite(half x) {"
-         "    x *= 2;"
-         "    return x;"
-         "}"
-         "void main() {"
-         "    sk_FragColor.x = parameterWrite(1);"
-         "}",
-R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-void main() {
-    float _0_parameterWrite;
-    float _1_x = 1.0;
-    {
-        _1_x *= 2.0;
-        _0_parameterWrite = _1_x;
-    }
-
-    sk_FragColor.x = _0_parameterWrite;
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFunctionInlineWithInoutArgument, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         "void outParameter(inout half x) {"
-         "    x *= 2;"
-         "}"
-         "void main() {"
-         "    half x = 1;"
-         "    outParameter(x);"
-         "    sk_FragColor.x = x;"
-         "}",
-         R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-void main() {
-    float x = 1.0;
-    {
-        x *= 2.0;
-    }
-
-
-    sk_FragColor.x = x;
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFunctionInlineWithNestedCall, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         "void foo(out half x) {"
-         "    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;"
-         "    --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x;"
-         "    x = 42;"
-         "}"
-         "half bar(half y) {"
-         "    foo(y);"
-         "    return y;"
-         "}"
-         "void main() {"
-         "    half _1_y = 123;"  // make sure the inliner doesn't try to reuse this name
-         "    half z = 0;"
-         "    bar(z);"
-         "    sk_FragColor.x = z;"
-         "}",
-R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-void main() {
-    float _2_y = 0.0;
-    {
-        {
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            ++_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            --_2_y;
-            _2_y = 42.0;
-        }
-
-    }
-
-
-    sk_FragColor.x = 0.0;
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPTernaryExpressionsShouldNotInlineResults, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half count = 0;
-             bool test(half4 v) {
-                 return v.x <= 0.5;
-             }
-             half4 trueSide(half4 v) {
-                 count += 1;
-                 return half4(sin(v.x), sin(v.y), sin(v.z), sin(v.w));
-             }
-             half4 falseSide(half4 v) {
-                 count += 1;
-                 return half4(cos(v.y), cos(v.z), cos(v.w), cos(v.z));
-             }
-             void main() {
-                 sk_FragColor = test(color) ? trueSide(color) : falseSide(color);
-                 sk_FragColor *= count;
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-float count = 0.0;
-vec4 trueSide(vec4 v) {
-    count += 1.0;
-    return vec4(sin(v.x), sin(v.y), sin(v.z), sin(v.w));
-}
-vec4 falseSide(vec4 v) {
-    count += 1.0;
-    return vec4(cos(v.y), cos(v.z), cos(v.w), cos(v.z));
-}
-void main() {
-    bool _0_test;
-    {
-        _0_test = color.x <= 0.5;
-    }
-
-    sk_FragColor = _0_test ? trueSide(color) : falseSide(color);
-
-    sk_FragColor *= count;
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPShortCircuitEvaluationsCannotInlineRightHandSide, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             bool testA(half4 v) {
-                 return v.x <= 0.5;
-             }
-             bool testB(half4 v) {
-                 return v.x > 0.5;
-             }
-             void main() {
-                 sk_FragColor = half4(0);
-                 if (testA(color) && testB(color)) {
-                    sk_FragColor = half4(0.5);
-                 }
-                 if (testB(color) || testA(color)) {
-                    sk_FragColor = half4(1.0);
-                 }
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-bool testA(vec4 v) {
-    return v.x <= 0.5;
-}
-bool testB(vec4 v) {
-    return v.x > 0.5;
-}
-void main() {
-    sk_FragColor = vec4(0.0);
-    bool _0_testA;
-    {
-        _0_testA = color.x <= 0.5;
-    }
-
-    if (_0_testA && testB(color)) {
-        sk_FragColor = vec4(0.5);
-    }
-
-    bool _1_testB;
-    {
-        _1_testB = color.x > 0.5;
-    }
-
-    if (_1_testB || testA(color)) {
-        sk_FragColor = vec4(1.0);
-    }
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPWhileTestCannotBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             bool shouldLoop(half4 v) {
-                 return v.x < 0.5;
-             }
-             void main() {
-                 sk_FragColor = half4(0);
-                 while (shouldLoop(sk_FragColor)) {
-                     sk_FragColor += half4(0.125);
-                 }
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-bool shouldLoop(vec4 v) {
-    return v.x < 0.5;
-}
-void main() {
-    sk_FragColor = vec4(0.0);
-    while (shouldLoop(sk_FragColor)) {
-        sk_FragColor += vec4(0.125);
-    }
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPInlinedWhileBodyMustBeInAScope, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             half4 adjust(half4 v) {
-                 return v + half4(0.125);
-             }
-             void main() {
-                 sk_FragColor = half4(0);
-                 while (sk_FragColor.x < 0.5)
-                     sk_FragColor = adjust(sk_FragColor);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-void main() {
-    sk_FragColor = vec4(0.0);
-    while (sk_FragColor.x < 0.5) {
-        vec4 _0_adjust;
-        {
-            _0_adjust = sk_FragColor + vec4(0.125);
-        }
-
-        sk_FragColor = _0_adjust;
-    }
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPDoWhileTestCannotBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             bool shouldLoop(half4 v) {
-                 return v.x < 0.5;
-             }
-             void main() {
-                 sk_FragColor = half4(0);
-                 do {
-                     sk_FragColor += half4(0.125);
-                 } while (shouldLoop(sk_FragColor));
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-bool shouldLoop(vec4 v) {
-    return v.x < 0.5;
-}
-void main() {
-    sk_FragColor = vec4(0.0);
-    do {
-        sk_FragColor += vec4(0.125);
-    } while (shouldLoop(sk_FragColor));
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPInlinedDoWhileBodyMustBeInAScope, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             half4 adjust(half4 v) {
-                 return v + half4(0.125);
-             }
-             void main() {
-                 sk_FragColor = half4(0);
-                 do
-                     sk_FragColor = adjust(sk_FragColor);
-                 while (sk_FragColor.x < 0.5);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-void main() {
-    sk_FragColor = vec4(0.0);
-    do {
-        vec4 _0_adjust;
-        {
-            _0_adjust = sk_FragColor + vec4(0.125);
-        }
-
-        sk_FragColor = _0_adjust;
-    } while (sk_FragColor.x < 0.5);
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPOnlyForInitializerExpressionsCanBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             half4 initLoopVar() {
-                 return half4(0.0625);
-             }
-             bool shouldLoop(half4 v) {
-                 return v.x < 0.5;
-             }
-             half4 grow(half4 v) {
-                 return v + half4(0.125);
-             }
-             void main() {
-                 for (sk_FragColor = initLoopVar();
-                      shouldLoop(sk_FragColor);
-                      sk_FragColor = grow(sk_FragColor)) {
-                 }
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-bool shouldLoop(vec4 v) {
-    return v.x < 0.5;
-}
-vec4 grow(vec4 v) {
-    return v + vec4(0.125);
-}
-void main() {
-    for (sk_FragColor = vec4(0.0625);
-    shouldLoop(sk_FragColor); sk_FragColor = grow(sk_FragColor)) {
-    }
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPInlinedForBodyMustBeInAScope, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             half4 adjust(half4 v) {
-                 return v + half4(0.125);
-             }
-             void main() {
-                 sk_FragColor = half4(0);
-                 for (int x=0; x<4; ++x)
-                     sk_FragColor = adjust(sk_FragColor);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-void main() {
-    sk_FragColor = vec4(0.0);
-    for (int x = 0;x < 4; ++x) {
-        vec4 _0_adjust;
-        {
-            _0_adjust = sk_FragColor + vec4(0.125);
-        }
-
-        sk_FragColor = _0_adjust;
-    }
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPIfTestsCanBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             bool ifTest(half4 v) {
-                 return color.x >= 0.5;
-             }
-             void main() {
-                 if (ifTest(color))
-                     sk_FragColor = half4(1.0);
-                 else
-                     sk_FragColor = half4(0.5);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    bool _0_ifTest;
-    {
-        _0_ifTest = color.x >= 0.5;
-    }
-
-    if (_0_ifTest) sk_FragColor = vec4(1.0); else sk_FragColor = vec4(0.5);
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPInlinedIfBodyMustBeInAScope, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half4 ifBody() {
-                 return color + half4(0.125);
-             }
-             void main() {
-                 half4 c = color;
-                 if (c.x >= 0.5)
-                     c = ifBody();
-                 sk_FragColor = c;
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    vec4 c = color;
-    if (c.x >= 0.5) {
-        vec4 _0_ifBody;
-        {
-            _0_ifBody = color + vec4(0.125);
-        }
-
-        c = _0_ifBody;
-    }
-    sk_FragColor = c;
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPInlinedElseBodyMustBeInAScope, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half4 elseBody() {
-                 return color + half4(0.125);
-             }
-             void main() {
-                 half4 c = color;
-                 if (c.x >= 0.5)
-                     ;
-                 else
-                     c = elseBody();
-                 sk_FragColor = c;
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    vec4 c = color;
-    if (c.x >= 0.5) {
-    } else {
-        vec4 _0_elseBody;
-        {
-            _0_elseBody = color + vec4(0.125);
-        }
-
-        c = _0_elseBody;
-    }
-    sk_FragColor = c;
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPSwitchWithReturnInsideCannotBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half4 switchy(half4 c) {
-                 switch (int(c.x)) {
-                     case 0: return c.yyyy;
-                 }
-                 return c.zzzz;
-             }
-             void main() {
-                 sk_FragColor = switchy(color);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-vec4 switchy(vec4 c) {
-    switch (int(c.x)) {
-        case 0:
-            return c.yyyy;
-    }
-    return c.zzzz;
-}
-void main() {
-    sk_FragColor = switchy(color);
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPSwitchWithoutReturnInsideCanBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half4 switchy(half4 c) {
-                 half4 result;
-                 switch (int(c.x)) {
-                     case 0: result = c.yyyy;
-                 }
-                 result = c.zzzz;
-                 return result;
-             }
-             void main() {
-                 sk_FragColor = switchy(color);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    vec4 _0_switchy;
-    {
-        vec4 _1_result;
-        switch (int(color.x)) {
-            case 0:
-                _1_result = color.yyyy;
-        }
-        _1_result = color.zzzz;
-        _0_switchy = _1_result;
-    }
-
-    sk_FragColor = _0_switchy;
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPForLoopWithReturnInsideCannotBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half4 loopy(half4 c) {
-                 for (int x=0; x<5; ++x) {
-                     if (x == int(c.w)) return c.yyyy;
-                 }
-                 return c.zzzz;
-             }
-             void main() {
-                 sk_FragColor = loopy(color);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-vec4 loopy(vec4 c) {
-    for (int x = 0;x < 5; ++x) {
-        if (x == int(c.w)) return c.yyyy;
-    }
-    return c.zzzz;
-}
-void main() {
-    sk_FragColor = loopy(color);
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPSwitchWithCastCanBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half4 switchy(half4 c) {
-                 half4 result;
-                 switch (int(c.x)) {
-                     case 1: result = c.yyyy; break;
-                     default: result = c.zzzz; break;
-                 }
-                 return result;
-             }
-             void main() {
-                 sk_FragColor = switchy(color);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    vec4 _0_switchy;
-    {
-        vec4 _1_result;
-        switch (int(color.x)) {
-            case 1:
-                _1_result = color.yyyy;
-                break;
-            default:
-                _1_result = color.zzzz;
-                break;
-        }
-        _0_switchy = _1_result;
-    }
-
-    sk_FragColor = _0_switchy;
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPForLoopWithoutReturnInsideCanBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half4 loopy(half4 c) {
-                 half4 pix;
-                 for (int x=0; x<5; ++x) {
-                     if (x == int(c.w)) pix = c.yyyy;
-                 }
-                 pix = c.zzzz;
-                 return pix;
-             }
-             void main() {
-                 sk_FragColor = loopy(color);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    vec4 _0_loopy;
-    {
-        vec4 _1_pix;
-        for (int _2_x = 0;_2_x < 5; ++_2_x) {
-            if (_2_x == int(color.w)) _1_pix = color.yyyy;
-        }
-        _1_pix = color.zzzz;
-        _0_loopy = _1_pix;
-    }
-
-    sk_FragColor = _0_loopy;
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPInlinerManglesOverlappingNames, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half add(half a, half b) {
-                 half c = a + b;
-                 return c;
-             }
-             half mul(half a, half b) {
-                 return a * b;
-             }
-             half fma(half a, half b, half c) {
-                 return add(mul(a, b), c);
-             }
-             half4 main() {
-                 half a = fma(color.x, color.y, color.z);
-                 half b = fma(color.y, color.z, color.w);
-                 half c = fma(color.z, color.w, color.x);
-                 return half4(a, b, mul(c, c), mul(a, mul(b, c)));
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-uniform vec4 color;
-vec4 main() {
-    float _3_fma;
-    float _4_a = color.x;
-    float _5_b = color.y;
-    float _6_c = color.z;
-    {
-        float _7_0_mul;
-        {
-            _7_0_mul = _4_a * _5_b;
-        }
-
-        float _8_1_add;
-        {
-            float _9_2_c = _7_0_mul + _6_c;
-            _8_1_add = _9_2_c;
-        }
-
-        _3_fma = _8_1_add;
-
-    }
-
-    float a = _3_fma;
-
-    float _10_fma;
-    float _11_a = color.y;
-    float _12_b = color.z;
-    float _13_c = color.w;
-    {
-        float _14_0_mul;
-        {
-            _14_0_mul = _11_a * _12_b;
-        }
-
-        float _15_1_add;
-        {
-            float _16_2_c = _14_0_mul + _13_c;
-            _15_1_add = _16_2_c;
-        }
-
-        _10_fma = _15_1_add;
-
-    }
-
-    float b = _10_fma;
-
-    float _17_fma;
-    float _18_a = color.z;
-    float _19_b = color.w;
-    float _20_c = color.x;
-    {
-        float _21_0_mul;
-        {
-            _21_0_mul = _18_a * _19_b;
-        }
-
-        float _22_1_add;
-        {
-            float _23_2_c = _21_0_mul + _20_c;
-            _22_1_add = _23_2_c;
-        }
-
-        _17_fma = _22_1_add;
-
-    }
-
-    float c = _17_fma;
-
-    float _24_mul;
-    {
-        _24_mul = c * c;
-    }
-
-    float _25_mul;
-    {
-        _25_mul = b * c;
-    }
-
-    float _26_mul;
-    {
-        _26_mul = a * _25_mul;
-    }
-
-    return vec4(a, b, _24_mul, _26_mul);
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPIfStatementWithReturnInsideCanBeInlined, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half4 branchy(half4 c) {
-                 if (c.z == c.w) return c.yyyy; else return c.zzzz;
-             }
-             void main() {
-                 sk_FragColor = branchy(color);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    vec4 _0_branchy;
-    {
-        if (color.z == color.w) _0_branchy = color.yyyy; else _0_branchy = color.zzzz;
-    }
-
-    sk_FragColor = _0_branchy;
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPUnnecessaryBlocksDoNotAffectEarlyReturnDetection, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             half4 blocky(half4 c) {
-                 {
-                     return c;
-                 }
-             }
-             void main() {
-                 sk_FragColor = blocky(color);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    vec4 _0_blocky;
-    {
-        {
-            _0_blocky = color;
-        }
-    }
-
-    sk_FragColor = _0_blocky;
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPInlinedEarlyReturnsAreWrappedInDoWhileBlock, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             inline half4 returny(half4 c) {
-                 if (c.x > c.y) return c.xxxx;
-                 if (c.y > c.z) return c.yyyy;
-                 return c.zzzz;
-             }
-             void main() {
-                 sk_FragColor = returny(color);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    vec4 _0_returny;
-    do {
-        if (color.x > color.y) {
-            _0_returny = color.xxxx;
-            break;
-        }
-        if (color.y > color.z) {
-            _0_returny = color.yyyy;
-            break;
-        }
-        {
-            _0_returny = color.zzzz;
-            break;
-        }
-    } while (false);
-
-    sk_FragColor = _0_returny;
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFPEarlyReturnDetectionSupportsIfElse, r) {
-    // An if-else statement at the end of a function, with a return as the last statement on all
-    // paths, are not actually "early" returns. The inliner is able to recognize this pattern.
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         /*src=*/R"__SkSL__(
-             uniform half4 color;
-             inline half4 branchy(half4 c) {
-                 c *= 0.5;
-                 if (c.x > 0)
-                     return c.xxxx;
-                 else if (c.y > 0)
-                     return c.yyyy;
-                 else if (c.z > 0)
-                     return c.zzzz;
-                 else
-                     return c.wwww;
-             }
-             inline half4 branchyAndBlocky(half4 c) {{{
-                 if (c.x > 0) {
-                     half4 d = c * 0.5;
-                     return d.xxxx;
-                 } else {{{
-                     if (c.x < 0) {
-                         return c.wwww;
-                     } else {
-                         return c.yyyy;
-                     }
-                 }}}
-             }}}
-             void main() {
-                 sk_FragColor = branchy(color) * branchyAndBlocky(color);
-             }
-         )__SkSL__",
-         /*expectedGLSL=*/R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform vec4 color;
-void main() {
-    vec4 _0_branchy;
-    vec4 _1_c = color;
-    {
-        _1_c *= 0.5;
-        if (_1_c.x > 0.0) _0_branchy = _1_c.xxxx; else if (_1_c.y > 0.0) _0_branchy = _1_c.yyyy; else if (_1_c.z > 0.0) _0_branchy = _1_c.zzzz; else _0_branchy = _1_c.wwww;
-    }
-
-    vec4 _2_branchyAndBlocky;
-    {
-        {
-            {
-                if (color.x > 0.0) {
-                    vec4 _3_d = color * 0.5;
-                    _2_branchyAndBlocky = _3_d.xxxx;
-                } else {
-                    {
-                        {
-                            if (color.x < 0.0) {
-                                _2_branchyAndBlocky = color.wwww;
-                            } else {
-                                _2_branchyAndBlocky = color.yyyy;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    sk_FragColor = _0_branchy * _2_branchyAndBlocky;
-
-}
-)__GLSL__");
-}
-
-DEF_TEST(SkSLFunctionMultipleInlinesOnOneLine, r) {
-    test(r,
-         *SkSL::ShaderCapsFactory::Default(),
-         R"__SkSL__(
-            uniform half val;
-            half BigX(half x) {
-                ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
-                --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x;
-                x = 123;
-                return x;
-            }
-            half BigY(half x) {
-                ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
-                --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x;
-                x = 456;
-                return x;
-            }
-            void main() {
-                sk_FragColor = BigX(BigY(val)).xxxx;
-            }
-         )__SkSL__",
-         R"__GLSL__(#version 400
-out vec4 sk_FragColor;
-uniform float val;
-void main() {
-    float _1_x = val;
-    {
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        ++_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        --_1_x;
-        _1_x = 456.0;
-    }
-    float _3_x = 456.0;
-    {
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        ++_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        --_3_x;
-        _3_x = 123.0;
-    }
-    sk_FragColor = vec4(123.0);
-
-
-}
-)__GLSL__");
-}
diff --git a/tests/sksl/inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl b/tests/sksl/inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl
new file mode 100644
index 0000000..57fafc5
--- /dev/null
+++ b/tests/sksl/inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl
@@ -0,0 +1,10 @@
+inline half4 adjust(half4 v) {
+    return v + half4(0.125);
+}
+
+void main() {
+    sk_FragColor = half4(0);
+    do
+        sk_FragColor = adjust(sk_FragColor);
+    while (sk_FragColor.x < 0.5);
+}
diff --git a/tests/sksl/inliner/DoWhileTestCannotBeInlined.sksl b/tests/sksl/inliner/DoWhileTestCannotBeInlined.sksl
new file mode 100644
index 0000000..1697053
--- /dev/null
+++ b/tests/sksl/inliner/DoWhileTestCannotBeInlined.sksl
@@ -0,0 +1,10 @@
+inline bool shouldLoop(half4 v) {
+    return v.x < 0.5;
+}
+
+void main() {
+    sk_FragColor = half4(0);
+    do {
+        sk_FragColor += half4(0.125);
+    } while (shouldLoop(sk_FragColor));
+}
diff --git a/tests/sksl/inliner/ForBodyMustBeInlinedIntoAScope.sksl b/tests/sksl/inliner/ForBodyMustBeInlinedIntoAScope.sksl
new file mode 100644
index 0000000..2fc8e26
--- /dev/null
+++ b/tests/sksl/inliner/ForBodyMustBeInlinedIntoAScope.sksl
@@ -0,0 +1,9 @@
+inline half4 adjust(half4 v) {
+    return v + half4(0.125);
+}
+
+void main() {
+    sk_FragColor = half4(0);
+    for (int x=0; x<4; ++x)
+        sk_FragColor = adjust(sk_FragColor);
+}
diff --git a/tests/sksl/inliner/ForInitializerExpressionsCanBeInlined.sksl b/tests/sksl/inliner/ForInitializerExpressionsCanBeInlined.sksl
new file mode 100644
index 0000000..d793be1
--- /dev/null
+++ b/tests/sksl/inliner/ForInitializerExpressionsCanBeInlined.sksl
@@ -0,0 +1,18 @@
+inline half4 initLoopVar() {
+    return half4(0.0625);
+}
+
+inline bool shouldLoop(half4 v) {
+    return v.x < 0.5;
+}
+
+inline half4 grow(half4 v) {
+    return v + half4(0.125);
+}
+
+void main() {
+    for (sk_FragColor = initLoopVar();
+         shouldLoop(sk_FragColor);
+         sk_FragColor = grow(sk_FragColor)) {
+    }
+}
diff --git a/tests/sksl/inliner/ForWithReturnInsideCannotBeInlined.sksl b/tests/sksl/inliner/ForWithReturnInsideCannotBeInlined.sksl
new file mode 100644
index 0000000..39998dc
--- /dev/null
+++ b/tests/sksl/inliner/ForWithReturnInsideCannotBeInlined.sksl
@@ -0,0 +1,12 @@
+uniform int value;
+
+inline half4 loopy(int v) {
+    for (int x=0; x<5; ++x) {
+        if (x == v) return half4(0.5);
+    }
+    return half4(1.0);
+}
+
+void main() {
+    sk_FragColor = loopy(value);
+}
diff --git a/tests/sksl/inliner/ForWithoutReturnInsideCanBeInlined.sksl b/tests/sksl/inliner/ForWithoutReturnInsideCanBeInlined.sksl
new file mode 100644
index 0000000..178d1e1
--- /dev/null
+++ b/tests/sksl/inliner/ForWithoutReturnInsideCanBeInlined.sksl
@@ -0,0 +1,13 @@
+uniform int value;
+
+inline half4 loopy(int v) {
+    half4 result = half4(1.0);
+    for (int x=0; x<5; ++x) {
+        if (x == v) result = half4(0.5);
+    }
+    return result;
+}
+
+void main() {
+    sk_FragColor = loopy(value);
+}
diff --git a/tests/sksl/inliner/IfBodyMustBeInlinedIntoAScope.sksl b/tests/sksl/inliner/IfBodyMustBeInlinedIntoAScope.sksl
new file mode 100644
index 0000000..fd18de6
--- /dev/null
+++ b/tests/sksl/inliner/IfBodyMustBeInlinedIntoAScope.sksl
@@ -0,0 +1,12 @@
+uniform half4 color;
+
+inline half4 ifBody() {
+    return color + half4(0.125);
+}
+
+void main() {
+    half4 c = color;
+    if (c.x >= 0.5)
+        c = ifBody();
+    sk_FragColor = c;
+}
diff --git a/tests/sksl/inliner/IfElseBodyMustBeInlinedIntoAScope.sksl b/tests/sksl/inliner/IfElseBodyMustBeInlinedIntoAScope.sksl
new file mode 100644
index 0000000..d6bb0ed
--- /dev/null
+++ b/tests/sksl/inliner/IfElseBodyMustBeInlinedIntoAScope.sksl
@@ -0,0 +1,14 @@
+uniform half4 color;
+
+inline half4 elseBody() {
+    return color + half4(0.125);
+}
+
+void main() {
+    half4 c = color;
+    if (c.x >= 0.5)
+        ;
+    else
+        c = elseBody();
+    sk_FragColor = c;
+}
diff --git a/tests/sksl/inliner/IfElseChainWithReturnsCanBeInlined.sksl b/tests/sksl/inliner/IfElseChainWithReturnsCanBeInlined.sksl
new file mode 100644
index 0000000..50cc320
--- /dev/null
+++ b/tests/sksl/inliner/IfElseChainWithReturnsCanBeInlined.sksl
@@ -0,0 +1,33 @@
+// An if-else statement at the end of a function, with a return as the last statement on all
+// paths, are not actually "early" returns. The inliner is able to recognize this pattern.
+
+uniform half4 color;
+
+inline half4 branchy(half4 c) {
+    c *= 0.5;
+    if (c.x > 0)
+        return c.xxxx;
+    else if (c.y > 0)
+        return c.yyyy;
+    else if (c.z > 0)
+        return c.zzzz;
+    else
+        return c.wwww;
+}
+
+inline half4 branchyAndBlocky(half4 c) {{{
+    if (c.x > 0) {
+        half4 d = c * 0.5;
+        return d.xxxx;
+    } else {{{
+        if (c.x < 0) {
+            return c.wwww;
+        } else {
+            return c.yyyy;
+        }
+    }}}
+}}}
+
+void main() {
+    sk_FragColor = branchy(color) * branchyAndBlocky(color);
+}
diff --git a/tests/sksl/inliner/IfTestCanBeInlined.sksl b/tests/sksl/inliner/IfTestCanBeInlined.sksl
new file mode 100644
index 0000000..ac3e0db
--- /dev/null
+++ b/tests/sksl/inliner/IfTestCanBeInlined.sksl
@@ -0,0 +1,12 @@
+uniform half4 color;
+
+inline bool ifTest(half4 v) {
+    return color.x >= 0.5;
+}
+
+void main() {
+    if (ifTest(color))
+        sk_FragColor = half4(1.0);
+    else
+        sk_FragColor = half4(0.5);
+}
diff --git a/tests/sksl/inliner/IfWithReturnsCanBeInlined.sksl b/tests/sksl/inliner/IfWithReturnsCanBeInlined.sksl
new file mode 100644
index 0000000..fc53428
--- /dev/null
+++ b/tests/sksl/inliner/IfWithReturnsCanBeInlined.sksl
@@ -0,0 +1,9 @@
+uniform half4 color;
+
+half4 branchy(half4 c) {
+    if (c.z == c.w) return c.yyyy; else return c.zzzz;
+}
+
+void main() {
+    sk_FragColor = branchy(color);
+}
diff --git a/tests/sksl/inliner/InlineKeywordOverridesThreshold.sksl b/tests/sksl/inliner/InlineKeywordOverridesThreshold.sksl
new file mode 100644
index 0000000..0270848
--- /dev/null
+++ b/tests/sksl/inliner/InlineKeywordOverridesThreshold.sksl
@@ -0,0 +1,10 @@
+inline void tooBig(inout int x) {
+    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
+    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
+}
+
+void main() {
+    int y = 0;
+    tooBig(y);
+    tooBig(y);
+}
diff --git a/tests/sksl/inliner/InlineThreshold.sksl b/tests/sksl/inliner/InlineThreshold.sksl
new file mode 100644
index 0000000..bfca1f0c
--- /dev/null
+++ b/tests/sksl/inliner/InlineThreshold.sksl
@@ -0,0 +1,10 @@
+void tooBig(inout int x) {
+    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
+    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
+}
+
+void main() {
+    int x = 0;
+    tooBig(x);
+    tooBig(x);
+}
diff --git a/tests/sksl/inliner/InlineWithInoutArgument.sksl b/tests/sksl/inliner/InlineWithInoutArgument.sksl
new file mode 100644
index 0000000..144dcec
--- /dev/null
+++ b/tests/sksl/inliner/InlineWithInoutArgument.sksl
@@ -0,0 +1,9 @@
+inline void outParameter(inout half x) {
+    x *= 2;
+}
+
+void main() {
+    half x = 1;
+    outParameter(x);
+    sk_FragColor.x = x;
+}
diff --git a/tests/sksl/inliner/InlineWithModifiedArgument.sksl b/tests/sksl/inliner/InlineWithModifiedArgument.sksl
new file mode 100644
index 0000000..4574475
--- /dev/null
+++ b/tests/sksl/inliner/InlineWithModifiedArgument.sksl
@@ -0,0 +1,8 @@
+inline half parameterWrite(half x) {
+    x *= 2;
+    return x;
+}
+
+void main() {
+    sk_FragColor.x = parameterWrite(1);
+}
diff --git a/tests/sksl/inliner/InlineWithNestedBigCalls.sksl b/tests/sksl/inliner/InlineWithNestedBigCalls.sksl
new file mode 100644
index 0000000..877c7b9
--- /dev/null
+++ b/tests/sksl/inliner/InlineWithNestedBigCalls.sksl
@@ -0,0 +1,19 @@
+uniform half val;
+
+inline half BigX(half x) {
+    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
+    --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x;
+    x = 123;
+    return x;
+}
+
+inline half BigY(half x) {
+    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
+    --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x;
+    x = 456;
+    return x;
+}
+
+void main() {
+    sk_FragColor = BigX(BigY(val)).xxxx;
+}
diff --git a/tests/sksl/inliner/InlineWithNestedCalls.sksl b/tests/sksl/inliner/InlineWithNestedCalls.sksl
new file mode 100644
index 0000000..a5b8244
--- /dev/null
+++ b/tests/sksl/inliner/InlineWithNestedCalls.sksl
@@ -0,0 +1,17 @@
+void foo(out half x) {
+    ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
+    --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x;
+    x = 42;
+}
+
+half bar(half y) {
+    foo(y);
+    return y;
+}
+
+void main() {
+    half _1_y = 123; // the inliner shouldn't try to reuse this name
+    half z = 0;
+    bar(z);
+    sk_FragColor.x = z;
+}
diff --git a/tests/sksl/inliner/InlineWithUnmodifiedArgument.sksl b/tests/sksl/inliner/InlineWithUnmodifiedArgument.sksl
new file mode 100644
index 0000000..ad6f596
--- /dev/null
+++ b/tests/sksl/inliner/InlineWithUnmodifiedArgument.sksl
@@ -0,0 +1,9 @@
+inline half basic(half x) {
+    return x * 2;
+}
+
+void main() {
+    sk_FragColor.x = basic(1);
+    half y = 2;
+    sk_FragColor.y = basic(y);
+}
diff --git a/tests/sksl/inliner/InlineWithUnnecessaryBlocks.sksl b/tests/sksl/inliner/InlineWithUnnecessaryBlocks.sksl
new file mode 100644
index 0000000..77d9d37
--- /dev/null
+++ b/tests/sksl/inliner/InlineWithUnnecessaryBlocks.sksl
@@ -0,0 +1,11 @@
+uniform half4 color;
+
+half4 blocky(half4 c) {
+    {
+        return c;
+    }
+}
+
+void main() {
+    sk_FragColor = blocky(color);
+}
diff --git a/tests/sksl/inliner/InlinerAvoidsVariableNameOverlap.sksl b/tests/sksl/inliner/InlinerAvoidsVariableNameOverlap.sksl
index ab73e43..cf8c8f5 100644
--- a/tests/sksl/inliner/InlinerAvoidsVariableNameOverlap.sksl
+++ b/tests/sksl/inliner/InlinerAvoidsVariableNameOverlap.sksl
@@ -1,14 +1,17 @@
 in half2 x;
+
 inline half2 InlineB(half2 tmp)
 {
     half2 reusedName = tmp + half2(3, 4);
     return reusedName;
 }
+
 inline half2 InlineA()
 {
     half2 reusedName = x + half2(1, 2);
     return InlineB(reusedName);
 }
+
 half4 main()
 {
     return InlineA().xyxy;
diff --git a/tests/sksl/inliner/InlinerManglesNames.sksl b/tests/sksl/inliner/InlinerManglesNames.sksl
new file mode 100644
index 0000000..23014a3
--- /dev/null
+++ b/tests/sksl/inliner/InlinerManglesNames.sksl
@@ -0,0 +1,21 @@
+uniform half4 color;
+
+half add(half a, half b) {
+    half c = a + b;
+    return c;
+}
+
+half mul(half a, half b) {
+    return a * b;
+}
+
+half fma(half a, half b, half c) {
+    return add(mul(a, b), c);
+}
+
+half4 main() {
+    half a = fma(color.x, color.y, color.z);
+    half b = fma(color.y, color.z, color.w);
+    half c = fma(color.z, color.w, color.x);
+    return half4(a, b, mul(c, c), mul(a, mul(b, c)));
+}
diff --git a/tests/sksl/inliner/InlinerWrapsEarlyReturnsWithDoWhileBlock.sksl b/tests/sksl/inliner/InlinerWrapsEarlyReturnsWithDoWhileBlock.sksl
new file mode 100644
index 0000000..7d7aa1c
--- /dev/null
+++ b/tests/sksl/inliner/InlinerWrapsEarlyReturnsWithDoWhileBlock.sksl
@@ -0,0 +1,15 @@
+uniform half4 color;
+
+// TODO(johnstiles): the skslc standalone caps bits do not enable do-while support, so this test
+// does not actually perform as described; the `returny` function is not inlined at all. This will
+// be fixed when customizable caps-bit support is added to the golden tests.
+
+inline half4 returny(half4 c) {
+    if (c.x > c.y) return c.xxxx;
+    if (c.y > c.z) return c.yyyy;
+    return c.zzzz;
+}
+
+void main() {
+    sk_FragColor = returny(color);
+}
diff --git a/tests/sksl/inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl b/tests/sksl/inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl
new file mode 100644
index 0000000..fef0d61
--- /dev/null
+++ b/tests/sksl/inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl
@@ -0,0 +1,19 @@
+uniform half4 color;
+
+inline bool testA(half4 v) {
+    return v.x <= 0.5;
+}
+
+inline bool testB(half4 v) {
+    return v.x > 0.5;
+}
+
+void main() {
+    sk_FragColor = half4(0);
+    if (testA(color) && testB(color)) {
+       sk_FragColor = half4(0.5);
+    }
+    if (testB(color) || testA(color)) {
+       sk_FragColor = half4(1.0);
+    }
+}
diff --git a/tests/sksl/inliner/SwitchWithCastCanBeInlined.sksl b/tests/sksl/inliner/SwitchWithCastCanBeInlined.sksl
new file mode 100644
index 0000000..6658400
--- /dev/null
+++ b/tests/sksl/inliner/SwitchWithCastCanBeInlined.sksl
@@ -0,0 +1,14 @@
+uniform half4 color;
+
+inline half4 switchy(half4 c) {
+    half4 result;
+    switch (int(c.x)) {
+        case 1: result = c.yyyy; break;
+        default: result = c.zzzz; break;
+    }
+    return result;
+}
+
+void main() {
+    sk_FragColor = switchy(color);
+}
diff --git a/tests/sksl/inliner/SwitchWithReturnInsideCannotBeInlined.sksl b/tests/sksl/inliner/SwitchWithReturnInsideCannotBeInlined.sksl
new file mode 100644
index 0000000..1e4ec7c
--- /dev/null
+++ b/tests/sksl/inliner/SwitchWithReturnInsideCannotBeInlined.sksl
@@ -0,0 +1,12 @@
+uniform int value;
+
+inline half4 switchy(int v) {
+    switch (v) {
+        case 0: return half4(0.5);
+    }
+    return half4(1.0);
+}
+
+void main() {
+    sk_FragColor = switchy(value);
+}
diff --git a/tests/sksl/inliner/SwitchWithoutReturnInsideCanBeInlined.sksl b/tests/sksl/inliner/SwitchWithoutReturnInsideCanBeInlined.sksl
new file mode 100644
index 0000000..ee5afb8
--- /dev/null
+++ b/tests/sksl/inliner/SwitchWithoutReturnInsideCanBeInlined.sksl
@@ -0,0 +1,13 @@
+uniform int value;
+
+inline half4 switchy(int v) {
+    half4 result = half4(1.0);
+    switch (v) {
+        case 0: result = half4(0.5);
+    }
+    return result;
+}
+
+void main() {
+    sk_FragColor = switchy(value);
+}
diff --git a/tests/sksl/inliner/TernaryResultsCannotBeInlined.sksl b/tests/sksl/inliner/TernaryResultsCannotBeInlined.sksl
new file mode 100644
index 0000000..b961ae1
--- /dev/null
+++ b/tests/sksl/inliner/TernaryResultsCannotBeInlined.sksl
@@ -0,0 +1,17 @@
+uniform half4 color;
+half count = 0;
+
+inline half4 trueSide(half4 v) {
+    count += 1;
+    return half4(sin(v.x), sin(v.y), sin(v.z), sin(v.w));
+}
+
+inline half4 falseSide(half4 v) {
+    count += 1;
+    return half4(cos(v.y), cos(v.z), cos(v.w), cos(v.z));
+}
+
+void main() {
+    sk_FragColor = (color.x <= 0.5) ? trueSide(color) : falseSide(color);
+    sk_FragColor *= count;
+}
diff --git a/tests/sksl/inliner/TernaryTestCanBeInlined.sksl b/tests/sksl/inliner/TernaryTestCanBeInlined.sksl
new file mode 100644
index 0000000..25523eb
--- /dev/null
+++ b/tests/sksl/inliner/TernaryTestCanBeInlined.sksl
@@ -0,0 +1,9 @@
+uniform half4 color;
+
+inline bool test(half4 v) {
+    return v.x <= 0.5;
+}
+
+void main() {
+    sk_FragColor = test(color) ? half4(0.5) : half4(1.0);
+}
diff --git a/tests/sksl/inliner/WhileBodyMustBeInlinedIntoAScope.sksl b/tests/sksl/inliner/WhileBodyMustBeInlinedIntoAScope.sksl
new file mode 100644
index 0000000..9adaf4a
--- /dev/null
+++ b/tests/sksl/inliner/WhileBodyMustBeInlinedIntoAScope.sksl
@@ -0,0 +1,9 @@
+inline half4 adjust(half4 v) {
+    return v + half4(0.125);
+}
+
+void main() {
+    sk_FragColor = half4(0);
+    while (sk_FragColor.x < 0.5)
+        sk_FragColor = adjust(sk_FragColor);
+}
diff --git a/tests/sksl/inliner/WhileTestCannotBeInlined.sksl b/tests/sksl/inliner/WhileTestCannotBeInlined.sksl
new file mode 100644
index 0000000..2f734e7
--- /dev/null
+++ b/tests/sksl/inliner/WhileTestCannotBeInlined.sksl
@@ -0,0 +1,10 @@
+inline bool shouldLoop(half4 v) {
+    return v.x < 0.5;
+}
+
+void main() {
+    sk_FragColor = half4(0);
+    while (shouldLoop(sk_FragColor)) {
+        sk_FragColor += half4(0.125);
+    }
+}
diff --git a/tests/sksl/inliner/golden/DoWhileBodyMustBeInlinedIntoAScope.glsl b/tests/sksl/inliner/golden/DoWhileBodyMustBeInlinedIntoAScope.glsl
new file mode 100644
index 0000000..d72d44a
--- /dev/null
+++ b/tests/sksl/inliner/golden/DoWhileBodyMustBeInlinedIntoAScope.glsl
@@ -0,0 +1,15 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+void main() {
+    sk_FragColor = vec4(0.0);
+    do {
+        mediump vec4 _0_adjust;
+        {
+            _0_adjust = sk_FragColor + vec4(0.125);
+        }
+
+        sk_FragColor = _0_adjust;
+    } while (sk_FragColor.x < 0.5);
+}
diff --git a/tests/sksl/inliner/golden/DoWhileTestCannotBeInlined.glsl b/tests/sksl/inliner/golden/DoWhileTestCannotBeInlined.glsl
new file mode 100644
index 0000000..bc4f9d0
--- /dev/null
+++ b/tests/sksl/inliner/golden/DoWhileTestCannotBeInlined.glsl
@@ -0,0 +1,13 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+bool shouldLoop(mediump vec4 v) {
+    return v.x < 0.5;
+}
+void main() {
+    sk_FragColor = vec4(0.0);
+    do {
+        sk_FragColor += vec4(0.125);
+    } while (shouldLoop(sk_FragColor));
+}
diff --git a/tests/sksl/inliner/golden/ForBodyMustBeInlinedIntoAScope.glsl b/tests/sksl/inliner/golden/ForBodyMustBeInlinedIntoAScope.glsl
new file mode 100644
index 0000000..bf2e272
--- /dev/null
+++ b/tests/sksl/inliner/golden/ForBodyMustBeInlinedIntoAScope.glsl
@@ -0,0 +1,15 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+void main() {
+    sk_FragColor = vec4(0.0);
+    for (highp int x = 0;x < 4; ++x) {
+        mediump vec4 _0_adjust;
+        {
+            _0_adjust = sk_FragColor + vec4(0.125);
+        }
+
+        sk_FragColor = _0_adjust;
+    }
+}
diff --git a/tests/sksl/inliner/golden/ForInitializerExpressionsCanBeInlined.glsl b/tests/sksl/inliner/golden/ForInitializerExpressionsCanBeInlined.glsl
new file mode 100644
index 0000000..fe96044
--- /dev/null
+++ b/tests/sksl/inliner/golden/ForInitializerExpressionsCanBeInlined.glsl
@@ -0,0 +1,15 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+bool shouldLoop(mediump vec4 v) {
+    return v.x < 0.5;
+}
+mediump vec4 grow(mediump vec4 v) {
+    return v + vec4(0.125);
+}
+void main() {
+    for (sk_FragColor = vec4(0.0625);
+    shouldLoop(sk_FragColor); sk_FragColor = grow(sk_FragColor)) {
+    }
+}
diff --git a/tests/sksl/inliner/golden/ForWithReturnInsideCannotBeInlined.glsl b/tests/sksl/inliner/golden/ForWithReturnInsideCannotBeInlined.glsl
new file mode 100644
index 0000000..3495e47
--- /dev/null
+++ b/tests/sksl/inliner/golden/ForWithReturnInsideCannotBeInlined.glsl
@@ -0,0 +1,14 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform highp int value;
+mediump vec4 loopy(highp int v) {
+    for (highp int x = 0;x < 5; ++x) {
+        if (x == v) return vec4(0.5);
+    }
+    return vec4(1.0);
+}
+void main() {
+    sk_FragColor = loopy(value);
+}
diff --git a/tests/sksl/inliner/golden/ForWithoutReturnInsideCanBeInlined.glsl b/tests/sksl/inliner/golden/ForWithoutReturnInsideCanBeInlined.glsl
new file mode 100644
index 0000000..9d09bf1
--- /dev/null
+++ b/tests/sksl/inliner/golden/ForWithoutReturnInsideCanBeInlined.glsl
@@ -0,0 +1,18 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform highp int value;
+void main() {
+    mediump vec4 _0_loopy;
+    {
+        mediump vec4 _1_result = vec4(1.0);
+        for (highp int _2_x = 0;_2_x < 5; ++_2_x) {
+            if (_2_x == value) _1_result = vec4(0.5);
+        }
+        _0_loopy = _1_result;
+    }
+
+    sk_FragColor = _0_loopy;
+
+}
diff --git a/tests/sksl/inliner/golden/IfBodyMustBeInlinedIntoAScope.glsl b/tests/sksl/inliner/golden/IfBodyMustBeInlinedIntoAScope.glsl
new file mode 100644
index 0000000..d3690b9
--- /dev/null
+++ b/tests/sksl/inliner/golden/IfBodyMustBeInlinedIntoAScope.glsl
@@ -0,0 +1,17 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+void main() {
+    mediump vec4 c = color;
+    if (c.x >= 0.5) {
+        mediump vec4 _0_ifBody;
+        {
+            _0_ifBody = color + vec4(0.125);
+        }
+
+        c = _0_ifBody;
+    }
+    sk_FragColor = c;
+}
diff --git a/tests/sksl/inliner/golden/IfElseBodyMustBeInlinedIntoAScope.glsl b/tests/sksl/inliner/golden/IfElseBodyMustBeInlinedIntoAScope.glsl
new file mode 100644
index 0000000..1c23bb8
--- /dev/null
+++ b/tests/sksl/inliner/golden/IfElseBodyMustBeInlinedIntoAScope.glsl
@@ -0,0 +1,18 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+void main() {
+    mediump vec4 c = color;
+    if (c.x >= 0.5) {
+    } else {
+        mediump vec4 _0_elseBody;
+        {
+            _0_elseBody = color + vec4(0.125);
+        }
+
+        c = _0_elseBody;
+    }
+    sk_FragColor = c;
+}
diff --git a/tests/sksl/inliner/golden/IfElseChainWithReturnsCanBeInlined.glsl b/tests/sksl/inliner/golden/IfElseChainWithReturnsCanBeInlined.glsl
new file mode 100644
index 0000000..cdea0a9
--- /dev/null
+++ b/tests/sksl/inliner/golden/IfElseChainWithReturnsCanBeInlined.glsl
@@ -0,0 +1,38 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+void main() {
+    mediump vec4 _0_branchy;
+    mediump vec4 _1_c = color;
+    {
+        _1_c *= 0.5;
+        if (_1_c.x > 0.0) _0_branchy = _1_c.xxxx; else if (_1_c.y > 0.0) _0_branchy = _1_c.yyyy; else if (_1_c.z > 0.0) _0_branchy = _1_c.zzzz; else _0_branchy = _1_c.wwww;
+    }
+
+    mediump vec4 _2_branchyAndBlocky;
+    {
+        {
+            {
+                if (color.x > 0.0) {
+                    mediump vec4 _3_d = color * 0.5;
+                    _2_branchyAndBlocky = _3_d.xxxx;
+                } else {
+                    {
+                        {
+                            if (color.x < 0.0) {
+                                _2_branchyAndBlocky = color.wwww;
+                            } else {
+                                _2_branchyAndBlocky = color.yyyy;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    sk_FragColor = _0_branchy * _2_branchyAndBlocky;
+
+}
diff --git a/tests/sksl/inliner/golden/IfTestCanBeInlined.glsl b/tests/sksl/inliner/golden/IfTestCanBeInlined.glsl
new file mode 100644
index 0000000..21fed13
--- /dev/null
+++ b/tests/sksl/inliner/golden/IfTestCanBeInlined.glsl
@@ -0,0 +1,14 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+void main() {
+    bool _0_ifTest;
+    {
+        _0_ifTest = color.x >= 0.5;
+    }
+
+    if (_0_ifTest) sk_FragColor = vec4(1.0); else sk_FragColor = vec4(0.5);
+
+}
diff --git a/tests/sksl/inliner/golden/IfWithReturnsCanBeInlined.glsl b/tests/sksl/inliner/golden/IfWithReturnsCanBeInlined.glsl
new file mode 100644
index 0000000..de3ea50
--- /dev/null
+++ b/tests/sksl/inliner/golden/IfWithReturnsCanBeInlined.glsl
@@ -0,0 +1,14 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+void main() {
+    mediump vec4 _0_branchy;
+    {
+        if (color.z == color.w) _0_branchy = color.yyyy; else _0_branchy = color.zzzz;
+    }
+
+    sk_FragColor = _0_branchy;
+
+}
diff --git a/tests/sksl/inliner/golden/InlineKeywordOverridesThreshold.glsl b/tests/sksl/inliner/golden/InlineKeywordOverridesThreshold.glsl
new file mode 100644
index 0000000..09f7e42
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlineKeywordOverridesThreshold.glsl
@@ -0,0 +1,82 @@
+
+precision mediump float;
+precision mediump sampler2D;
+void main() {
+    highp int y = 0;
+    {
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+    }
+
+
+    {
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+        ++y;
+    }
+
+
+}
diff --git a/tests/sksl/inliner/golden/InlineThreshold.glsl b/tests/sksl/inliner/golden/InlineThreshold.glsl
new file mode 100644
index 0000000..d3d69e3
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlineThreshold.glsl
@@ -0,0 +1,44 @@
+
+precision mediump float;
+precision mediump sampler2D;
+void tooBig(inout highp int x) {
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+    ++x;
+}
+void main() {
+    highp int x = 0;
+    tooBig(x);
+    tooBig(x);
+}
diff --git a/tests/sksl/inliner/golden/InlineWithInoutArgument.glsl b/tests/sksl/inliner/golden/InlineWithInoutArgument.glsl
new file mode 100644
index 0000000..e011b5b
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlineWithInoutArgument.glsl
@@ -0,0 +1,13 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+void main() {
+    mediump float x = 1.0;
+    {
+        x *= 2.0;
+    }
+
+
+    sk_FragColor.x = x;
+}
diff --git a/tests/sksl/inliner/golden/InlineWithModifiedArgument.glsl b/tests/sksl/inliner/golden/InlineWithModifiedArgument.glsl
new file mode 100644
index 0000000..d177a97
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlineWithModifiedArgument.glsl
@@ -0,0 +1,15 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+void main() {
+    mediump float _0_parameterWrite;
+    mediump float _1_x = 1.0;
+    {
+        _1_x *= 2.0;
+        _0_parameterWrite = _1_x;
+    }
+
+    sk_FragColor.x = _0_parameterWrite;
+
+}
diff --git a/tests/sksl/inliner/golden/InlineWithNestedBigCalls.glsl b/tests/sksl/inliner/golden/InlineWithNestedBigCalls.glsl
new file mode 100644
index 0000000..e6e186a
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlineWithNestedBigCalls.glsl
@@ -0,0 +1,87 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump float val;
+void main() {
+    mediump float _1_x = val;
+    {
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        ++_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        --_1_x;
+        _1_x = 456.0;
+    }
+
+    mediump float _3_x = 456.0;
+    {
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        ++_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        --_3_x;
+        _3_x = 123.0;
+    }
+
+    sk_FragColor = vec4(123.0);
+
+}
diff --git a/tests/sksl/inliner/golden/InlineWithNestedCalls.glsl b/tests/sksl/inliner/golden/InlineWithNestedCalls.glsl
new file mode 100644
index 0000000..81286f7
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlineWithNestedCalls.glsl
@@ -0,0 +1,50 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+void main() {
+    mediump float _2_y = 0.0;
+    {
+        {
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            ++_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            --_2_y;
+            _2_y = 42.0;
+        }
+
+    }
+
+
+    sk_FragColor.x = 0.0;
+}
diff --git a/tests/sksl/inliner/golden/InlineWithUnmodifiedArgument.glsl b/tests/sksl/inliner/golden/InlineWithUnmodifiedArgument.glsl
new file mode 100644
index 0000000..6366dde
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlineWithUnmodifiedArgument.glsl
@@ -0,0 +1,10 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+void main() {
+    sk_FragColor.x = 2.0;
+
+    sk_FragColor.y = 4.0;
+
+}
diff --git a/tests/sksl/inliner/golden/InlineWithUnnecessaryBlocks.glsl b/tests/sksl/inliner/golden/InlineWithUnnecessaryBlocks.glsl
new file mode 100644
index 0000000..874d078
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlineWithUnnecessaryBlocks.glsl
@@ -0,0 +1,16 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+void main() {
+    mediump vec4 _0_blocky;
+    {
+        {
+            _0_blocky = color;
+        }
+    }
+
+    sk_FragColor = _0_blocky;
+
+}
diff --git a/tests/sksl/inliner/golden/InlinerManglesNames.glsl b/tests/sksl/inliner/golden/InlinerManglesNames.glsl
new file mode 100644
index 0000000..9ccbe4a
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlinerManglesNames.glsl
@@ -0,0 +1,89 @@
+
+precision mediump float;
+precision mediump sampler2D;
+uniform mediump vec4 color;
+mediump vec4 main() {
+    mediump float _3_fma;
+    mediump float _4_a = color.x;
+    mediump float _5_b = color.y;
+    mediump float _6_c = color.z;
+    {
+        mediump float _7_0_mul;
+        {
+            _7_0_mul = _4_a * _5_b;
+        }
+
+        mediump float _8_1_add;
+        {
+            mediump float _9_2_c = _7_0_mul + _6_c;
+            _8_1_add = _9_2_c;
+        }
+
+        _3_fma = _8_1_add;
+
+    }
+
+    mediump float a = _3_fma;
+
+    mediump float _10_fma;
+    mediump float _11_a = color.y;
+    mediump float _12_b = color.z;
+    mediump float _13_c = color.w;
+    {
+        mediump float _14_0_mul;
+        {
+            _14_0_mul = _11_a * _12_b;
+        }
+
+        mediump float _15_1_add;
+        {
+            mediump float _16_2_c = _14_0_mul + _13_c;
+            _15_1_add = _16_2_c;
+        }
+
+        _10_fma = _15_1_add;
+
+    }
+
+    mediump float b = _10_fma;
+
+    mediump float _17_fma;
+    mediump float _18_a = color.z;
+    mediump float _19_b = color.w;
+    mediump float _20_c = color.x;
+    {
+        mediump float _21_0_mul;
+        {
+            _21_0_mul = _18_a * _19_b;
+        }
+
+        mediump float _22_1_add;
+        {
+            mediump float _23_2_c = _21_0_mul + _20_c;
+            _22_1_add = _23_2_c;
+        }
+
+        _17_fma = _22_1_add;
+
+    }
+
+    mediump float c = _17_fma;
+
+    mediump float _24_mul;
+    {
+        _24_mul = c * c;
+    }
+
+    mediump float _25_mul;
+    {
+        _25_mul = b * c;
+    }
+
+    mediump float _26_mul;
+    {
+        _26_mul = a * _25_mul;
+    }
+
+    return vec4(a, b, _24_mul, _26_mul);
+
+}
diff --git a/tests/sksl/inliner/golden/InlinerWrapsEarlyReturnsWithDoWhileBlock.glsl b/tests/sksl/inliner/golden/InlinerWrapsEarlyReturnsWithDoWhileBlock.glsl
new file mode 100644
index 0000000..7072ac7
--- /dev/null
+++ b/tests/sksl/inliner/golden/InlinerWrapsEarlyReturnsWithDoWhileBlock.glsl
@@ -0,0 +1,13 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+mediump vec4 returny(mediump vec4 c) {
+    if (c.x > c.y) return c.xxxx;
+    if (c.y > c.z) return c.yyyy;
+    return c.zzzz;
+}
+void main() {
+    sk_FragColor = returny(color);
+}
diff --git a/tests/sksl/inliner/golden/ShortCircuitEvaluationsCannotInlineRightHandSide.glsl b/tests/sksl/inliner/golden/ShortCircuitEvaluationsCannotInlineRightHandSide.glsl
new file mode 100644
index 0000000..0e71404
--- /dev/null
+++ b/tests/sksl/inliner/golden/ShortCircuitEvaluationsCannotInlineRightHandSide.glsl
@@ -0,0 +1,32 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+bool testA(mediump vec4 v) {
+    return v.x <= 0.5;
+}
+bool testB(mediump vec4 v) {
+    return v.x > 0.5;
+}
+void main() {
+    sk_FragColor = vec4(0.0);
+    bool _0_testA;
+    {
+        _0_testA = color.x <= 0.5;
+    }
+
+    if (_0_testA && testB(color)) {
+        sk_FragColor = vec4(0.5);
+    }
+
+    bool _1_testB;
+    {
+        _1_testB = color.x > 0.5;
+    }
+
+    if (_1_testB || testA(color)) {
+        sk_FragColor = vec4(1.0);
+    }
+
+}
diff --git a/tests/sksl/inliner/golden/SwitchWithCastCanBeInlined.glsl b/tests/sksl/inliner/golden/SwitchWithCastCanBeInlined.glsl
new file mode 100644
index 0000000..9fac0a7
--- /dev/null
+++ b/tests/sksl/inliner/golden/SwitchWithCastCanBeInlined.glsl
@@ -0,0 +1,23 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+void main() {
+    mediump vec4 _0_switchy;
+    {
+        mediump vec4 _1_result;
+        switch (int(color.x)) {
+            case 1:
+                _1_result = color.yyyy;
+                break;
+            default:
+                _1_result = color.zzzz;
+                break;
+        }
+        _0_switchy = _1_result;
+    }
+
+    sk_FragColor = _0_switchy;
+
+}
diff --git a/tests/sksl/inliner/golden/SwitchWithReturnInsideCannotBeInlined.glsl b/tests/sksl/inliner/golden/SwitchWithReturnInsideCannotBeInlined.glsl
new file mode 100644
index 0000000..b13e22a
--- /dev/null
+++ b/tests/sksl/inliner/golden/SwitchWithReturnInsideCannotBeInlined.glsl
@@ -0,0 +1,15 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform highp int value;
+mediump vec4 switchy(highp int v) {
+    switch (v) {
+        case 0:
+            return vec4(0.5);
+    }
+    return vec4(1.0);
+}
+void main() {
+    sk_FragColor = switchy(value);
+}
diff --git a/tests/sksl/inliner/golden/SwitchWithoutReturnInsideCanBeInlined.glsl b/tests/sksl/inliner/golden/SwitchWithoutReturnInsideCanBeInlined.glsl
new file mode 100644
index 0000000..8ca5f61
--- /dev/null
+++ b/tests/sksl/inliner/golden/SwitchWithoutReturnInsideCanBeInlined.glsl
@@ -0,0 +1,19 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform highp int value;
+void main() {
+    mediump vec4 _0_switchy;
+    {
+        mediump vec4 _1_result = vec4(1.0);
+        switch (value) {
+            case 0:
+                _1_result = vec4(0.5);
+        }
+        _0_switchy = _1_result;
+    }
+
+    sk_FragColor = _0_switchy;
+
+}
diff --git a/tests/sksl/inliner/golden/TernaryResultsCannotBeInlined.glsl b/tests/sksl/inliner/golden/TernaryResultsCannotBeInlined.glsl
new file mode 100644
index 0000000..7f9ae82
--- /dev/null
+++ b/tests/sksl/inliner/golden/TernaryResultsCannotBeInlined.glsl
@@ -0,0 +1,18 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+mediump float count = 0.0;
+mediump vec4 trueSide(mediump vec4 v) {
+    count += 1.0;
+    return vec4(sin(v.x), sin(v.y), sin(v.z), sin(v.w));
+}
+mediump vec4 falseSide(mediump vec4 v) {
+    count += 1.0;
+    return vec4(cos(v.y), cos(v.z), cos(v.w), cos(v.z));
+}
+void main() {
+    sk_FragColor = color.x <= 0.5 ? trueSide(color) : falseSide(color);
+    sk_FragColor *= count;
+}
diff --git a/tests/sksl/inliner/golden/TernaryTestCanBeInlined.glsl b/tests/sksl/inliner/golden/TernaryTestCanBeInlined.glsl
new file mode 100644
index 0000000..e94750e
--- /dev/null
+++ b/tests/sksl/inliner/golden/TernaryTestCanBeInlined.glsl
@@ -0,0 +1,14 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+uniform mediump vec4 color;
+void main() {
+    bool _0_test;
+    {
+        _0_test = color.x <= 0.5;
+    }
+
+    sk_FragColor = _0_test ? vec4(0.5) : vec4(1.0);
+
+}
diff --git a/tests/sksl/inliner/golden/WhileBodyMustBeInlinedIntoAScope.glsl b/tests/sksl/inliner/golden/WhileBodyMustBeInlinedIntoAScope.glsl
new file mode 100644
index 0000000..be17c69
--- /dev/null
+++ b/tests/sksl/inliner/golden/WhileBodyMustBeInlinedIntoAScope.glsl
@@ -0,0 +1,15 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+void main() {
+    sk_FragColor = vec4(0.0);
+    while (sk_FragColor.x < 0.5) {
+        mediump vec4 _0_adjust;
+        {
+            _0_adjust = sk_FragColor + vec4(0.125);
+        }
+
+        sk_FragColor = _0_adjust;
+    }
+}
diff --git a/tests/sksl/inliner/golden/WhileTestCannotBeInlined.glsl b/tests/sksl/inliner/golden/WhileTestCannotBeInlined.glsl
new file mode 100644
index 0000000..3c3a562
--- /dev/null
+++ b/tests/sksl/inliner/golden/WhileTestCannotBeInlined.glsl
@@ -0,0 +1,13 @@
+
+precision mediump float;
+precision mediump sampler2D;
+out mediump vec4 sk_FragColor;
+bool shouldLoop(mediump vec4 v) {
+    return v.x < 0.5;
+}
+void main() {
+    sk_FragColor = vec4(0.0);
+    while (shouldLoop(sk_FragColor)) {
+        sk_FragColor += vec4(0.125);
+    }
+}