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]

[AVR][4.3, 4.2, 4.1] Disable deletete_null_pointer_checks for avr target


Hello.

Citing from the gcc info pages: 

`-fdelete-null-pointer-checks' 

Use global dataflow analysis to identify and eliminate useless checks for null
pointers. The compiler assumes that dereferencing a null pointer would have
halted the program. If a pointer is checked after it has already been
dereferenced, it cannot be null. 

In some environments, this assumption is not true, and programs can safely
dereference null pointers. Use `-fno-delete-null-pointer-checks' to disable
this optimization for programs which depend on that behavior. 

The AVR HW does not implement null-pointer-checks. Bjorn Haase suggested to
disable null-pointer-checks optimization in 'CC1_SPEC' and 'CC1PLUS_SPEC'
macros. This patch disable it in 'avr_override_options' function.

2007-03-30  Anatoly Sokolov <aesok@post.ru>

	* config/avr/avr.c (avr_override_options): Clear 
	'flag_delete_null_pointer_checks'.

Index: gcc/config/avr/avr.c
===================================================================
--- gcc/config/avr/avr.c	(revision 123340)
+++ gcc/config/avr/avr.c	(working copy)
@@ -316,6 +316,8 @@
   const struct mcu_type_s *t;
   const struct base_arch_s *base;
 
+  flag_delete_null_pointer_checks = 0;
+
   for (t = avr_mcu_types; t->name; t++)
     if (strcmp (t->name, avr_mcu_name) == 0)
       break;

Anatoly.


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