[LLVMbugs] [Bug 12173] incorrect shrdq instruction from __asm__() directive

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 5 22:16:21 PST 2012


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

Steve Hartwell <shartwell at vmware.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
            Version|3.0                         |trunk
         Resolution|FIXED                       |

--- Comment #2 from Steve Hartwell <shartwell at vmware.com> 2012-03-06 00:16:21 CST ---
Change r152014 addresses the shift count in %cl, but in the registers are still
in the wrong order, as indicated in the bug description.

$ clang --version
clang version 3.1 (trunk 152062 trunk 152099)
Target: x86_64-apple-darwin11.3.0
Thread model: posix
$ clang -c -O2 asmshift.c
$ otool -tv asmshift.o
asmshift.o:
(__TEXT,__text) section
_badshift:
0000000000000000 pushq    %rbp
0000000000000001 movq    %rsp,%rbp
0000000000000004     movb    %dl,%cl
0000000000000006 shrdq    %cl,%rax,%rdx      <----- wrong register order
000000000000000a popq    %rbp
000000000000000b ret
000000000000000c    nopl    0x00(%rax)
_goodshift:
0000000000000010     pushq    %rbp
0000000000000011 movq    %rsp,%rbp
0000000000000014     movb    %dl,%cl
0000000000000016     shrdq    %cl,%rdx,%rax
000000000000001a     popq    %rbp
000000000000001b ret

Note that the assembler output has the registers in the correct order:
$ clang -s -O2 asmshift.c
$ cat asmshift.s

    .section    __TEXT,__text,regular,pure_instructions
    .globl    _badshift
    .align    4, 0x90
_badshift:                              ## @badshift
    .cfi_startproc
## BB#0:                                ## %entry
    pushq    %rbp
Ltmp2:
    .cfi_def_cfa_offset 16
Ltmp3:
    .cfi_offset %rbp, -16
    movq    %rsp, %rbp
Ltmp4:
    .cfi_def_cfa_register %rbp
    movb    %dl, %cl
    ## InlineAsm Start
    shrdq   %rdx, %rax                        <--------- correct register order
    ## InlineAsm End
    popq    %rbp
    ret
    .cfi_endproc

    .globl    _goodshift
    .align    4, 0x90
_goodshift:                             ## @goodshift
    .cfi_startproc
## BB#0:                                ## %entry
    pushq    %rbp
Ltmp7:
    .cfi_def_cfa_offset 16
Ltmp8:
    .cfi_offset %rbp, -16
    movq    %rsp, %rbp
Ltmp9:
    .cfi_def_cfa_register %rbp
    movb    %dl, %cl
    ## InlineAsm Start
    shrdq   %cl, %rdx, %rax
    ## InlineAsm End
    popq        %rbp
    ret
    .cfi_endproc


.subsections_via_symbols

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