public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5399] Fix IPA modref ubsan.
@ 2021-11-19 11:33 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-11-19 11:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:74a4ece02df1b1b6f396fd0e24dbbf8b0897858a

commit r12-5399-g74a4ece02df1b1b6f396fd0e24dbbf8b0897858a
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Nov 18 13:14:25 2021 +0100

    Fix IPA modref ubsan.
    
    modref_tree<tree_node*>::merge(modref_tree<tree_node*>*, vec<modref_parm_map, va_heap, vl_ptr>*, modref_parm_map*, bool)
    
    is called with modref_parm_map chain_map;
    
    The variable has uninitialized m.parm_offset_known and it is accessed
    here:
    
    gcc/ipa-modref-tree.h:572 a.parm_offset_known &= m.parm_offset_known;
    
            PR ipa/103230
    
    gcc/ChangeLog:
    
            * ipa-modref-tree.h (struct modref_parm_map): Add default
            constructor.
            * ipa-modref.c (ipa_merge_modref_summary_after_inlining): Use it.

Diff:
---
 gcc/ipa-modref-tree.h | 5 +++++
 gcc/ipa-modref.c      | 3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/ipa-modref-tree.h b/gcc/ipa-modref-tree.h
index 0a097349ebd..6796e6ecc34 100644
--- a/gcc/ipa-modref-tree.h
+++ b/gcc/ipa-modref-tree.h
@@ -287,6 +287,11 @@ struct GTY((user)) modref_base_node
 
 struct modref_parm_map
 {
+  /* Default constructor.  */
+  modref_parm_map ()
+  : parm_index (MODREF_UNKNOWN_PARM), parm_offset_known (false), parm_offset ()
+  {}
+
   /* Index of parameter we translate to.
      Values from special_params enum are permitted too.  */
   int parm_index;
diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index 213343173c5..57e2aa5d868 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -5030,8 +5030,7 @@ ipa_merge_modref_summary_after_inlining (cgraph_edge *edge)
       auto_vec <modref_parm_map, 32> parm_map;
       modref_parm_map chain_map;
       /* TODO: Once we get jump functions for static chains we could
-	 compute this.  */
-      chain_map.parm_index = MODREF_UNKNOWN_PARM;
+	 compute parm_index.  */
 
       compute_parm_map (edge, &parm_map);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-19 11:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 11:33 [gcc r12-5399] Fix IPA modref ubsan Martin Liska

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).