[LLVMbugs] [Bug 1358] NEW: miscompilation of 2007-04-25-weak.c

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Apr 25 07:36:16 PDT 2007


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

           Summary: miscompilation of 2007-04-25-weak.c
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: lauro.venancio at gmail.com


LLVM is considering that the if is always true.

test:
extern int test_weak () __attribute__ ((weak));

int main(){
  int (*t)() = test_weak;
  if (t)
    return t();
  else return 250;
}

llc emits:
.text
        .align  16
        .globl  main
        .type main, at function
main:
        subl $4, %esp
        fnstcw 2(%esp)
        movb $2, 3(%esp)
        fldcw 2(%esp)
.LBB1_1:        #cond_true
        call test_weak
        addl $4, %esp
        ret
        .size main, .-main
        .weak   test_weak

gcc emits:
        .file   "teste.c"
        .text
        .p2align 4,,15
.globl main
        .type   main, @function
main:
        leal    4(%esp), %ecx
        andl    $-16, %esp
        pushl   -4(%ecx)
        movl    $test_weak, %eax
        movl    $250, %edx
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ecx
        subl    $4, %esp
        testl   %eax, %eax
        je      .L4
        call    test_weak
        movl    %eax, %edx
.L4:
        addl    $4, %esp
        movl    %edx, %eax
        popl    %ecx
        popl    %ebp
        leal    -4(%ecx), %esp
        ret
        .size   main, .-main
        .weak   test_weak
        .ident  "GCC: (GNU) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)"
        .section        .note.GNU-stack,"", at progbits



------- 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