[PATCH] D47198: [InstCombine] Replace malloc+strcpy with malloc+memcpy
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 22 11:07:50 PDT 2018
efriedma added a comment.
What does the malloc have to do with this transform? The transform here is just `strcpy(d, s)` -> `memcpy(d, s, strlen(s)+1)`, where `strlen(s)` is free because we can CSE it with the previous call. I guess in general, you can transform `strcpy(malloc(strlen(s)+1), s)` to strdup, but that's not what you're doing.
Also, you're making the same mistake *again*: you're not checking whether the string is modified between the strlen and the strcpy.
https://reviews.llvm.org/D47198
More information about the llvm-commits
mailing list