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: Fix GetIdEquivalenceClasses #3767

Merged
merged 2 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions source/fuzz/fuzzer_pass_add_opphi_synonyms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ FuzzerPassAddOpPhiSynonyms::GetIdEquivalenceClasses() {
continue;
}

// Exclude OpFunction and OpUndef instructions, because:
// - OpFunction does not yield a value;
// - OpUndef yields an undefined value at each use, so it should never be a
// synonym of another id.
if (pair.second->opcode() == SpvOpFunction ||
pair.second->opcode() == SpvOpUndef) {
continue;
}

// We need a new equivalence class for this id.
std::set<uint32_t> new_equivalence_class;

Expand Down
5 changes: 5 additions & 0 deletions test/fuzz/fuzzer_pass_add_opphi_synonyms_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ std::string shader = R"(
%5 = OpTypeBool
%6 = OpConstantTrue %5
%7 = OpTypeInt 32 1
%31 = OpTypeFunction %7
%8 = OpTypeInt 32 0
%9 = OpConstant %7 1
%10 = OpConstant %7 2
Expand Down Expand Up @@ -109,6 +110,10 @@ std::string shader = R"(
%28 = OpLabel
OpReturn
OpFunctionEnd
%32 = OpFunction %7 None %31
%33 = OpLabel
OpReturnValue %9
OpFunctionEnd
)";

TEST(FuzzerPassAddOpPhiSynonymsTest, HelperFunctions) {
Expand Down