[llvm-bugs] [Bug 32568] New: Bad code generation with cmpxchg16b and __uint128_t

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 7 10:54:05 PDT 2017


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

            Bug ID: 32568
           Summary: Bad code generation with cmpxchg16b and __uint128_t
           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 18249
  --> http://bugs.llvm.org/attachment.cgi?id=18249&action=edit
Preprocessed file (-E)

Hello,

clang 3.8 and 4.0 at least seem to generate bad code around a cmpxchg16b asm
instruction that uses __uint128_t. The code is as follows:

ret = cmpxchg16b(entry, &old_ire, new_ire);
ASSERT(ret == old_ire.val);

This leads to clang generating the following asm:

mov    %r15,%rdx
shr    $0x20,%rdx
mov    %r12,%rcx
mov    %r15d,%eax
lock cmpxchg16b (%r14)
xor    %eax,%eax
test   %al,%al

I'm attaching the pre-processed output that causes this. The function where
this happens is update_irte.

The rune used to compile the file is:

clang -m64 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes
-Wdeclaration-after-statement -Wno-unused-local-typedefs   -O1 -nostdinc
-fno-builtin -fno-common -Werror -Wredundant-decls -Wno-pointer-arith -pipe -g
-D__XEN__ -include /root/xen/xen/include/xen/config.h
'-D__OBJECT_FILE__="intremap.o"' -fno-omit-frame-pointer -MMD -MF
./.intremap.o.d -I/root/xen/xen/include
-I/root/xen/xen/include/asm-x86/mach-generic
-I/root/xen/xen/include/asm-x86/mach-default -DXEN_IMG_OFFSET=0x200000
'-D__OBJECT_LABEL__=drivers$passthrough$vtd$intremap.o' -msoft-float
-fno-stack-protector -fno-exceptions -Wnested-externs -DHAVE_GAS_VMX
-DHAVE_GAS_SSE4_2 -DHAVE_GAS_EPT -DHAVE_GAS_RDRAND -DHAVE_GAS_RDSEED
-mno-red-zone -mno-sse -fpic -fno-asynchronous-unwind-tables
-DGCC_HAS_VISIBILITY_ATTRIBUTE -c intremap.c -o intremap.o

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/20170407/c1ca00a7/attachment-0001.html>


More information about the llvm-bugs mailing list