Re: [PATCH] Limit removal of UBSAN_NULL checks

2014-11-06 Thread Marek Polacek
On Thu, Nov 06, 2014 at 11:10:37AM +0100, Jakub Jelinek wrote: > Sorry for being slow on this, but in the current algorithm you are using > the latest vector element from each bb only anyway, so the > && tree_int_cst_compare (cur_align, align) == 0 > is unnecessary, even if the condition isn't true

Re: [PATCH] Limit removal of UBSAN_NULL checks

2014-11-06 Thread Jakub Jelinek
On Thu, Nov 06, 2014 at 10:56:17AM +0100, Marek Polacek wrote: > --- gcc/sanopt.c > +++ gcc/sanopt.c > @@ -130,7 +130,30 @@ sanopt_optimize_walker (basic_block bb, struct > sanopt_ctx *ctx) > /* At this point we shouldn't have any statements >tha

Re: [PATCH] Limit removal of UBSAN_NULL checks

2014-11-06 Thread Marek Polacek
On Wed, Nov 05, 2014 at 11:08:27PM +0100, Jakub Jelinek wrote: > I wonder if for the case where you don't remove, gimple_bb (g) == gimple_bb > (stmt) and tree_int_cst_compare (cur_align, align) == 0 it wouldn't be > worthwhile to v.pop (); so that the vector doesn't grow up unnecessarily too Good

Re: [PATCH] Limit removal of UBSAN_NULL checks

2014-11-05 Thread Jakub Jelinek
On Wed, Nov 05, 2014 at 10:37:46PM +0100, Marek Polacek wrote: > 2014-11-05 Marek Polacek > > * sanopt.c (sanopt_optimize_walker): Limit removal of the checks. > testsuite/ > * c-c++-common/ubsan/align-2.c: Add dg-output. > * c-c++-common/ubsan/align-4.c: Likewise. > * c

[PATCH] Limit removal of UBSAN_NULL checks

2014-11-05 Thread Marek Polacek
This patch limits optimizing UBSAN_NULL checks a bit, so that we don't lose diagnostics. If we know we're on a path where segv would have already occured, we can drop further checks (e.g. dereferencing a NULL pointer - we can't recover from that). Also if we're not recovering or using -fsanitize-u