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.
This commit is contained in:
Martin Liska 2021-11-18 13:14:25 +01:00
parent dd85c42c36
commit 74a4ece02d
2 changed files with 6 additions and 2 deletions

View File

@ -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;

View File

@ -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);