Richard Biener <rguenth at gcc dot> changed:

           What    |Removed                     |Added
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2017-02-16
           Assignee|unassigned at gcc dot      |rguenth at gcc dot
     Ever confirmed|0                           |1

--- Comment #3 from Richard Biener <rguenth at gcc dot> ---
Yes, the issue is that we are not told that __builtin_strlen does not return
something that can be used to re-construct the address of 's' and thus
passing that return value to f() makes it escaped.  That is, strlen is not

size_t strlen(const char *s) { return (size_t)s; }

handling strlen inside find_func_aliases_for_builtin_call would fix that part
but for example SCCVN doesn't do stmt walking when CSEing pure calls.  But the
strlen pass then handles things.

Index: gcc/tree-ssa-structalias.c
--- gcc/tree-ssa-structalias.c  (revision 245501)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -4474,6 +4474,12 @@ find_func_aliases_for_builtin_call (stru
            process_all_all_constraints (lhsc, rhsc);
        return true;
+      /* Pure functions that return something not based on any object.  */
+      case BUILT_IN_STRLEN:
+       /* We don't need to do anything here.  No constraints are necessary
+          for the return value and call handling for pure functions is
+          special-cased in the alias oracle.  */
+       return true;
       /* Trampolines are special - they set up passing the static
         frame.  */

any other similar (pure/const) builtins?

Reply via email to