skia2/tests/sksl/inliner/golden
John Stiles c5ff48648a Elide return expression temp-var in vardecl-less blocks.
Previously, a return statement inside a scoped Block would always result
in the return expression being assigned to a temporary variable instead
of replacing the function-call-expression directly. This was done
because there might be variables inside the Block; these would have
fallen out of scope when the expression is migrated to the call site,
resulting in an invalid expression.

We aren't actually examining the return expression so we don't know if
it uses variables from an inner scope at all. (Inspecting the return
expression for variable usage is certainly possible! But it's a fair
amount of code and complexity for a small payoff.)

However, we can very easily get most of the benefit here without paying
for the complexity. In this CL we now look for variable declarations
inside of scoped Blocks. If the code doesn't add any vardecls into
scoped Blocks, there's no risk of scope problems, and we don't need to
use a temp-var to store our return expressions. If any vardecls are
added, we go back to using a temp-var as before.

Change-Id: I4c81400dad2f33db06a1c18eb671ba2140232006
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346499
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-22 19:33:12 +00:00
..
DoWhileBodyMustBeInlinedIntoAScope.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
DoWhileTestCannotBeInlined.glsl Align default values of GrShaderCaps with StandaloneShaderCaps. 2020-09-16 15:16:37 +00:00
ExponentialGrowth.glsl Remove unnecessary Blocks from the inliner. 2020-12-17 19:35:35 +00:00
ExponentialGrowthStandaloneSettings.glsl Remove unnecessary Blocks from the inliner. 2020-12-17 19:35:35 +00:00
ForBodyMustBeInlinedIntoAScope.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
ForInitializerExpressionsCanBeInlined.glsl Reland "Remove inliner from IR generation stage." 2020-11-20 18:44:07 +00:00
ForWithoutReturnInsideCanBeInlined.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
ForWithReturnInsideCannotBeInlined.glsl Align default values of GrShaderCaps with StandaloneShaderCaps. 2020-09-16 15:16:37 +00:00
IfBodyMustBeInlinedIntoAScope.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
IfElseBodyMustBeInlinedIntoAScope.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
IfElseChainWithReturnsCanBeInlined.glsl Remove unnecessary Blocks from the inliner. 2020-12-17 19:35:35 +00:00
IfTestCanBeInlined.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
IfWithReturnsCanBeInlined.glsl Remove unnecessary Blocks from the inliner. 2020-12-17 19:35:35 +00:00
InlineKeywordOverridesThreshold.glsl Remove unnecessary Blocks from the inliner. 2020-12-17 19:35:35 +00:00
InlinerAvoidsVariableNameOverlap.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
InlinerCanBeDisabled.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
InlinerCanBeDisabledStandaloneSettings.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
InlinerElidesTempVarForReturnsInsideBlock.glsl Elide return expression temp-var in vardecl-less blocks. 2020-12-22 19:33:12 +00:00
InlinerManglesNames.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
InlinerUsesTempVarForMultipleReturns.glsl Test that the inliner uses a temp var for return statements. 2020-12-22 17:52:49 +00:00
InlinerUsesTempVarForReturnsInsideBlockWithVar.glsl Test that the inliner uses a temp var for return statements. 2020-12-22 17:52:49 +00:00
InlinerWrapsEarlyReturnsWithForLoop.glsl Replace inliner do-while loops with for loops. 2020-12-17 19:23:47 +00:00
InlinerWrapsSwitchWithReturnInsideWithForLoop.glsl Add support for inlining switches with returns inside. 2020-12-18 00:14:48 +00:00
InlineThreshold.glsl Align default values of GrShaderCaps with StandaloneShaderCaps. 2020-09-16 15:16:37 +00:00
InlineWithInoutArgument.glsl Remove unnecessary Blocks from the inliner. 2020-12-17 19:35:35 +00:00
InlineWithModifiedArgument.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
InlineWithNestedBigCalls.glsl Remove unnecessary Blocks from the inliner. 2020-12-17 19:35:35 +00:00
InlineWithNestedCalls.glsl Remove unnecessary Blocks from the inliner. 2020-12-17 19:35:35 +00:00
InlineWithUnmodifiedArgument.glsl Align default values of GrShaderCaps with StandaloneShaderCaps. 2020-09-16 15:16:37 +00:00
InlineWithUnnecessaryBlocks.glsl Elide return expression temp-var in vardecl-less blocks. 2020-12-22 19:33:12 +00:00
ShortCircuitEvaluationsCannotInlineRightHandSide.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
SwitchWithCastCanBeInlined.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
SwitchWithoutReturnInsideCanBeInlined.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
SwizzleCanBeInlinedDirectly.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
TernaryResultsCannotBeInlined.glsl Align default values of GrShaderCaps with StandaloneShaderCaps. 2020-09-16 15:16:37 +00:00
TernaryTestCanBeInlined.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
TrivialArgumentsInlineDirectly.glsl Remove unnecessary Blocks from the inliner. 2020-12-17 19:35:35 +00:00
WhileBodyMustBeInlinedIntoAScope.glsl Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
WhileTestCannotBeInlined.glsl Align default values of GrShaderCaps with StandaloneShaderCaps. 2020-09-16 15:16:37 +00:00