tint: transform::RemovePhonies: skip builtins with no side effects

This transform was attempting to remove builtins with no side
effects, such as a call with abstract int/float args, which is unhandled
by this transform. For example, this would cause the transform to ICE:

_ = clamp(1, 2, 3);

Fixes ClusterFuzz issue crbug.com/1348739.

Bug: chromium:1348739
Change-Id: Ie355eb36c6c020417c2d93f2dc434c11dbb72d1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97880
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Antonio Maiorano 2022-08-01 17:21:54 +00:00 committed by Dawn LUCI CQ
parent 6315a27778
commit 239a92d2d0
14 changed files with 82 additions and 79 deletions

View File

@ -97,7 +97,8 @@ void RemovePhonies::Run(CloneContext& ctx, const DataMap&, DataMap&) const {
// Just skip.
return ast::TraverseAction::Skip;
}
if (call->Target()->IsAnyOf<sem::Function, sem::Builtin>()) {
if (call->Target()->IsAnyOf<sem::Function, sem::Builtin>() &&
call->HasSideEffects()) {
side_effects.push_back(expr);
return ast::TraverseAction::Skip;
}

View File

@ -65,6 +65,8 @@ fn f() {
_ = vec2<f32>(5.0);
_ = vec3<i32>(6, 7, 8);
_ = mat2x2<f32>(9.0, 10.0, 11.0, 12.0);
_ = atan2(1.0, 2.0);
_ = clamp(1.0, 2.0, 3.0);
}
)";

View File

@ -1,4 +1,4 @@
@compute @workgroup_size(1)
fn main() {
_ = mix(1.0, vec2(1.0).y, 1.0);
let a = mix(1.0, vec2(1.0).y, 1.0);
}

View File

@ -1,5 +1,5 @@
[numthreads(1, 1, 1)]
void main() {
lerp(1.0f, 1.0f, 1.0f);
const float a = lerp(1.0f, 1.0f, 1.0f);
return;
}

View File

@ -1,5 +1,5 @@
[numthreads(1, 1, 1)]
void main() {
lerp(1.0f, 1.0f, 1.0f);
const float a = lerp(1.0f, 1.0f, 1.0f);
return;
}

View File

@ -1,7 +1,7 @@
#version 310 es
void tint_symbol() {
mix(1.0f, 1.0f, 1.0f);
float a = mix(1.0f, 1.0f, 1.0f);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -2,7 +2,7 @@
using namespace metal;
kernel void tint_symbol() {
mix(1.0f, 1.0f, 1.0f);
float const a = mix(1.0f, 1.0f, 1.0f);
return;
}

View File

@ -1,4 +1,4 @@
@compute @workgroup_size(1)
fn main() {
_ = mix(1.0, vec2(1.0).y, 1.0);
let a = mix(1.0, vec2(1.0).y, 1.0);
}

View File

@ -2,19 +2,19 @@
// same builtin overload results in single helper being generated.
@compute @workgroup_size(1)
fn main() {
_ = degrees(vec4<f32>());
_ = degrees(vec4<f32>(1.));
_ = degrees(vec4<f32>(1., 2., 3., 4.));
let a = degrees(vec4<f32>());
let b = degrees(vec4<f32>(1.));
let c = degrees(vec4<f32>(1., 2., 3., 4.));
_ = degrees(vec3<f32>());
_ = degrees(vec3<f32>(1.));
_ = degrees(vec3<f32>(1., 2., 3.));
let d = degrees(vec3<f32>());
let e = degrees(vec3<f32>(1.));
let f = degrees(vec3<f32>(1., 2., 3.));
_ = degrees(vec2<f32>());
_ = degrees(vec2<f32>(1.));
_ = degrees(vec2<f32>(1., 2.));
let g = degrees(vec2<f32>());
let h = degrees(vec2<f32>(1.));
let i = degrees(vec2<f32>(1., 2.));
_ = degrees(1.);
_ = degrees(2.);
_ = degrees(3.);
let j = degrees(1.);
let k = degrees(2.);
let l = degrees(3.);
}

View File

@ -16,17 +16,17 @@ float tint_degrees_3(float param_0) {
[numthreads(1, 1, 1)]
void main() {
tint_degrees((0.0f).xxxx);
tint_degrees((1.0f).xxxx);
tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f));
tint_degrees_1((0.0f).xxx);
tint_degrees_1((1.0f).xxx);
tint_degrees_1(float3(1.0f, 2.0f, 3.0f));
tint_degrees_2((0.0f).xx);
tint_degrees_2((1.0f).xx);
tint_degrees_2(float2(1.0f, 2.0f));
tint_degrees_3(1.0f);
tint_degrees_3(2.0f);
tint_degrees_3(3.0f);
const float4 a = tint_degrees((0.0f).xxxx);
const float4 b = tint_degrees((1.0f).xxxx);
const float4 c = tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f));
const float3 d = tint_degrees_1((0.0f).xxx);
const float3 e = tint_degrees_1((1.0f).xxx);
const float3 f = tint_degrees_1(float3(1.0f, 2.0f, 3.0f));
const float2 g = tint_degrees_2((0.0f).xx);
const float2 h = tint_degrees_2((1.0f).xx);
const float2 i = tint_degrees_2(float2(1.0f, 2.0f));
const float j = tint_degrees_3(1.0f);
const float k = tint_degrees_3(2.0f);
const float l = tint_degrees_3(3.0f);
return;
}

View File

