KhronosGroup / SPIRV-Tools

Apache License 2.0
1.05k stars 548 forks source link

spirv-fuzz: Fuzzer pass to do arbitrary id replacements in dead blocks #3843

Open afd opened 3 years ago

afd commented 3 years ago

For good reasons we are going to ban creation of synonyms in dead blocks, because ids in dead blocks are regarded as irrelevant and having synonyms of irrelevant ids doesn't make sense.

However, within dead blocks there is no harm in replacing a use of an id with a definition of any other available id with the same type.

Therefore we should have a new fuzzer pass that does this, or check whether this is already adequately handled by FuzzerPassReplaceIrrelevantIds (perhaps it is).

afd commented 3 years ago

@Vasniktel perhaps you could take a look and see whether FuzzerPassReplaceIrrelevantIds already handles what we want to do.

Vasniktel commented 3 years ago

It doesn't because TransformationReplaceIrrelevantId doesn't support it. For example, if the following instruction is in a dead block %1 = OpIAdd %int %const_1 %const_1 then we can't replace %const_1 with any other integral id if %const_1 is not irrelevant. And it might not be irrelevant since it's not defined in a dead block.

That is, in the preceding example TransformationReplaceIrrelevantId won't allow us to make a replacement because it requires %const_1 to be irrelevant.

Vasniktel commented 3 years ago

We can adjust TransformationReplaceIrrelevantId to support that use case. @afd, what do you think?