aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-03-04 12:46:31 +0100
committerJakub Jelinek <jakub@redhat.com>2020-03-04 12:47:42 +0100
commit1cdfb80a4ec7b6585b436917e13b205055732232 (patch)
treec1f82425e5596304ab6873d9cfa941ec1c290a15 /gcc/tree-inline.c
parentdca54007ebb5d49c3d6cea63ee87fd8f3ccb9ca5 (diff)
downloadgcc-1cdfb80a4ec7b6585b436917e13b205055732232.zip
gcc-1cdfb80a4ec7b6585b436917e13b205055732232.tar.gz
gcc-1cdfb80a4ec7b6585b436917e13b205055732232.tar.bz2
sccvn: Avoid overflows in push_partial_def
The following patch attempts to avoid dangerous overflows in the various push_partial_def HOST_WIDE_INT computations. This is achieved by performing the subtraction offset2i - offseti in the push_partial_def function and before doing that doing some tweaks. If a constant store (non-CONSTRUCTOR) is too large (perhaps just hypothetical case), native_encode_expr would fail for it, but we don't necessarily need to fail right away, instead we can treat it like non-constant store and if it is already shadowed, we can ignore it. Otherwise, if it at most 64-byte and the caller ensured that there is a range overlap and push_partial_def ensures the load is at most 64-byte, I think we should be fine, offset (relative to the load) can be from -64*8+1 to 64*8-1 only and size at most 64*8, so no risks of overflowing HOST_WIDE_INT computations. For CONSTRUCTOR (or non-constant) stores, those can be indeed arbitrarily large, the caller just checks that both the absolute offset and size fit into signed HWI. But, we store the same bytes in that case over and over (both in the {} case where it is all 0, and in the hypothetical future case where we handle in push_partial_def also memset (, 123, )), so we can tweak the write range for our purposes. For {} store we could just cap it at the start offset and/or offset+size because all the bits are 0, but I wrote it in anticipation of the memset case and so the relative offset can now be down to -7 and similarly size can grow up to 64 bytes + 14 bits, all this trying to preserve the offset difference % BITS_PER_UNIT or end as well. 2020-03-04 Jakub Jelinek <jakub@redhat.com> * tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): Add offseti argument. Change pd argument so that it can be modified. Turn constant non-CONSTRUCTOR store into non-constant if it is too large. Adjust offset and size of CONSTRUCTOR or non-constant store to avoid overflows. (vn_walk_cb_data::vn_walk_cb_data, vn_reference_lookup_3): Adjust callers.
Diffstat (limited to 'gcc/tree-inline.c')
0 files changed, 0 insertions, 0 deletions