Implementation
In the fuzzer pass, we need to randomly decide for each function a set of parameters that we want to replace. We also need to make sure that the required struct and function types exist in the module.
In the transformation class, we need to replace a type of function with a new one. We also need to replace OpFunctionParameter instructions with OpVariable instructions with Function storage class for the parameters that are being replaced, introduce an additional OpFunctionParameter instruction for a struct parameter and introduce OpAccessChain instructions to initialize new variables. Apart from that, we also need to adjust every call site of the function. If the parameter’s type is an OpTypePointer, store the pointee into a struct field and restore it back after the function call. If the parameter is not a pointer (clspv compiler produces such code), simply store the value in the struct.