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

spirvfuzz: Fix type-related bug, change undef to zero, and add assert #3188

Merged
merged 1 commit into from
Feb 14, 2020
Merged
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: 7 additions & 2 deletions source/fuzz/fuzzer_pass_donate_modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void FuzzerPassDonateModules::Apply() {
std::unique_ptr<opt::IRContext> donor_ir_context = donor_suppliers_.at(
GetFuzzerContext()->RandomIndex(donor_suppliers_))();
assert(donor_ir_context != nullptr && "Supplying of donor failed");
assert(fuzzerutil::IsValid(donor_ir_context.get()) &&
"The donor module must be valid");
// Donate the supplied module.
//
// Randomly decide whether to make the module livesafe (see
Expand Down Expand Up @@ -668,9 +670,12 @@ void FuzzerPassDonateModules::HandleFunctions(
// The return type is void, so we don't need a return value.
kill_unreachable_return_value_id = 0;
} else {
// We do need a return value; we use OpUndef.
// We do need a return value; we use zero.
assert(function_return_type_inst->opcode() != SpvOpTypePointer &&
"Function return type must not be a pointer.");
kill_unreachable_return_value_id =
FindOrCreateGlobalUndef(function_return_type_inst->type_id());
FindOrCreateZeroConstant(original_id_to_donated_id->at(
function_return_type_inst->result_id()));
}
// Add the function in a livesafe manner.
ApplyTransformation(TransformationAddFunction(
Expand Down