LLVM backend should sign extend foreign function arguments and results as necessary
In #20735 (comment 393658) we noticed that when asked to compile:
short int func(short int targetType);
int main() {
func(-2);
return 0;
}
clang
will emit the following IR:
define i32 @main() #0 {
%1 = alloca i32, align 4
store i32 0, i32* %1, align 4
%2 = call signext i16 @func(i16 signext -2)
ret i32 0
}
Specifically, note the use of the signext
parameter attribute, which is necessary on platforms like AArch64/Darwin where the caller is responsible for sign extending (see Apple's ABI documentation for details).
We should be emulating this.
This caused #20735 (closed) with the LLVM backend.