aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2025-08-01 15:07:15 +0200
committerRichard Biener <rguenther@suse.de>2025-08-03 09:25:46 +0200
commit7c99de1c439dbb149cc6a33a214f22f2df1c88f3 (patch)
tree0759376a526e736b011704274d3df61049d4e041 /gcc
parent94edbc153ae4f1c1532859836e528fc480da82d6 (diff)
downloadgcc-7c99de1c439dbb149cc6a33a214f22f2df1c88f3.zip
gcc-7c99de1c439dbb149cc6a33a214f22f2df1c88f3.tar.gz
gcc-7c99de1c439dbb149cc6a33a214f22f2df1c88f3.tar.bz2
tree-optimization/90242 - UBSAN error in vn_reference_compute_hash
The following plugs possible overflow issues in vn_reference_compute_hash and possibly in vn_reference_eq. The inchash "integer" adds are a bit of a mess, but I know overloads with different integer types can get messy, so not this time. For hashing simply truncate to 64bits. PR tree-optimization/90242 * tree-ssa-sccvn.cc (vn_reference_compute_hash): Use poly_offset_int for offset accumulation. For hashing truncate to 64 bits and also hash 64 bits. (vn_reference_eq): Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-ssa-sccvn.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index a3117da..3974c4d 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -717,7 +717,7 @@ vn_reference_compute_hash (const vn_reference_t vr1)
hashval_t result;
int i;
vn_reference_op_t vro;
- poly_int64 off = -1;
+ poly_offset_int off = -1;
bool deref = false;
FOR_EACH_VEC_ELT (vr1->operands, i, vro)
@@ -736,7 +736,7 @@ vn_reference_compute_hash (const vn_reference_t vr1)
{
if (maybe_ne (off, -1)
&& maybe_ne (off, 0))
- hstate.add_poly_int (off);
+ hstate.add_poly_hwi (off.force_shwi ());
off = -1;
if (deref
&& vro->opcode == ADDR_EXPR)
@@ -850,7 +850,7 @@ vn_reference_eq (const_vn_reference_t const vr1, const_vn_reference_t const vr2)
j = 0;
do
{
- poly_int64 off1 = 0, off2 = 0;
+ poly_offset_int off1 = 0, off2 = 0;
vn_reference_op_t vro1, vro2;
vn_reference_op_s tem1, tem2;
bool deref1 = false, deref2 = false;