[LLVMbugs] [Bug 7509] New: [inline asm] forced register + -O0 + locational input arg == wrong/no input placement

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 26 20:50:06 PDT 2010


           Summary: [inline asm] forced register + -O0 + locational input
                    arg == wrong/no input placement
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: kaffeemonster at googlemail.com
                CC: dalej at apple.com, llvmbugs at cs.uiuc.edu

clang TOT at 106969

After Bug #6520 is fixed, the testcase over there is fixed, but the real source
still does not compile...
This time it gets a little bit trickier:

unsigned long func(const char *s)
        const char *p;
        unsigned long len, f, t;

        asm (
                "xchg   %0, (%1)\n\t"
        : /* %0 */ "=a" (len),
          /* %1 */ "=r" (p),
          /* %2 */ "=r" (t),
          /* %3 */ "=r" (f)
        : /* %4 */ "1" (s)
        return len;

The result is that the $whatever-component (RA?) totally forgets to get the
input "s" into %1. This is again striped down, but complicated enough to make
the problem obvious, all the fluff is only to not make the output look right by
accident (the prolog puts the right value into the reg by accident) or the
compiler has an easy way out (choosing %eax for %1).
This is what i get:

00000000 <func>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   56                      push   %esi
   4:   83 ec 1c                sub    $0x1c,%esp
   7:   8b 45 08                mov    0x8(%ebp),%eax
   a:   89 45 f8                mov    %eax,-0x8(%ebp)
   d:   8b 45 f8                mov    -0x8(%ebp),%eax
  10:   89 45 e4                mov    %eax,-0x1c(%ebp)
  13:   87 01                   xchg   %eax,(%ecx)
  15:   89 4d e4                mov    %ecx,-0x1c(%ebp)
  18:   89 45 f0                mov    %eax,-0x10(%ebp)
  1b:   89 4d f4                mov    %ecx,-0xc(%ebp)
  1e:   89 55 e8                mov    %edx,-0x18(%ebp)
  21:   89 75 ec                mov    %esi,-0x14(%ebp)
  24:   8b 45 f0                mov    -0x10(%ebp),%eax
  27:   83 c4 1c                add    $0x1c,%esp
  2a:   5e                      pop    %esi
  2b:   5d                      pop    %ebp
  2c:   c3                      ret

As one can see, %ecx is used for %1, but it is never initialized.


PS: isn't there a pass to prevent the dead spills of edx && esi?

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