This is the first component of addressing #240.
In Rust's MIR generation, shim functions are generated for calls to Fn::call and FnMut::call_mutthat include calls to the wrapped function, for example, conceptually:
// self is a dyn Fn
fn call(&self) {
call_actual_function();
}
Previously, the Gotoc code we were generating was call the first (self) argument instead of inserting an actual call to the wrapped function. In the case of Fn::call, self is a zero-sized type, that is, a pointer to an empty allocation (see this zulip post for more). Trying to call that as a pointer is an invalid function call, and produces Gotoc that is both incorrect and fails when passing the --pointer-check flag.
unsigned int call(unsigned int (*var_1)(void))
{
bb0:
;
unsigned int var_0=var_1();
bb1:
;
return var_0;
}
Instead, we should generate this:
unsigned int call(unsigned int (*var_1)(void))
{
bb0:
;
unsigned int var_0=call_actual_function();
bb1:
;
return var_0;
}
This is the first component of addressing #240.
In Rust's MIR generation, shim functions are generated for calls to
Fn::callandFnMut::call_mutthat include calls to the wrapped function, for example, conceptually:Previously, the Gotoc code we were generating was call the first (self) argument instead of inserting an actual call to the wrapped function. In the case of
Fn::call, self is a zero-sized type, that is, a pointer to an empty allocation (see this zulip post for more). Trying to call that as a pointer is an invalid function call, and produces Gotoc that is both incorrect and fails when passing the--pointer-checkflag.Instead, we should generate this: