[LLVMbugs] [Bug 13841] New: clang misscompiles complex asm at -O0

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 13 14:17:34 PDT 2012


             Bug #: 13841
           Summary: clang misscompiles complex asm at -O0
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: michaelni at gmx.at
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Tested with clang version 3.1 (trunk 144800) on ubuntu and clang version 3.0
(tags/RELEASE_30/final) on netbsd

The problem can be reproduced with ffmpeg 51fa6538 using the regression test
suite: ./configure --cc=clang --samples=yourpathto/fate-suite/ --enable-gpl
--disable-optimizations && make -j12 fate

(you can fetch the fate suite with make fate-rsync)

The problem is in the get_cabac_inline_x86() function and also occurs without
it being inlined. It seems clang forgets loading the input for at least the
"+&r"(c->range) operand. A workaround is to use "=&r" and a explicit "2" later
(this workaround will likely end in ffmpeg soon)

The diff from changing the 2 "+&r" to "=&r" with "1" and "2" later is:
(you can see here that r10 is uninitialized before and afterwards the
equivalent r9 is initialized)

 get_cabac_inline_x86:                   # @get_cabac_inline_x86
        .loc    6 158 0                 # libavcodec/x86/cabac.h:158:0
 # BB#0:                                 # %entry
-       pushq   %rbx
-       .cfi_def_cfa_offset 16
-       .cfi_offset %rbx, -16
        movq    %rdi, -8(%rsp)
        movq    %rsi, -16(%rsp)
        .loc    6 169 5 prologue_end    # libavcodec/x86/cabac.h:169:5
        movq    -8(%rsp), %rsi
-       movl    (%rsi), %eax
        movq    -8(%rsp), %rdi
-       movl    4(%rdi), %ecx
-       movq    -16(%rsp), %rdx
-       movq    -8(%rsp), %r8
-       movl    %ecx, -28(%rsp)         # 4-byte Spill
+       movq    -16(%rsp), %rax
+       movq    -8(%rsp), %rcx
+       movq    -8(%rsp), %rdx
+       movl    (%rdx), %r8d
+       movq    -8(%rsp), %rdx
+       movl    4(%rdx), %r9d
+       movq    %rcx, -32(%rsp)         # 8-byte Spill
+       movq    -32(%rsp), %rdx         # 8-byte Reload
-       movzbl (%rdx)    , %r9d                                     
-       mov    %r10d     , %r11d                                     
-       and    $0xC0       , %r10d                                   
-       movzbl ff_h264_cabac_tables+512(%r9d, %r10d, 2), %r10d 
-       sub    %r10d     , %r11d                                     
+       movzbl (%rax)    , %r10d                                     
+       mov    %r9d     , %r11d                                     
+       and    $0xC0       , %r9d                                   
+       movzbl ff_h264_cabac_tables+512(%r10d, %r9d, 2), %r9d

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