[LLVMbugs] [Bug 15348] New: LLVM seems to be lowering unaligned memcpy as movaps on x86-32 + sse2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 25 05:02:38 PST 2013


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

            Bug ID: 15348
           Summary: LLVM seems to be lowering unaligned memcpy as movaps
                    on x86-32 + sse2
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: chandlerc at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

My test case is currently C++, and triggered due to r175389 emitting memcpy
more often. It was reduced (very greatly) from TargetInfo in a bootstrap...

% cat bitfield.cpp 
struct S {
  S() {}
  S(const S&) {}
  ~S() {}
  void *ptr1, *ptr2;
  unsigned long x;
};

struct X {
  unsigned b00 : 1;
  unsigned b01 : 1;
  unsigned b02 : 1;
  unsigned b03 : 1;
  unsigned b04 : 1;
  unsigned b05 : 1;
  unsigned b06 : 1;
  unsigned b07 : 1;
  unsigned b08 : 1;
  unsigned b09 : 1;
  unsigned b10 : 1;
  unsigned b11 : 1;
  unsigned b12 : 1;
  unsigned b13 : 1;
  unsigned b14 : 1;
  unsigned b15 : 1;
  unsigned u;
  unsigned b16 : 1;
  unsigned b17 : 1;
  unsigned b18 : 1;
  unsigned b19 : 1;
  unsigned u2;
  unsigned b20 : 1;
  unsigned b21 : 1;
  unsigned b22 : 1;
  unsigned b23 : 1;

  S s;

  enum { A, B, C } e1;
  enum { AA, BB, CC } e2;
};

X f(const X &x) { return x; }

int main() {
  X x;
  X y = f(x);
}

% ./bin/clang++ -m32 -march=pentium3 -msse2 -O0 -std=c++03 -o bitfield
bitfield.cpp

% ./bitfield 
zsh: segmentation fault  ./bitfield

% gdb --args ./bitfield
(gdb) r
Starting program: ./bitfield 

Program received signal SIGSEGV, Segmentation fault.
0x08048774 in X::X(X const&) ()
(gdb) disass
Dump of assembler code for function _ZN1XC2ERKS_:
   0x08048750 <+0>:     push   %ebp
   0x08048751 <+1>:     mov    %esp,%ebp
   0x08048753 <+3>:     push   %ebx
   0x08048754 <+4>:     sub    $0x14,%esp
   0x08048757 <+7>:     mov    0xc(%ebp),%eax
   0x0804875a <+10>:    mov    0x8(%ebp),%ecx
   0x0804875d <+13>:    mov    %ecx,-0x8(%ebp)
   0x08048760 <+16>:    mov    %eax,-0xc(%ebp)
   0x08048763 <+19>:    mov    -0x8(%ebp),%eax
   0x08048766 <+22>:    mov    %eax,%ecx
   0x08048768 <+24>:    mov    -0xc(%ebp),%edx
   0x0804876b <+27>:    mov    0x10(%edx),%bl
   0x0804876e <+30>:    mov    %bl,0x10(%ecx)
   0x08048771 <+33>:    movaps (%edx),%xmm0
=> 0x08048774 <+36>:    movaps %xmm0,(%ecx)
   0x08048777 <+39>:    mov    %eax,%ecx
   0x08048779 <+41>:    add    $0x14,%ecx
   0x0804877f <+47>:    mov    -0xc(%ebp),%edx
   0x08048782 <+50>:    add    $0x14,%edx
   0x08048788 <+56>:    mov    %ecx,(%esp)
   0x0804878b <+59>:    mov    %edx,0x4(%esp)
   0x0804878f <+63>:    mov    %eax,-0x10(%ebp)
   0x08048792 <+66>:    call   0x80487b0 <_ZN1SC1ERKS_>
   0x08048797 <+71>:    mov    -0xc(%ebp),%eax
   0x0804879a <+74>:    mov    0x20(%eax),%ecx
   0x0804879d <+77>:    mov    -0x10(%ebp),%edx
   0x080487a0 <+80>:    mov    %ecx,0x20(%edx)
   0x080487a3 <+83>:    mov    0x24(%eax),%eax
   0x080487a6 <+86>:    mov    %eax,0x24(%edx)
   0x080487a9 <+89>:    add    $0x14,%esp
   0x080487ac <+92>:    pop    %ebx
   0x080487ad <+93>:    pop    %ebp
   0x080487ae <+94>:    ret    
End of assembler dump.

-- 
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/20130225/71cba7dc/attachment.html>


More information about the llvm-bugs mailing list