[llvm] r328386 - [X86] Fix Windows `i1 zeroext` conventions to use i8 instead of i32

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 24 16:11:48 PDT 2018


On Fri, 23 Mar 2018, Reid Kleckner via llvm-commits wrote:

> Author: rnk
> Date: Fri Mar 23 16:38:53 2018
> New Revision: 328386
>
> URL: http://llvm.org/viewvc/llvm-project?rev=328386&view=rev
> Log:
> [X86] Fix Windows `i1 zeroext` conventions to use i8 instead of i32
>
> Both GCC and MSVC only look at the low byte of a boolean when it is
> passed.

FWIW, it seems like this change (with the follow-up fix in 
https://reviews.llvm.org/D44876) also would be relevant for the 
non-windows case - if I'm reading the GCC output right on linux, GCC also 
just uses the 8 or 16 bit version of registers when possible, and doesn't 
assume that the full 32 bit part of an input parameter register is 
initialized like clang does. The difference is easly testable with the 
following snippet:

void other(int a);
void extend(signed char a) {
   other(a);
}


With GCC on linux, "gcc -O2 -S -o - cc.c", I'm getting this:

extend:
         movzbl  %dil, %edi
         jmp     other

While clang doesn't do any such sign extension since it currently assumes 
that the caller already extended i8/i16 to i32.

// Martin


More information about the llvm-commits mailing list