From 8ccaace8355c45a0b4602c2a666d4d5318fdc707 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 17 Dec 2016 20:10:39 +0100 Subject: [PATCH] re PR sanitizer/78832 (-fcompare-debug failure (length) with -fsanitize=address) PR sanitizer/78832 * sanopt.c (sanitize_asan_mark_unpoison): Remove next variable, use continue if gsi_next should be skipped. (sanitize_asan_mark_poison): Remove prev variable, use continue if gsi_prev should be skipped. When removing ASAN_MARK, do gsi_prev first and gsi_remove on a previously made copy of the iterator. * gcc.dg/asan/pr78832.c: New test. From-SVN: r243777 --- gcc/ChangeLog | 9 +++++++++ gcc/sanopt.c | 16 +++++++--------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/asan/pr78832.c | 22 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/asan/pr78832.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 388532e8916..5452c91df72 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2016-12-17 Jakub Jelinek + + PR sanitizer/78832 + * sanopt.c (sanitize_asan_mark_unpoison): Remove next variable, use + continue if gsi_next should be skipped. + (sanitize_asan_mark_poison): Remove prev variable, use continue if + gsi_prev should be skipped. When removing ASAN_MARK, do gsi_prev + first and gsi_remove on a previously made copy of the iterator. + 2016-12-17 Andrew Senkevich * config/i386/avx512bwintrin.h: Add new k-mask intrinsics. diff --git a/gcc/sanopt.c b/gcc/sanopt.c index 7fe8d32e39a..ae716cffcf4 100644 --- a/gcc/sanopt.c +++ b/gcc/sanopt.c @@ -740,7 +740,6 @@ sanitize_asan_mark_unpoison (void) gimple_stmt_iterator gsi; for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) { - bool next = true; gimple *stmt = gsi_stmt (gsi); if (gimple_call_internal_p (stmt, IFN_ASAN_MARK)) { @@ -753,12 +752,11 @@ sanitize_asan_mark_unpoison (void) unlink_stmt_vdef (stmt); release_defs (stmt); gsi_remove (&gsi, true); - next = false; + continue; } } - if (next) - gsi_next (&gsi); + gsi_next (&gsi); } } } @@ -840,7 +838,6 @@ sanitize_asan_mark_poison (void) gimple_stmt_iterator gsi; for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi);) { - bool prev = true; gimple *stmt = gsi_stmt (gsi); if (maybe_contains_asan_check (stmt)) break; @@ -850,12 +847,13 @@ sanitize_asan_mark_poison (void) fprintf (dump_file, "Removing ASAN_MARK poison\n"); unlink_stmt_vdef (stmt); release_defs (stmt); - gsi_remove (&gsi, true); - prev = false; + gimple_stmt_iterator gsi2 = gsi; + gsi_prev (&gsi); + gsi_remove (&gsi2, true); + continue; } - if (prev) - gsi_prev (&gsi); + gsi_prev (&gsi); } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index af27093c7db..8315852aee2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-17 Jakub Jelinek + + PR sanitizer/78832 + * gcc.dg/asan/pr78832.c: New test. + 2016-12-17 Andrew Senkevich * gcc.target/i386/avx512bw-kaddd-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/asan/pr78832.c b/gcc/testsuite/gcc.dg/asan/pr78832.c new file mode 100644 index 00000000000..deed8f17da6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr78832.c @@ -0,0 +1,22 @@ +/* PR sanitizer/78832 */ +/* { dg-do compile } */ +/* { dg-additional-options "-fcompare-debug" } */ + +void bar (int *); + +int +foo (int x) +{ + int *f = 0; + if (x) + goto lab; + { + int y, z; + bar (&y); + int *d = &y; + bar (&z); + int *e = &z; + } + f = &x; + lab: return 6; +} -- 2.30.2