This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: ABI incompatibility between libffi and LLVM-generated callees
Andrew Haley <aph@redhat.com> writes:
> On 02/03/2013 05:01 PM, Mark H Weaver wrote:
>> LLVM assumes that unsigned integers will be zero-extended by the caller,
>> which is what this patch does.
>
> Does it? I didn't see that. I just saw a copy of the word,
> regardless of whether the source of the data is a full word.
> Maybe I'm mistaken.
Consider the case where the caller passes -1 for the int8_t and 255 for
the uint8_t. Since the LLVM callee simply accesses both arguments as if
they were both int64_t, it is important to sign-extend the -1 and
zero-extend the 255. If the caller sign-extended both arguments, then
the callee would return -2, which is incorrect. The sum should be 254.
Mark