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]

[patch,avr,committed] Move disable of -fno-delete-null-pointer-checks to common.


Applied the following patch that moves disabling of -fno-disable-null-pointer-checks to a different place so that it can be overwritten on the command-line (as opposed to TARGET_OVERRIDE_OPTIONS). This allows some more test cases to pass that set -fdisable-null-pointer-checks.

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.

gcc/testsuite/
	* gcc.dg/tree-ssa/vrp111.c (dg-options): Add
	-fdelete-null-pointer-checks.


Johann
Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(revision 257298)
+++ config/avr/avr.c	(working copy)
@@ -730,14 +730,6 @@ && mcu->macro == NULL)
 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.
Index: common/config/avr/avr-common.c
===================================================================
--- common/config/avr/avr-common.c	(revision 257298)
+++ common/config/avr/avr-common.c	(working copy)
@@ -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 },
Index: testsuite/gcc.dg/tree-ssa/vrp111.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/vrp111.c	(revision 257298)
+++ testsuite/gcc.dg/tree-ssa/vrp111.c	(working copy)
@@ -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)));
 

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