[llvm-bugs] [Bug 52062] New: Failure to optimize out strncpy immediately followed by memset

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 4 04:01:13 PDT 2021


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

            Bug ID: 52062
           Summary: Failure to optimize out strncpy immediately followed
                    by memset
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: llvm-bugs at lists.llvm.org

extern void frob(char *);

void g(char *s)
{
  char a[8];
  __builtin_strncpy(a, s, sizeof a);
  __builtin_memset(a, 0, sizeof a);
  frob(a);
}

The `__builtin_strncpy(a, s, sizeof a);` statement can be optimized out. This
optimization is done by GCC, but not by LLVM.

-- 
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/20211004/55a85abb/attachment-0001.html>


More information about the llvm-bugs mailing list