Fixed a few spots where SkSL optimizer was not respecting side effects
This was affecting expressions such as 0 * float4(<expr>), which would be collapsed down to float4(0) - in some cases even if <expr> had side effects. This is obviously incorrect no matter what, but to make matters worse it could lead to a use-after-free when we eliminated an assignment which we were tracking as the current definition of a variable. Bug: skia:7467 Change-Id: I91ba154c57dad9cadf36b6062bec3211557248e0 Reviewed-on: https://skia-review.googlesource.com/98704 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
d8327a8c8b
commit
08dae924f6
@ -713,7 +713,8 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
|
||||
}
|
||||
else if (is_constant(*bin->fLeft, 0)) {
|
||||
if (bin->fLeft->fType.kind() == Type::kScalar_Kind &&
|
||||
bin->fRight->fType.kind() == Type::kVector_Kind) {
|
||||
bin->fRight->fType.kind() == Type::kVector_Kind &&
|
||||
!bin->fRight->hasSideEffects()) {
|
||||
// 0 * float4(x) -> float4(0)
|
||||
vectorize_left(&b, iter, outUpdated, outNeedsRescan);
|
||||
} else {
|
||||
@ -739,7 +740,8 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
|
||||
}
|
||||
else if (is_constant(*bin->fRight, 0)) {
|
||||
if (bin->fLeft->fType.kind() == Type::kVector_Kind &&
|
||||
bin->fRight->fType.kind() == Type::kScalar_Kind) {
|
||||
bin->fRight->fType.kind() == Type::kScalar_Kind &&
|
||||
!bin->fLeft->hasSideEffects()) {
|
||||
// float4(x) * 0 -> float4(0)
|
||||
vectorize_right(&b, iter, outUpdated, outNeedsRescan);
|
||||
} else {
|
||||
@ -805,7 +807,8 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
|
||||
}
|
||||
} else if (is_constant(*bin->fLeft, 0)) {
|
||||
if (bin->fLeft->fType.kind() == Type::kScalar_Kind &&
|
||||
bin->fRight->fType.kind() == Type::kVector_Kind) {
|
||||
bin->fRight->fType.kind() == Type::kVector_Kind &&
|
||||
!bin->fRight->hasSideEffects()) {
|
||||
// 0 / float4(x) -> float4(0)
|
||||
vectorize_left(&b, iter, outUpdated, outNeedsRescan);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user