[LLVMbugs] [Bug 18220] New: clang misassembles 16-bit operations

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Dec 11 17:53:27 PST 2013


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

            Bug ID: 18220
           Summary: clang misassembles 16-bit operations
           Product: libraries
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: dwmw2 at infradead.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I was trying to familiarise myself with the code, wondering if I was stupid
enough to try to fix bug 8464. I couldn't work out how the current code could
work in all cases even for 32-bit mode.

Turns out it doesn't. We always emit 4 bytes of displacement, even when we've
emitted the 0x67 prefix and should only be emitting *2* bytes of displacement.
And we end up using the wrong registers too, since we use the ModR/M table for
32-bit mode when we should be using the 16-bit one.

Consider this test case, compiled with '-m32 -c -o foo.o foo.S'

      movw $0x55aa, 0x1234(%bp)

GCC quite correctly gives the following:

00000000 <.text>:
   0:    67 66 c7 86 34 12 aa     movw   $0x55aa,0x1234(%bp)
   7:    55 

But clang gives this erroneous output:

00000000 <.text>:
   0:    67 66 c7 85 34 12 00     movw   $0x0,0x1234(%di)
   7:    00 
   8:    aa                       stos   %al,%es:(%edi)
   9:    55                       push   %ebp

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131212/114c1f13/attachment.html>


More information about the llvm-bugs mailing list