This PR fixes the next bug showed in the example below:
typedef int (*fn_t)();
int get42() { return 42; }
void foo() {
fn_t f = get42;
}
The function type fn_t is generated as the variadic one due to no arg types listed, this is the codegen feature. And once we store the function pointer to a real function - a pointer to get42 here has the expected i32 ()* type - we get a verification error, so bitcast is needed. The original codegen doesn't have it because of opaque pointers used, and had the bitcast earlier, long time ago:
%f = alloca i32 (...)*
store i32 (...)* bitcast (i32 ()* @get42 to i32 (...)*), i32 (...)** %f
This PR fixes the next bug showed in the example below:
The function type
fn_t
is generated as the variadic one due to no arg types listed, this is thecodegen
feature. And once we store the function pointer to a real function - a pointer toget42
here has the expectedi32 ()*
type - we get a verification error, sobitcast
is needed. The originalcodegen
doesn't have it because of opaque pointers used, and had thebitcast
earlier, long time ago: