c5ff48648a
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> |
||
---|---|---|
.. | ||
golden | ||
DoWhileBodyMustBeInlinedIntoAScope.sksl | ||
DoWhileTestCannotBeInlined.sksl | ||
ExponentialGrowth.sksl | ||
ForBodyMustBeInlinedIntoAScope.sksl | ||
ForInitializerExpressionsCanBeInlined.sksl | ||
ForWithoutReturnInsideCanBeInlined.sksl | ||
ForWithReturnInsideCannotBeInlined.sksl | ||
IfBodyMustBeInlinedIntoAScope.sksl | ||
IfElseBodyMustBeInlinedIntoAScope.sksl | ||
IfElseChainWithReturnsCanBeInlined.sksl | ||
IfTestCanBeInlined.sksl | ||
IfWithReturnsCanBeInlined.sksl | ||
InlineKeywordOverridesThreshold.sksl | ||
InlinerAvoidsVariableNameOverlap.sksl | ||
InlinerCanBeDisabled.sksl | ||
InlinerElidesTempVarForReturnsInsideBlock.sksl | ||
InlinerManglesNames.sksl | ||
InlinerUsesTempVarForMultipleReturns.sksl | ||
InlinerUsesTempVarForReturnsInsideBlockWithVar.sksl | ||
InlinerWrapsEarlyReturnsWithForLoop.sksl | ||
InlinerWrapsSwitchWithReturnInsideWithForLoop.sksl | ||
InlineThreshold.sksl | ||
InlineWithInoutArgument.sksl | ||
InlineWithModifiedArgument.sksl | ||
InlineWithNestedBigCalls.sksl | ||
InlineWithNestedCalls.sksl | ||
InlineWithUnmodifiedArgument.sksl | ||
InlineWithUnnecessaryBlocks.sksl | ||
ShortCircuitEvaluationsCannotInlineRightHandSide.sksl | ||
SwitchWithCastCanBeInlined.sksl | ||
SwitchWithoutReturnInsideCanBeInlined.sksl | ||
SwizzleCanBeInlinedDirectly.sksl | ||
TernaryResultsCannotBeInlined.sksl | ||
TernaryTestCanBeInlined.sksl | ||
TrivialArgumentsInlineDirectly.sksl | ||
WhileBodyMustBeInlinedIntoAScope.sksl | ||
WhileTestCannotBeInlined.sksl |