spirv-fuzz: Add GetParameters (#3454)

Adds a GetParameters function to fuzzerutil.
This commit is contained in:
Vasyl Teliman 2020-06-23 18:41:45 +03:00 committed by GitHub
parent 8e586e46a2
commit 71a5b6770d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -675,6 +675,18 @@ bool IsPermutationOfRange(const std::vector<uint32_t>& arr, uint32_t lo,
*min_max.second == hi; *min_max.second == hi;
} }
std::vector<opt::Instruction*> GetParameters(opt::IRContext* ir_context,
uint32_t function_id) {
auto* function = FindFunction(ir_context, function_id);
assert(function && "|function_id| is invalid");
std::vector<opt::Instruction*> result;
function->ForEachParam(
[&result](opt::Instruction* inst) { result.push_back(inst); });
return result;
}
} // namespace fuzzerutil } // namespace fuzzerutil
} // namespace fuzz } // namespace fuzz

View File

@ -261,6 +261,11 @@ bool HasDuplicates(const std::vector<uint32_t>& arr);
bool IsPermutationOfRange(const std::vector<uint32_t>& arr, uint32_t lo, bool IsPermutationOfRange(const std::vector<uint32_t>& arr, uint32_t lo,
uint32_t hi); uint32_t hi);
// Returns OpFunctionParameter instructions corresponding to the function
// with result id |function_id|.
std::vector<opt::Instruction*> GetParameters(opt::IRContext* ir_context,
uint32_t function_id);
} // namespace fuzzerutil } // namespace fuzzerutil
} // namespace fuzz } // namespace fuzz