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

Anatoly Sokolov aesok@post.ru
Thu Mar 29 22:06:00 GMT 2007


Citing from the gcc info pages: 


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 

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)


More information about the Gcc-patches mailing list