diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2021-08-23 09:21:36 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@ucw.cz> | 2021-08-23 09:22:22 +0200 |
commit | 59f38935d189027f172b4813a6056addaceb7cd3 (patch) | |
tree | d73fad95ddf379719bb3a2015aba1a2ac54c3f5f /gcc/ipa-modref.c | |
parent | f93f0868919ab32bfbc24adb40158298031a4d58 (diff) | |
download | gcc-59f38935d189027f172b4813a6056addaceb7cd3.zip gcc-59f38935d189027f172b4813a6056addaceb7cd3.tar.gz gcc-59f38935d189027f172b4813a6056addaceb7cd3.tar.bz2 |
Improve return slot handling in ipa-modref
gcc/ChangeLog:
* ipa-modref.c (analyze_ssa_name_flags): Improve handling of return slot.
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/modref-1.C: New test.
Diffstat (limited to 'gcc/ipa-modref.c')
-rw-r--r-- | gcc/ipa-modref.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index 5491538..cb0a314 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -1709,19 +1709,8 @@ analyze_ssa_name_flags (tree name, vec<modref_lattice> &lattice, int depth, if (gimple_call_fn (use_stmt) == name) lattice[index].merge (~EAF_NOCLOBBER); - /* Return slot optimization would require bit of propagation; - give up for now. */ - if (gimple_call_return_slot_opt_p (call) - && gimple_call_lhs (call) != NULL_TREE - && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (call)))) - { - if (dump_file) - fprintf (dump_file, "%*s Unhandled return slot opt\n", - depth * 4, ""); - lattice[index].merge (0); - } /* Recursion would require bit of propagation; give up for now. */ - else if (callee && !ipa && recursive_call_p (current_function_decl, + if (callee && !ipa && recursive_call_p (current_function_decl, callee)) lattice[index].merge (0); else @@ -1735,7 +1724,15 @@ analyze_ssa_name_flags (tree name, vec<modref_lattice> &lattice, int depth, /* Handle *name = func (...). */ if (gimple_call_lhs (call) && memory_access_to (gimple_call_lhs (call), name)) - lattice[index].merge_direct_store (); + { + lattice[index].merge_direct_store (); + /* Return slot optimization passes address of + LHS to callee via hidden parameter and this + may make LHS to escape. See PR 98499. */ + if (gimple_call_return_slot_opt_p (call) + && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (call)))) + lattice[index].merge (EAF_NOREAD | EAF_DIRECT); + } /* We do not track accesses to the static chain (we could) so give up. */ |