[llvm-bugs] [Bug 32594] New: Error with inline asm constraint "=A" on amd64

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 10 06:16:58 PDT 2017


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

            Bug ID: 32594
           Summary: Error with inline asm constraint "=A" on amd64
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: royger at freebsd.org
                CC: llvm-bugs at lists.llvm.org

Created attachment 18257
  --> http://bugs.llvm.org/attachment.cgi?id=18257&action=edit
Preprocessed C file

When the "=A" inline asm constrain is used to generate x86 64bit code clang
trows an internal error:

$ cc -o test test.c
fatal error: error in backend: Cannot select: t53: i64 = build_pair t51, t52
  t51: i32,ch,glue = CopyFromReg t50, Register:i32 %EAX, t50:1
    t31: i32 = Register %EAX
    t50: ch,glue = inlineasm t46, TargetExternalSymbol:i64'lock; cmpxchg16b
$2', MDNode:ch<0x803b3e4a8>, TargetConstant:i64<25>, TargetConstant:i32<18>,
Register:i32 %EAX, Register:i32 %EDX, TargetConstant:i32<196622>,
FrameIndex:i64<1>, TargetConstant:i32<9>, Register:i64 %RCX,
TargetConstant:i32<9>, Register:i64 %RBX, TargetConstant:i32<-2147483631>,
Register:i32 %vreg6, Register:i32 %vreg7, TargetConstant:i32<196622>,
FrameIndex:i64<1>, TargetConstant:i32<12>, Register:i32 %EFLAGS, t46:1
      t27: i64 = TargetExternalSymbol'lock; cmpxchg16b $2'
      t29: i64 = TargetConstant<25>
      t30: i32 = TargetConstant<18>
      t31: i32 = Register %EAX
      t32: i32 = Register %EDX
      t33: i32 = TargetConstant<196622>
      t3: i64 = FrameIndex<1>
      t36: i32 = TargetConstant<9>
      t34: i64 = Register %RCX
      t36: i32 = TargetConstant<9>
      t37: i64 = Register %RBX
      t47: i32 = TargetConstant<-2147483631>
      t43: i32 = Register %vreg6
      t45: i32 = Register %vreg7
      t33: i32 = TargetConstant<196622>
      t3: i64 = FrameIndex<1>
      t48: i32 = TargetConstant<12>
      t49: i32 = Register %EFLAGS
      t46: ch,glue = CopyToReg t38, Register:i32 %vreg7, t93, t44:1
        t45: i32 = Register %vreg7
        t93: i32 = truncate t92
          t92: i64 = srl t72, Constant:i8<32>
            t72: i64,ch = load<LD8[%6](align=16)> t81, t24, undef:i64
              t24: i64,ch = load<LD8[%oldp.addr]> t81, FrameIndex:i64<2>,
undef:i64
                t9: i64 = FrameIndex<2>
                t5: i64 = undef
              t5: i64 = undef
            t91: i8 = Constant<32>
        t44: ch,glue = CopyToReg t38, Register:i32 %vreg6, t90, t38:1
          t43: i32 = Register %vreg6
          t90: i32 = truncate t72
            t72: i64,ch = load<LD8[%6](align=16)> t81, t24, undef:i64
              t24: i64,ch = load<LD8[%oldp.addr]> t81, FrameIndex:i64<2>,
undef:i64
                t9: i64 = FrameIndex<2>
                t5: i64 = undef
              t5: i64 = undef
          t38: ch,glue = CopyToReg t35, Register:i64 %RBX, t23, t35:1
            t37: i64 = Register %RBX
            t23: i64,ch = load<LD8[%lo](align=16)> t81, FrameIndex:i64<4>,
undef:i64
              t15: i64 = FrameIndex<4>
              t5: i64 = undef
            t35: ch,glue = CopyToReg t26, Register:i64 %RCX, t22
              t34: i64 = Register %RCX
              t22: i64,ch = load<LD8[%hi]> t81, t73, undef:i64
                t73: i64 = or FrameIndex:i64<4>, Constant:i64<8>
                  t15: i64 = FrameIndex<4>
                  t20: i64 = Constant<8>
                t5: i64 = undef
  t52: i32,ch,glue = CopyFromReg t51:1, Register:i32 %EDX, t51:2
    t32: i32 = Register %EDX
    t51: i32,ch,glue = CopyFromReg t50, Register:i32 %EAX, t50:1
      t31: i32 = Register %EAX
      t50: ch,glue = inlineasm t46, TargetExternalSymbol:i64'lock; cmpxchg16b
