Add fix storage class code.#2434
Conversation
This pass tries to fix validation error due to a mismatch of storage classes in instructions. There is no guarantee that all such error will be fixed, and it is possible that in fixing these errors, it could lead to other errors. Fixes KhronosGroup#2430.
| } | ||
| } | ||
| }); | ||
| return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange; |
There was a problem hiding this comment.
Should there be a warning/error/failure if a storage class mismatch was detected but could not be fixed? Or does this pass not detect this case?
There was a problem hiding this comment.
This pass does not check if it fails to fix something. It would require more code to check if it fails. Like comparing function parameters for type mismatches or looking at every operand of an OpPhi to make sure the types all match. This is code that is not needed for the pass, and already exists in the validator.
Running the validator will identify anything that has not been fixed. I did not feel the need to make it part of this pass.
| inst, [&uses](Instruction* use) { uses.push_back(use); }); | ||
| for (Instruction* use : uses) { | ||
| modified |= PropagateStorageClass( | ||
| use, static_cast<SpvStorageClass>(inst->GetSingleWordInOperand(0))); |
There was a problem hiding this comment.
Dunno if this can happen in an instruction. What if there are 2 different storage classes in the instruction uses?
There was a problem hiding this comment.
This can happen for OpPhi instructions if the type are legitimately different storage types. It will be wrong no matter what we do because the input operands have to match. We will end up picking one of them arbitrarily. Since it cannot be fixed, the choice does not matter. The same for an OpSelect.
All other instructions that we try to rewrite only have a single pointer operand, and the result type has to have the same storage class.
This pass tries to fix validation error due to a mismatch of storage classes
in instructions. There is no guarantee that all such error will be fixed,
and it is possible that in fixing these errors, it could lead to other
errors.
Fixes #2430.