This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Support -fsanitize=integer-arith-overflow even for vectors (PR sanitizer/77823)


On 11/15/2016 07:03 AM, Jakub Jelinek wrote:
Hi!

On Mon, Nov 14, 2016 at 10:58:51AM +0100, Jakub Jelinek wrote:
Working virtually out of Samoa.

The following patch is an attempt to handle -fsanitize=undefined
for vectors.  We already diagnose out of bounds accesses for vector
subscripts, this patch adds expansion for vector UBSAN_CHECK_* and generates
those in ubsan.  Haven't finished up the many vect elements handling (want
to emit a loop for code size).  Is this something we want for GCC 7?

Here is the full patch (just for -fsanitize=signed-integer-overflow, not
for -fsanitize=shift or -fsanitize={integer,float}-divide-by-zero for now).

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-11-15  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/77823
	* ubsan.c (ubsan_build_overflow_builtin): Add DATAP argument, if
	it points to non-NULL tree, use it instead of ubsan_create_data.
	(instrument_si_overflow): Handle vector signed integer overflow
	checking.
	* ubsan.h (ubsan_build_overflow_builtin): Add DATAP argument.
	* tree-vrp.c (simplify_internal_call_using_ranges): Punt for
	vector IFN_UBSAN_CHECK_*.
	* internal-fn.c (expand_addsub_overflow): Add DATAP argument,
	pass it through to ubsan_build_overflow_builtin.
	(expand_neg_overflow, expand_mul_overflow): Likewise.
	(expand_vector_ubsan_overflow): New function.
	(expand_UBSAN_CHECK_ADD, expand_UBSAN_CHECK_SUB,
	expand_UBSAN_CHECK_MUL): Use tit for vector arithmetics.
	(expand_arith_overflow): Adjust expand_*_overflow callers.

	* c-c++-common/ubsan/overflow-vec-1.c: New test.
	* c-c++-common/ubsan/overflow-vec-2.c: New test.
I certainly don't see any reason why we wouldn't want additional sanitizers, so ISTM it's really a matter of are you happy with the implementation.

While there's a fair amount of changes in internal-fn.c, they're all sanitizer specific routines AFAICT.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]