[LLVMbugs] [Bug 22022] New: Inline assembly MMX register bugs

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Dec 24 01:41:52 PST 2014


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

            Bug ID: 22022
           Summary: Inline assembly MMX register bugs
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: adam at consulting.net.nz
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Thanks for a great compiler that is steadily improving!

Inline assembly with MMX registers is fragile. It's unusual to use MMX
registers so I'm likely exercising previously untested code paths.

Here are a couple of examples that fail:

//Example 1
#include <stdint.h>
#include <stdio.h>

typedef uint8_t mmx_t __attribute__ ((vector_size (8)));

int main(void) {
  register mmx_t mmx asm ("mm0");
  asm volatile ("" : "+y" (mmx));
  printf("%d\n", mmx[0]);
  return 0;
}

$ clang-3.6 --version
Debian clang version 3.6.0-svn224681-1~exp1 (trunk) (based on LLVM 3.6.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
(approx. 20 December 2014 snapshot)

$ clang-3.6 -O3 clang-u8x8-mmx-bug.c
clang-u8x8-mmx-bug.c:8:17: error: non-trivial scalar-to-vector conversion,
possible invalid constraint for vector type
  asm volatile ("" : "+y" (mmx));
                ^
1 error generated.

Note: y is the machine constraint for any MMX register:
<https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html>


//Example 2 (MMX register is now defined as one 64 bit value)
#include <stdint.h>
#include <stdio.h>

typedef uint64_t mmx_t __attribute__ ((vector_size (8)));

int main(void) {
  register mmx_t mmx asm ("mm0");
  asm volatile ("" : "+y" (mmx));
  printf("%ld\n", mmx[0]);
  return 0;
}

$ clang-3.6 -O3 clang-u64-mmx-bug.c
fatal error: error in backend: Cannot select: 0x2138870: i64 = truncate
0x2138760 [ORD=2] [ID=27]
  0x2138760: x86mmx,ch,glue = CopyFromReg 0x2138650, 0x2137ee0, 0x2138650:1
[ORD=2] [ID=25]
    0x2137ee0: x86mmx = Register %MM0 [ID=5]
    0x2138650: ch,glue = inlineasm 0x2138210, 0x2137aa0, 0x2137bb0, 0x2137cc0,
0x2137dd0, 0x2137ee0, 0x2138320, 0x2138100, 0x2138430, 0x2138540, 0x2138210:1
[ORD=2] [ID=24]
      0x2137aa0: i64 = TargetExternalSymbol'' [ID=1]
      0x2137cc0: i64 = TargetConstant<1> [ID=3]
      0x2137dd0: i32 = TargetConstant<10> [ID=4]
      0x2137ee0: x86mmx = Register %MM0 [ID=5]
      0x2138320: i32 = TargetConstant<-2147483639> [ID=8]
      0x2138100: x86mmx = Register %vreg0 [ID=7]
      0x2138430: i32 = TargetConstant<12> [ID=9]
      0x2138540: i32 = Register %EFLAGS [ID=10]
      0x2138210: ch,glue = CopyToReg 0x20ee730, 0x2138100, 0x2137ff0 [ORD=2]
[ID=22]
        0x2138100: x86mmx = Register %vreg0 [ID=7]
        0x2137ff0: x86mmx = undef [ID=6]
In function: main
clang: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
Debian clang version 3.6.0-svn224681-1~exp1 (trunk) (based on LLVM 3.6.0)
Target: x86_64-pc-linux-gnu
Thread model: posix

-- 
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/20141224/c5034ece/attachment.html>


More information about the llvm-bugs mailing list