Improve handling of return slot in ipa-pure-const and modref.
commitca84f39399fda80c770306465276ffd66d3766ed
authorJan Hubicka <hubicka@ucw.cz>
Sun, 31 Oct 2021 22:14:29 +0000 (31 23:14 +0100)
committerJan Hubicka <hubicka@ucw.cz>
Sun, 31 Oct 2021 22:14:29 +0000 (31 23:14 +0100)
tree6bb38a6cd317c43716c251388b7aa9b10c5302b8
parentd41092ec52f46d2f4b08fff8d1519e50354331b0
Improve handling of return slot in ipa-pure-const and modref.

while preparing testcase for return slot tracking I noticed that both
ipa-pure-const and modref treat return slot writes as non-local which prevents
detecting functions as pure or not modifying global state.  Fixed by making
points_to_local_or_readonly_memory_p to special case return slot.  This is bit
of a side case, but presently at all uses of
points_to_local_or_readonly_memory_p we want to handle return slot this way.

I also noticed that we handle gimple copy unnecesarily pesimistically.  This
does not make difference right now since we do no not track non-scalars, but
I fixed it anyway.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

* ipa-fnsummary.c: Include tree-dfa.h.
(points_to_local_or_readonly_memory_p): Return true on return
slot writes.
* ipa-modref.c (analyze_ssa_name_flags): Fix handling of copy
statement.

gcc/testsuite/ChangeLog:

* g++.dg/ipa/modref-1.C: New test.
gcc/ipa-fnsummary.c
gcc/ipa-modref.c
gcc/testsuite/g++.dg/ipa/modref-1.C [new file with mode: 0644]