From 19416210b37db0584cd0b3f3b3961324b8973d25 Mon Sep 17 00:00:00 2001 From: Georg-Johann Lay Date: Thu, 1 Feb 2018 15:54:20 +0000 Subject: [PATCH] avr.c (avr_option_override): Move disabling of -fdelete-null-pointer-checks to... gcc/ * config/avr/avr.c (avr_option_override): Move disabling of -fdelete-null-pointer-checks to... * common/config/avr/avr-common.c (avr_option_optimization_table): ...here. testsuite/ * gcc.dg/tree-ssa/vrp111.c (dg-options): Add -fdelete-null-pointer-checks. From-SVN: r257301 --- gcc/ChangeLog | 7 +++++++ gcc/common/config/avr/avr-common.c | 6 ++++++ gcc/config/avr/avr.c | 8 -------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/vrp111.c | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e62b93d9a38..4dcc3644f36 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-02-01 Georg-Johann Lay + + * config/avr/avr.c (avr_option_override): Move disabling of + -fdelete-null-pointer-checks to... + * common/config/avr/avr-common.c (avr_option_optimization_table): + ...here. + 2018-02-01 Richard Sandiford PR tree-optimization/81635 diff --git a/gcc/common/config/avr/avr-common.c b/gcc/common/config/avr/avr-common.c index 078584d53c3..d6293b1192e 100644 --- a/gcc/common/config/avr/avr-common.c +++ b/gcc/common/config/avr/avr-common.c @@ -27,6 +27,12 @@ /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */ static const struct default_options avr_option_optimization_table[] = { + // With -fdelete-null-pointer-checks option, the compiler assumes + // that dereferencing of a null pointer would halt the program. + // For AVR this assumption is not true and a program can safely + // dereference null pointers. Changes made by this option may not + // work properly for AVR. So disable this option. + { OPT_LEVELS_ALL, OPT_fdelete_null_pointer_checks, NULL, 0 }, // The only effect of -fcaller-saves might be that it triggers // a frame without need when it tries to be smart around calls. { OPT_LEVELS_ALL, OPT_fcaller_saves, NULL, 0 }, diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index ad155125741..81c35e7fbc2 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -730,14 +730,6 @@ avr_set_core_architecture (void) static void avr_option_override (void) { - /* Disable -fdelete-null-pointer-checks option for AVR target. - This option compiler assumes that dereferencing of a null pointer - would halt the program. For AVR this assumption is not true and - programs can safely dereference null pointers. Changes made by this - option may not work properly for AVR. So disable this option. */ - - flag_delete_null_pointer_checks = 0; - /* caller-save.c looks for call-clobbered hard registers that are assigned to pseudos that cross calls and tries so save-restore them around calls in order to reduce the number of stack slots needed. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 465ae15296a..da557b80629 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-01 Georg-Johann Lay + + * gcc.dg/tree-ssa/vrp111.c (dg-options): Add + -fdelete-null-pointer-checks. + 2018-02-01 Paolo Carlini PR c++/83796 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp111.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp111.c index 2511c1964bb..631442358be 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp111.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp111.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-evrp" } */ +/* { dg-options "-O2 -fdump-tree-evrp -fdelete-null-pointer-checks" } */ void foo (void *p) __attribute__((nonnull(1))); -- 2.30.2