[llvm-bugs] [Bug 46490] New: Failure to optimize sprintf of single string to strcpy instead of using strlen+strcpy
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Sun Aug  9 12:42:38 PDT 2020
    
    
  
https://bugs.llvm.org/show_bug.cgi?id=46490
            Bug ID: 46490
           Summary: Failure to optimize sprintf of single string to strcpy
                    instead of using strlen+strcpy
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: RESOLVED
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: llvm-bugs at lists.llvm.org
            Status: RESOLVED
        Resolution: DUPLICATE
void f(char *p, const char *s)
{
    sprintf(p, "%s", s);
}
This can be optimized to `strcpy(p, s)`. This transformation is done by GCC.
but not by LLVM, which instead transforms it to `memcpy(p, s, strlen(s) + 1)`
--- Comment #1 from Gabriel Ravier <gabravier at gmail.com> ---
Oops, looks like this somehow got duplicated. Marked as duplicate of
https://bugs.llvm.org/show_bug.cgi?id=46489
*** This bug has been marked as a duplicate of bug 46489 ***
-- 
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/20200809/7c762279/attachment.html>
    
    
More information about the llvm-bugs
mailing list