[LLVMbugs] [Bug 8959] New: inline asm "0" constraint doesn't implicitly cast

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jan 11 11:52:42 PST 2011


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

           Summary: inline asm "0" constraint doesn't implicitly cast
           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: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, spectral at google.com


This is a breakout from bug 3373 comment 11. New testcase:

  int test_and_set(volatile int *addr)
  {
    unsigned char oldval;
    /* Note: the "xchg" instruction does not need a "lock" prefix */
    __asm__ __volatile__("xchgb %0, %1"
                  : "=Q"(oldval), "=m"(*addr)
                  : "0"(0xff), "m"(*addr) : "memory");
    return (int)oldval;
  }

which produces:

  $ clang t.c -S -o -
  t.c:7:25: error: unsupported inline asm: input with type 'int' matching
output
        with type 'unsigned char'
                    : "0"(0xff), "m"(*addr) : "memory");
                          ^~~~
  1 error generated.

Ian Taylor explains: "Clang is incorrectly assuming that when given an operand
number as a constraint that the type of a constant must be identical to the
type of the other operand.  When the operand is a constant, it should be
converted to the relevant type as though in an assignment.  When the operand is
a variable of some sort, it must of course have exactly the correct type."

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