@ -16,17 +16,17 @@ float tint_degrees_3(float param_0) {
[numthreads(1, 1, 1)]
void main() {
tint_degrees((0.0f).xxxx);
tint_degrees((1.0f).xxxx);
tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f));
tint_degrees_1((0.0f).xxx);
tint_degrees_1((1.0f).xxx);
tint_degrees_1(float3(1.0f, 2.0f, 3.0f));
tint_degrees_2((0.0f).xx);
tint_degrees_2((1.0f).xx);
tint_degrees_2(float2(1.0f, 2.0f));
tint_degrees_3(1.0f);
tint_degrees_3(2.0f);
tint_degrees_3(3.0f);
const float4 a = tint_degrees((0.0f).xxxx);
const float4 b = tint_degrees((1.0f).xxxx);
const float4 c = tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f));
const float3 d = tint_degrees_1((0.0f).xxx);
const float3 e = tint_degrees_1((1.0f).xxx);
const float3 f = tint_degrees_1(float3(1.0f, 2.0f, 3.0f));
const float2 g = tint_degrees_2((0.0f).xx);
const float2 h = tint_degrees_2((1.0f).xx);
const float2 i = tint_degrees_2(float2(1.0f, 2.0f));
const float j = tint_degrees_3(1.0f);
const float k = tint_degrees_3(2.0f);
const float l = tint_degrees_3(3.0f);
return;
}

View File

@ -18,18 +18,18 @@ float tint_degrees_3(float param_0) {
void tint_symbol() {
tint_degrees(vec4(0.0f));
tint_degrees(vec4(1.0f));
tint_degrees(vec4(1.0f, 2.0f, 3.0f, 4.0f));
tint_degrees_1(vec3(0.0f));
tint_degrees_1(vec3(1.0f));
tint_degrees_1(vec3(1.0f, 2.0f, 3.0f));
tint_degrees_2(vec2(0.0f));
tint_degrees_2(vec2(1.0f));
tint_degrees_2(vec2(1.0f, 2.0f));
tint_degrees_3(1.0f);
tint_degrees_3(2.0f);
tint_degrees_3(3.0f);
vec4 a = tint_degrees(vec4(0.0f));
vec4 b = tint_degrees(vec4(1.0f));
vec4 c = tint_degrees(vec4(1.0f, 2.0f, 3.0f, 4.0f));
vec3 d = tint_degrees_1(vec3(0.0f));
vec3 e = tint_degrees_1(vec3(1.0f));
vec3 f = tint_degrees_1(vec3(1.0f, 2.0f, 3.0f));
vec2 g = tint_degrees_2(vec2(0.0f));
vec2 h = tint_degrees_2(vec2(1.0f));
vec2 i = tint_degrees_2(vec2(1.0f, 2.0f));
float j = tint_degrees_3(1.0f);
float k = tint_degrees_3(2.0f);
float l = tint_degrees_3(3.0f);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -19,18 +19,18 @@ float tint_degrees_3(float param_0) {
}
kernel void tint_symbol() {
tint_degrees(float4(0.0f));
tint_degrees(float4(1.0f));
tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f));
tint_degrees_1(float3(0.0f));
tint_degrees_1(float3(1.0f));
tint_degrees_1(float3(1.0f, 2.0f, 3.0f));
tint_degrees_2(float2(0.0f));
tint_degrees_2(float2(1.0f));
tint_degrees_2(float2(1.0f, 2.0f));
tint_degrees_3(1.0f);
tint_degrees_3(2.0f);
tint_degrees_3(3.0f);
float4 const a = tint_degrees(float4(0.0f));
float4 const b = tint_degrees(float4(1.0f));
float4 const c = tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f));
float3 const d = tint_degrees_1(float3(0.0f));
float3 const e = tint_degrees_1(float3(1.0f));
float3 const f = tint_degrees_1(float3(1.0f, 2.0f, 3.0f));
float2 const g = tint_degrees_2(float2(0.0f));
float2 const h = tint_degrees_2(float2(1.0f));
float2 const i = tint_degrees_2(float2(1.0f, 2.0f));
float const j = tint_degrees_3(1.0f);
float const k = tint_degrees_3(2.0f);
float const l = tint_degrees_3(3.0f);
return;
}

View File

@ -1,15 +1,15 @@
@compute @workgroup_size(1)
fn main() {
_ = degrees(vec4<f32>());
_ = degrees(vec4<f32>(1.0));
_ = degrees(vec4<f32>(1.0, 2.0, 3.0, 4.0));
_ = degrees(vec3<f32>());
_ = degrees(vec3<f32>(1.0));
_ = degrees(vec3<f32>(1.0, 2.0, 3.0));
_ = degrees(vec2<f32>());
_ = degrees(vec2<f32>(1.0));
_ = degrees(vec2<f32>(1.0, 2.0));
_ = degrees(1.0);
_ = degrees(2.0);
_ = degrees(3.0);
let a = degrees(vec4<f32>());
let b = degrees(vec4<f32>(1.0));
let c = degrees(vec4<f32>(1.0, 2.0, 3.0, 4.0));
let d = degrees(vec3<f32>());
let e = degrees(vec3<f32>(1.0));
let f = degrees(vec3<f32>(1.0, 2.0, 3.0));
let g = degrees(vec2<f32>());
let h = degrees(vec2<f32>(1.0));
let i = degrees(vec2<f32>(1.0, 2.0));
let j = degrees(1.0);
let k = degrees(2.0);
let l = degrees(3.0);
}