[LLVMbugs] [Bug 1018] NEW: wrong code on amd64

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Nov 28 06:42:46 PST 2006


http://llvm.org/bugs/show_bug.cgi?id=1018

           Summary: wrong code on amd64
           Product: libraries
           Version: trunk
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rafael.espindola at gmail.com


The code:

------------------------
extern void * xcalloc (size_t, size_t) __attribute__ ((__malloc__));

typedef void * (*htab_alloc) (size_t, size_t);

int
main(void)
{

  htab_alloc alloc_f = xcalloc;
  (*alloc_f) (1, 5);
  return 0;
}
--------------------------------

compiles to
-------------------------------
main:
        subq $32, %rsp
        movq %rbp, 24(%rsp)
        leaq 24(%rsp), %rbp
        fnstcw -18(%rbp)
        movb $2, -17(%rbp)
        fldcw -18(%rbp)
        leaq xcalloc at GOTPCREL(%rip), %rax
        movq %rax, -16(%rbp)
        xorb %al, %al
        movl $5, %esi
        movl $1, %edi
        call xcalloc
        movl $0, -8(%rbp)
        movl $0, -4(%rbp)
.BB1_1: #return
        movl -4(%rbp), %eax
        movq %rbp, %rsp
        popq %rbp
        ret
-----------------------------
with gcc 4.1.2 it compiles to

------------------------------
main:
.LFB2:
        pushq   %rbp
.LCFI0:
        movq    %rsp, %rbp
.LCFI1:
        subq    $16, %rsp
.LCFI2:
        movq    $xcalloc, -8(%rbp)
        movq    -8(%rbp), %rdx
        movl    $5, %esi
        movl    $1, %edi
        movl    $0, %eax
        call    *%rdx
        movl    $0, %eax
        leave
        ret
-----------------------------
This is a reduction of a segmentation fault during a bootstrap (running 
genmodes).



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the llvm-bugs mailing list