public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5292] Fix uninitialized access in merge_call_side_effects
@ 2021-11-16 8:16 Jan Hubicka
0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2021-11-16 8:16 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e69b7c5779863469479698f863ab25e0d9b4586e
commit r12-5292-ge69b7c5779863469479698f863ab25e0d9b4586e
Author: Jan Hubicka <jh@suse.cz>
Date: Tue Nov 16 09:15:39 2021 +0100
Fix uninitialized access in merge_call_side_effects
gcc/ChangeLog:
PR ipa/103262
* ipa-modref.c (merge_call_side_effects): Fix uninitialized
access.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/modref-dse-5.c: New test.
Diff:
---
gcc/ipa-modref.c | 64 ++++++++++++++--------------
gcc/testsuite/gcc.dg/tree-ssa/modref-dse-5.c | 43 +++++++++++++++++++
2 files changed, 75 insertions(+), 32 deletions(-)
diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index d9d48cc2291..57834303290 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -1014,38 +1014,6 @@ merge_call_side_effects (modref_summary *cur_summary,
changed = true;
}
- if (always_executed
- && callee_summary->kills.length ()
- && (!cfun->can_throw_non_call_exceptions
- || !stmt_could_throw_p (cfun, stmt)))
- {
- /* Watch for self recursive updates. */
- auto_vec<modref_access_node, 32> saved_kills;
-
- saved_kills.reserve_exact (callee_summary->kills.length ());
- saved_kills.splice (callee_summary->kills);
- for (auto kill : saved_kills)
- {
- if (kill.parm_index >= (int)parm_map.length ())
- continue;
- modref_parm_map &m
- = kill.parm_index == MODREF_STATIC_CHAIN_PARM
- ? chain_map
- : parm_map[kill.parm_index];
- if (m.parm_index == MODREF_LOCAL_MEMORY_PARM
- || m.parm_index == MODREF_UNKNOWN_PARM
- || m.parm_index == MODREF_RETSLOT_PARM
- || !m.parm_offset_known)
- continue;
- modref_access_node n = kill;
- n.parm_index = m.parm_index;
- n.parm_offset += m.parm_offset;
- if (modref_access_node::insert_kill (cur_summary->kills, n,
- record_adjustments))
- changed = true;
- }
- }
-
/* We can not safely optimize based on summary of callee if it does
not always bind to current def: it is possible that memory load
was optimized out earlier which may not happen in the interposed
@@ -1095,6 +1063,38 @@ merge_call_side_effects (modref_summary *cur_summary,
if (dump_file)
fprintf (dump_file, "\n");
+ if (always_executed
+ && callee_summary->kills.length ()
+ && (!cfun->can_throw_non_call_exceptions
+ || !stmt_could_throw_p (cfun, stmt)))
+ {
+ /* Watch for self recursive updates. */
+ auto_vec<modref_access_node, 32> saved_kills;
+
+ saved_kills.reserve_exact (callee_summary->kills.length ());
+ saved_kills.splice (callee_summary->kills);
+ for (auto kill : saved_kills)
+ {
+ if (kill.parm_index >= (int)parm_map.length ())
+ continue;
+ modref_parm_map &m
+ = kill.parm_index == MODREF_STATIC_CHAIN_PARM
+ ? chain_map
+ : parm_map[kill.parm_index];
+ if (m.parm_index == MODREF_LOCAL_MEMORY_PARM
+ || m.parm_index == MODREF_UNKNOWN_PARM
+ || m.parm_index == MODREF_RETSLOT_PARM
+ || !m.parm_offset_known)
+ continue;
+ modref_access_node n = kill;
+ n.parm_index = m.parm_index;
+ n.parm_offset += m.parm_offset;
+ if (modref_access_node::insert_kill (cur_summary->kills, n,
+ record_adjustments))
+ changed = true;
+ }
+ }
+
/* Merge with callee's summary. */
changed |= cur_summary->loads->merge (callee_summary->loads, &parm_map,
&chain_map, record_adjustments);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-dse-5.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-dse-5.c
new file mode 100644
index 00000000000..ad35b70136f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/modref-dse-5.c
@@ -0,0 +1,43 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-dse2-details" } */
+struct a {int a,b,c;};
+__attribute__ ((noinline))
+void
+kill_me (struct a *a)
+{
+ a->a=0;
+ a->b=0;
+ a->c=0;
+}
+__attribute__ ((noinline))
+int
+wrap(int b, struct a *a)
+{
+ kill_me (a);
+ return b;
+}
+__attribute__ ((noinline))
+void
+my_pleasure (struct a *a)
+{
+ a->a=1;
+ a->c=2;
+}
+__attribute__ ((noinline))
+int
+wrap2(int b, struct a *a)
+{
+ my_pleasure (a);
+ return b;
+}
+
+int
+set (struct a *a)
+{
+ wrap (0, a);
+ int ret = wrap2 (0, a);
+ //int ret = my_pleasure (a);
+ a->b=1;
+ return ret;
+}
+/* { dg-final { scan-tree-dump "Deleted dead store: wrap" "dse2" } } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-16 8:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 8:16 [gcc r12-5292] Fix uninitialized access in merge_call_side_effects Jan Hubicka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).