From 4be6874246f4ce395873dbc64efe14d062a8d8b3 Mon Sep 17 00:00:00 2001 From: Alastair Donaldson Date: Wed, 21 Oct 2020 16:10:23 +0100 Subject: [PATCH] spirv-fuzz: Pass OpUndef in function call if needed Fixes #3977. --- source/fuzz/fuzzer_pass_add_function_calls.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/fuzz/fuzzer_pass_add_function_calls.cpp b/source/fuzz/fuzzer_pass_add_function_calls.cpp index b6f4c85d07..74005579c4 100644 --- a/source/fuzz/fuzzer_pass_add_function_calls.cpp +++ b/source/fuzz/fuzzer_pass_add_function_calls.cpp @@ -141,9 +141,13 @@ std::vector FuzzerPassAddFunctionCalls::ChooseFunctionCallArguments( assert(param_type && "Parameter has invalid type"); if (!param_type->AsPointer()) { - // We mark the constant as irrelevant so that we can replace it with a - // more interesting value later. - result.push_back(FindOrCreateZeroConstant(param->type_id(), true)); + if (fuzzerutil::CanCreateConstant(GetIRContext(), param->type_id())) { + // We mark the constant as irrelevant so that we can replace it with a + // more interesting value later. + result.push_back(FindOrCreateZeroConstant(param->type_id(), true)); + } else { + result.push_back(FindOrCreateGlobalUndef(param->type_id())); + } continue; }