Fix ubsan in gimple-fold.c (PR tree-optimization/82491).

2018-02-19  Martin Liska  <mliska@suse.cz>
	    Richard Sandiford  <richard.sandiford@linaro.org>

	PR tree-optimization/82491
	* gimple-fold.c (get_base_constructor): Make earlier bail out
	to prevent ubsan.

Co-Authored-By: Richard Sandiford <richard.sandiford@linaro.org>

From-SVN: r257816
This commit is contained in:
Martin Liska 2018-02-19 19:29:52 +01:00 committed by Martin Liska
parent a197d3406c
commit 6a5aca5327
2 changed files with 10 additions and 7 deletions

View file

@ -1,3 +1,10 @@
2018-02-19 Martin Liska <mliska@suse.cz>
Richard Sandiford <richard.sandiford@linaro.org>
PR tree-optimization/82491
* gimple-fold.c (get_base_constructor): Make earlier bail out
to prevent ubsan.
2018-02-19 Carl Love <cel@us.ibm.com>
* config/rs6000/rs6000-builtin.def: Change NEG macro expansions from

View file

@ -6442,13 +6442,9 @@ get_base_constructor (tree base, poly_int64_pod *bit_offset,
if (TREE_CODE (base) == MEM_REF)
{
if (!integer_zerop (TREE_OPERAND (base, 1)))
{
if (!tree_fits_shwi_p (TREE_OPERAND (base, 1)))
return NULL_TREE;
*bit_offset += (mem_ref_offset (base).force_shwi ()
* BITS_PER_UNIT);
}
poly_offset_int boff = *bit_offset + mem_ref_offset (base) * BITS_PER_UNIT;
if (!boff.to_shwi (bit_offset))
return NULL_TREE;
if (valueize
&& TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)