Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spirv-fuzz: Replace OpCopyObject with the pair OpStore and OpLoad instructions #3351

Closed
andreperezmaselco opened this issue May 16, 2020 · 3 comments · Fixed by #3567
Closed
Assignees
Labels
component:fuzzer Relates to the spirv-fuzz tool

Comments

@andreperezmaselco
Copy link
Collaborator

andreperezmaselco commented May 16, 2020

If we have %8 = OpCopyObject %type %7, we could create a new variable with type pointer to %type, store %7 to the new variable and load the new variable to %8. The following is an example.

OpStore %fresh_variable_id %7
%8 = OpLoad %type %fresh_variable_id

This transformation protobuf would consist of copy_object_result_id, fresh_variable_id, variable_storage_class, variable_initializer_id.

The transformation is only applicable if the pointer type already exists. The pointer type cannot be a pointer to a pointer.

The fuzzer pass would look for OpCopyObject instructions and create and apply a transformation to add the required pointer type, if needed using FindOrCreatePointerType.

The transformation should add a synonym fact to the fact manager.

This will be similar to TransformationPushIdThroughVariable.

@afd
Copy link
Contributor

afd commented Jul 15, 2020

@antnkarp can we assign this to you? (We'll help prioritize the order.)

@antonikarp
Copy link
Collaborator

Ok, that's great :)

@paulthomson
Copy link
Contributor

A bigger example:

%1 = OpTypeInt 32 0
%2 = OpTypePointer Function %1
%3 = OpConstant %1 42
…
%5 = OpIAdd %1 %3 %3 ; %5 = 42 + 42
%4 = OpCopyObject %1 %5 ; Copy the value 84 into %4.

→
%100 = OpVariable %2 Function ; new variable to store into
...
%5 = OpIAdd %1 %3 %3 ; %5 = 42 + 42
     OpStore %100 %5 ; Store the value 84 into variable %100
%4 = OpLoad %1 %100 ; Load the value 84 from %100.



@afd afd added the component:fuzzer Relates to the spirv-fuzz tool label Jul 21, 2020
@afd afd closed this as completed in #3567 Jul 23, 2020
afd pushed a commit that referenced this issue Jul 23, 2020
Adds a transformation that replaces instruction OpCopyObject with
storing into a new variable and immediately loading this variable to
|result_id| of the original OpCopyObject instruction.

Fixes #3351.
dnovillo pushed a commit to dnovillo/SPIRV-Tools that referenced this issue Aug 19, 2020
…sGroup#3567)

Adds a transformation that replaces instruction OpCopyObject with
storing into a new variable and immediately loading this variable to
|result_id| of the original OpCopyObject instruction.

Fixes KhronosGroup#3351.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:fuzzer Relates to the spirv-fuzz tool
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants