spirv-diff: Fix OpTypeFunction matching w.r.t operand count (#4771)

The code accidentally expected OpTypeFunction operand count to match.
This is fixed so that OpTypeFunction instructions with different operand
counts are considered not matching.
This commit is contained in:
Shahbaz Youssefi
2022-04-01 09:04:26 -04:00
committed by GitHub
parent d4f3f42b7d
commit c327d0465c
5 changed files with 443 additions and 3 deletions
+5 -3
View File
@@ -2196,16 +2196,18 @@ void Differ::MatchTypeIds() {
case SpvOpTypeSampledImage:
case SpvOpTypeRuntimeArray:
case SpvOpTypePointer:
case SpvOpTypeFunction:
// Match these instructions when all operands match.
assert(src_inst->NumInOperandWords() ==
dst_inst->NumInOperandWords());
return DoOperandsMatch(src_inst, dst_inst, 0,
src_inst->NumInOperandWords());
case SpvOpTypeFunction:
case SpvOpTypeImage:
// Match these instructions when all operands match, including the
// optional final parameter (if provided in both).
// Match function types only if they have the same number of operands,
// and they all match.
// Match image types similarly, expecting the optional final parameter
// to match (if provided in both)
if (src_inst->NumInOperandWords() != dst_inst->NumInOperandWords()) {
return false;
}