[llvm-bugs] [Bug 47644] New: Improve DSE with libcalls

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 25 05:59:51 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47644

            Bug ID: 47644
           Summary: Improve DSE with libcalls
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

void f(const char *s) {
  char a[256];
  __builtin_strcpy(a, s);  // dead store
}

void g(const char *s) {
  char a[256];
  __builtin_memcpy(a, s, sizeof a);  // dead store
}

char d[256];

void h(const char *s) {

  __builtin_strcpy(d, s);  // dead store
  __builtin_memset(d, 0, sizeof d);
}

Clang:
f(char const*):                                # @f(char const*)
        sub     rsp, 264
        mov     rsi, rdi
        mov     rdi, rsp
        call    strcpy
        add     rsp, 264
        ret
g(char const*):                                # @g(char const*)
        ret
h(char const*):                                # @h(char const*)
        push    rax
        mov     rsi, rdi
        mov     edi, offset d
        call    strcpy
        xorps   xmm0, xmm0
        movaps  xmmword ptr [rip + d], xmm0
        movaps  xmmword ptr [rip + d+16], xmm0
        movaps  xmmword ptr [rip + d+32], xmm0
        movaps  xmmword ptr [rip + d+48], xmm0
        movaps  xmmword ptr [rip + d+64], xmm0
        movaps  xmmword ptr [rip + d+80], xmm0
        movaps  xmmword ptr [rip + d+96], xmm0
        movaps  xmmword ptr [rip + d+112], xmm0
        movaps  xmmword ptr [rip + d+128], xmm0
        movaps  xmmword ptr [rip + d+144], xmm0
        movaps  xmmword ptr [rip + d+160], xmm0
        movaps  xmmword ptr [rip + d+176], xmm0
        movaps  xmmword ptr [rip + d+192], xmm0
        movaps  xmmword ptr [rip + d+208], xmm0
        movaps  xmmword ptr [rip + d+224], xmm0
        movaps  xmmword ptr [rip + d+240], xmm0
        pop     rax
        ret
d:
        .zero   256



We should be able eliminate strcpy calls (based on deref. bytes info, memset
overwrites the whole buffer)

-- 
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/20200925/d13d26e0/attachment.html>


More information about the llvm-bugs mailing list