$2', MDNode:ch<0x803b3e4a8>, TargetConstant:i64<25>, TargetConstant:i32<18>,
Register:i32 %EAX, Register:i32 %EDX, TargetConstant:i32<196622>,
FrameIndex:i64<1>, TargetConstant:i32<9>, Register:i64 %RCX,
TargetConstant:i32<9>, Register:i64 %RBX, TargetConstant:i32<-2147483631>,
Register:i32 %vreg6, Register:i32 %vreg7, TargetConstant:i32<196622>,
FrameIndex:i64<1>, TargetConstant:i32<12>, Register:i32 %EFLAGS, t46:1
        t27: i64 = TargetExternalSymbol'lock; cmpxchg16b $2'
        t29: i64 = TargetConstant<25>
        t30: i32 = TargetConstant<18>
        t31: i32 = Register %EAX
        t32: i32 = Register %EDX
        t33: i32 = TargetConstant<196622>
        t3: i64 = FrameIndex<1>
        t36: i32 = TargetConstant<9>
        t34: i64 = Register %RCX
        t36: i32 = TargetConstant<9>
        t37: i64 = Register %RBX
        t47: i32 = TargetConstant<-2147483631>
        t43: i32 = Register %vreg6
        t45: i32 = Register %vreg7
        t33: i32 = TargetConstant<196622>
        t3: i64 = FrameIndex<1>
        t48: i32 = TargetConstant<12>
        t49: i32 = Register %EFLAGS
        t46: ch,glue = CopyToReg t38, Register:i32 %vreg7, t93, t44:1
          t45: i32 = Register %vreg7
          t93: i32 = truncate t92
            t92: i64 = srl t72, Constant:i8<32>
              t72: i64,ch = load<LD8[%6](align=16)> t81, t24, undef:i64
                t24: i64,ch = load<LD8[%oldp.addr]> t81, FrameIndex:i64<2>,
undef:i64
                  t9: i64 = FrameIndex<2>
                  t5: i64 = undef
                t5: i64 = undef
              t91: i8 = Constant<32>
          t44: ch,glue = CopyToReg t38, Register:i32 %vreg6, t90, t38:1
            t43: i32 = Register %vreg6
            t90: i32 = truncate t72
              t72: i64,ch = load<LD8[%6](align=16)> t81, t24, undef:i64
                t24: i64,ch = load<LD8[%oldp.addr]> t81, FrameIndex:i64<2>,
undef:i64
                  t9: i64 = FrameIndex<2>
                  t5: i64 = undef
                t5: i64 = undef
            t38: ch,glue = CopyToReg t35, Register:i64 %RBX, t23, t35:1
              t37: i64 = Register %RBX
              t23: i64,ch = load<LD8[%lo](align=16)> t81, FrameIndex:i64<4>,
undef:i64
                t15: i64 = FrameIndex<4>
                t5: i64 = undef
              t35: ch,glue = CopyToReg t26, Register:i64 %RCX, t22
                t34: i64 = Register %RCX
                t22: i64,ch = load<LD8[%hi]> t81, t73, undef:i64
                  t73: i64 = or FrameIndex:i64<4>, Constant:i64<8>


                  t5: i64 = undef
In function: cmpxchg16b
cc: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM
3.8.0)
Target: x86_64-unknown-freebsd11.0
Thread model: posix
InstalledDir: /usr/bin
cc: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed
source, and associated run script.
cc: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
cc: note: diagnostic msg: /tmp/test-6fbfe6.c
cc: note: diagnostic msg: /tmp/test-6fbfe6.sh
cc: note: diagnostic msg:

********************

AFAICT clang is trying to use the eax:edx registers, which is wrong. On 64bit
the ax and dx registers are rax and rdx.

Attaching the preprocessed file and run scripts.

Thanks, Roger.

-- 
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/20170410/27462adb/attachment.html>


More information about the llvm-bugs mailing list