[Bug tree-optimization/80576] dead strcpy and strncpy followed by memset not eliminated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80576 --- Comment #6 from Jeffrey A. Law --- *** Bug 81810 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/80576] dead strcpy and strncpy followed by memset not eliminated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80576 --- Comment #5 from Jeffrey A. Law --- Interestingly enough, it never comes up in gcc AFAICT, at least not the str* followed by memcpy/memset variant that shows up in that BZ. I don't think it'd be terribly hard to support, but if it's not going to help real code I'm not too inclined to add the complexity. The non-constant memcpy followed by a full object memset isn't optimized either. But that's a function of the non-constant sized memcpy. It'd likely fall into the same bucket too. Let me do some instrumentation on this variant.
[Bug tree-optimization/80576] dead strcpy and strncpy followed by memset not eliminated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80576 --- Comment #4 from Martin Sebor --- I've seen code similar to it but I don't remember how close they were. I imagine it comes up quite a bit as GCC itself transforms code in various ways. DSE already eliminates stores with constant sizes but it doesn't handle the non-constant ones: $ cat pr80576.c && gcc -O2 -S -Wall -Wextra -Wpedantic -fdump-tree-optimized=/dev/stdout pr80576.c extern char a[32]; void f (const char *s) { __builtin_memcpy (a, s, 7);// eliminated __builtin_memset (a, 0, sizeof a); } void g (const char *s, unsigned n) { __builtin_memcpy (a, s, n);// not eliminated __builtin_memset (a, 0, sizeof a); } ;; Function f (f, funcdef_no=0, decl_uid=1909, cgraph_uid=1, symbol_order=0) f (const char * s) { [local count: 1073741824]: __builtin_memset (, 0, 32); [tail call] return; } ;; Function g (g, funcdef_no=1, decl_uid=1913, cgraph_uid=2, symbol_order=1) g (const char * s, unsigned int n) { long unsigned int _1; [local count: 1073741824]: _1 = (long unsigned int) n_2(D); __builtin_memcpy (, s_4(D), _1); __builtin_memset (, 0, 32); [tail call] return; }
[Bug tree-optimization/80576] dead strcpy and strncpy followed by memset not eliminated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80576 Jeffrey A. Law changed: What|Removed |Added CC||law at redhat dot com --- Comment #3 from Jeffrey A. Law --- I happened to stumble across this while looking for something else in BZ. I don't think it'd be hard to do this in DSE. The question I have is how common this is in practice. Have you seen this kind of code in the wild?
[Bug tree-optimization/80576] dead strcpy and strncpy followed by memset not eliminated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80576 Eric Gallager changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-08-29 CC||egallager at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Eric Gallager --- Confirmed.
[Bug tree-optimization/80576] dead strcpy and strncpy followed by memset not eliminated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80576 Martin Sebor changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=79715 --- Comment #1 from Martin Sebor --- See also bug 79715.