This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/71315] missing strlen optimization on a POINTER_PLUS expression
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 Jul 2016 13:43:05 +0000
- Subject: [Bug middle-end/71315] missing strlen optimization on a POINTER_PLUS expression
- Auto-submitted: auto-generated
- References: <bug-71315-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71315
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This is alias analysis deficiency. It considers s escaped, because &s[0] is
passed to a function (strlen), but __builtin_strlen really is not allowed to
save the argument into some global var that e.g. the following call to f
function could then use to modify it.
The strlen pass just uses the alias oracle to query if it needs to invalidate
remembered string lengths, in particular on the f () call. As the alias oracle
considers s to be escaped, it returns that the f () call might change it (which
it indeed could if instead of __builtin_strlen one used some function with the
same prototype, but on which the compiler can't make any assumptions).