[LLVMbugs] [Bug 17959] New: Strange handling of asm constraints

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Nov 16 10:17:36 PST 2013


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

            Bug ID: 17959
           Summary: Strange handling of asm constraints
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: marc.glisse at normalesup.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

double f(double x){
  asm volatile ("" : "+x"(x) );
  asm volatile ("" : "+m"(x) );
  asm volatile ("" : "+f"(x) );
  asm volatile ("" : "+mx"(x) );
  asm volatile ("" : "+mf"(x) );
  asm volatile ("" : "+xm"(x) );
  asm volatile ("" : "+xf"(x) );
  asm volatile ("" : "+fx"(x) );
  asm volatile ("" : "+fm"(x) );
  asm volatile ("" : "+mxf"(x) );
  asm volatile ("" : "+mfx"(x) );
  asm volatile ("" : "+fmx"(x) );
  asm volatile ("" : "+fxm"(x) );
  asm volatile ("" : "+xfm"(x) );
  asm volatile ("" : "+xmf"(x) );
  return x;
}

compiled with clang complains:
error: illegal "f" output constraint
for each line where there isn't an 'x' before the 'f'. That seems inconsistent.
And the 'f' seems ignored in the cases where it isn't rejected.

Now if I compile:
  asm volatile ("" : "+x"(x) );
with -m64 -O, I get the expected empty assembler output (just 'ret').
But with "+xm", the compiler somehow adds:
    movsd    %xmm0, -8(%rsp)
before and after the asm (I would maybe understand if the second movsd was
reversed, it would just mean that llvm wrongly prefers 'm' to 'x', but the same
movsd is confusing me).

Similarly strange things happen with -m32, producing for instance:
    subl    $12, %esp
    movsd    16(%esp), %xmm0
    movsd    %xmm0, (%esp)
    #APP
    #NO_APP
    movsd    %xmm0, (%esp)
    fldl    (%esp)
    addl    $12, %esp

when with just "+x" it manages the less strange:
    subl    $12, %esp
    movsd    16(%esp), %xmm0
    #APP
    #NO_APP
    movsd    %xmm0, (%esp)
    fldl    (%esp)
    addl    $12, %esp
    ret

Note that inline asm is all the more necessary with llvm ignoring fenv floating
point support.

-- 
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/20131116/5aebd363/attachment.html>


More information about the llvm-bugs mailing list