Commit 0186d373 by Richard Sandiford Committed by Richard Sandiford

Fix unchecked use of tree_to_uhwi in tree-ssa-strlen.c

r273783 introduced an unchecked use of tree_to_uhwi.  This is
tested by the SVE ACLE patches, but could potentially trigger
in non-SVE cases too.

2019-10-15  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-ssa-strlen.c (count_nonzero_bytes): Check tree_fits_uhwi_p
	before using tree_to_uhwi.

From-SVN: r276990
parent 0d552c1b
2019-10-15 Richard Sandiford <richard.sandiford@arm.com>
* tree-ssa-strlen.c (count_nonzero_bytes): Check tree_fits_uhwi_p
before using tree_to_uhwi.
2019-10-15 Ilya Leoshkevich <iii@linux.ibm.com> 2019-10-15 Ilya Leoshkevich <iii@linux.ibm.com>
* config/s390/s390.md: Run %a0:DI splitters only after reload. * config/s390/s390.md: Run %a0:DI splitters only after reload.
......
...@@ -4026,10 +4026,10 @@ count_nonzero_bytes (tree exp, unsigned HOST_WIDE_INT offset, ...@@ -4026,10 +4026,10 @@ count_nonzero_bytes (tree exp, unsigned HOST_WIDE_INT offset,
/* The size of the MEM_REF access determines the number of bytes. */ /* The size of the MEM_REF access determines the number of bytes. */
tree type = TREE_TYPE (exp); tree type = TREE_TYPE (exp);
if (tree typesize = TYPE_SIZE_UNIT (type)) tree typesize = TYPE_SIZE_UNIT (type);
nbytes = tree_to_uhwi (typesize); if (!typesize || !tree_fits_uhwi_p (typesize))
else
return false; return false;
nbytes = tree_to_uhwi (typesize);
/* Handle MEM_REF = SSA_NAME types of assignments. */ /* Handle MEM_REF = SSA_NAME types of assignments. */
return count_nonzero_bytes (arg, offset, nbytes, lenrange, nulterm, return count_nonzero_bytes (arg, offset, nbytes, lenrange, nulterm,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment