[LLVMbugs] [Bug 4177] New: strcpy optimizer gets endian wrong

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu May 7 12:06:20 PDT 2009


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

           Summary: strcpy optimizer gets endian wrong
           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: md at bu.edu
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=2971)
 --> (http://llvm.org/bugs/attachment.cgi?id=2971)
sample program

I have a small program example which uses strcpy to concatenate the strings
"hello\0" and "\n\0".  When I compile through opt -O1, it is okay.  When I
compile through opt -O2 or higher, it makes a mistake.  bugpoint isolates this
to "Found miscompiling passes: -inline -simplify-libcalls -instcombine" but I
can point specifically to the line of asm output which is incorrect.

LLVM opt -O2 outputs:

  movw $2560, 5(%rbx)

and 2560 is 0x0A00 in hex.  The problem is that on a little-endian architecture
this write comes out to:

0x23e2010:      104 'h' 101 'e' 108 'l' 108 'l' 111 'o' 0 '\0'  10 '\n'

the nul and the newline are in the wrong order.  The instruction should have
been

  movw $10, 5(%rbx)

I attached bug.ll which can reproduce the error by:

  cat bug.ll | llvm-as | opt -O2 | llc > bug.s && gcc bug.s


LLVM from SVN (r70985)
Debian Linux 2.6.26 amd64


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list