https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70760

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Where _1(D) is

  # PT =
  struct __single_object & _1(D) = <retval>;

This is in a function deemed local (a ISRA specialization) and thus it looks
like we think there are no callers.

There are indeed callers but to different ISRA specializations.  I suppose
(again) it is IPA ICF that merges them.

There seems to be a disconnect between what versioning does to DECL_RESULT
(and DECL_BY_REFERENCE) and what IPA PTA does vs. non-IPA PTA with regard
to such results.  non-IPA just looks at gimple_call_return_slot_opt_p
while IPA only looks at DECL_BY_REFERENCE.

Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c  (revision 235404)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -4658,9 +4658,11 @@ find_func_aliases_for_call (struct funct

       /* If we pass the result decl by reference, honor that.  */
       if (lhsop
-         && fndecl
-         && DECL_RESULT (fndecl)
-         && DECL_BY_REFERENCE (DECL_RESULT (fndecl)))
+         && ((fndecl
+              && DECL_RESULT (fndecl)
+              && DECL_BY_REFERENCE (DECL_RESULT (fndecl)))
+             || (gimple_call_return_slot_opt_p (t)
+                 && TREE_ADDRESSABLE (TREE_TYPE (lhsop)))))
        {
          struct constraint_expr lhs;
          struct constraint_expr *rhsp;

fixes that but the following should also work (but is obviously less safe).

Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c  (revision 235404)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -4658,9 +4658,8 @@ find_func_aliases_for_call (struct funct

       /* If we pass the result decl by reference, honor that.  */
       if (lhsop
-         && fndecl
-         && DECL_RESULT (fndecl)
-         && DECL_BY_REFERENCE (DECL_RESULT (fndecl)))
+         && gimple_call_return_slot_opt_p (t)
+         && TREE_ADDRESSABLE (TREE_TYPE (lhsop)))
        {
          struct constraint_expr lhs;
          struct constraint_expr *rhsp;

so can you test the latter on your app?  I'm giving it IPA PTA + LTO bootstrap
testing.

Reply via email to