------- Comment #2 from hjl dot tools at gmail dot com  2009-12-07 18:39 -------
(In reply to comment #1)
> For what it's worth, gcc 3.4.6 generates a clear on the output register, and
> therefore complies with the written ABI.
> 

That is true. However, gcc 3.4.6 does:


[...@gnu-26 pr42324]$ cat b1.c
_Bool myfunction(char val);

int
foo (char v)
{
  return myfunction (v);
}
[...@gnu-26 pr42324]$ gcc -O2 -S b1.c
[...@gnu-26 pr42324]$ cat b1.s
        .file   "b1.c"
        .text
        .p2align 4,,15
.globl foo
        .type   foo, @function
foo:
.LFB2:
        subq    $8, %rsp
.LCFI0:
        movsbl  %dil,%edi
        call    myfunction
        addq    $8, %rsp
        movzbl  %al, %eax
        ret

It assumes that _Bool is returned in AL. Gcc 3.4.6 generates:

[...@gnu-26 pr42324]$ cat b2.c
void foo (char, char, char, char, char, char, char, _Bool);

void
myfunction(char val)
{
  foo (val, val, val, val, val, val, val, val);
}
[...@gnu-26 pr42324]$ gcc -O2 -S b2.c
[...@gnu-26 pr42324]$ cat b2.s
        .file   "b2.c"
        .text
        .p2align 4,,15
.globl myfunction
        .type   myfunction, @function
myfunction:
.LFB2:
        movsbl  %dil,%r10d
        subq    $24, %rsp
.LCFI0:
        xorl    %eax, %eax
        testb   %dil, %dil
        movl    %r10d, %r9d
        movl    %r10d, %r8d
        setne   %al
        movl    %r10d, %ecx
        movl    %r10d, %edx
        movl    %r10d, %esi
        movl    %r10d, %edi
        movl    %eax, 8(%rsp)
        movl    %r10d, (%rsp)
        call    foo
        addq    $24, %rsp
        ret

The upper 32bits of _Bool on stack aren't zeroed.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42324

Reply via email to