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]

-fdelete-null-pointer-checks




This patch adds an option to allow users to enable/disable null pointer
check elimination.

	* invoke.texi: Document -fdelete-null-pointer-checks
	* toplev.c (flag_delete_null_pointer_checks): New.
	(f_options): Add entry for -fdelete-null-pointer-checks.
	(rest_of_compilation): Conditionalize null pointer check
	elimination on flag_delete_null_pointer_checks.
	(main): If -O2 or greater, enable -fdelete-null-pointer-checks
	
	
Index: invoke.texi
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/invoke.texi,v
retrieving revision 1.139
diff -c -3 -p -r1.139 invoke.texi
*** invoke.texi	1999/09/20 20:24:42	1.139
--- invoke.texi	1999/09/23 19:51:20
*************** in the following sections.
*** 153,159 ****
  -falign-functions=@var{n}  -falign-labels=@var{n}  -falign-loops=@var{n} 
  -falign-jumps=@var{n}  -fbranch-probabilities  
  -fcaller-saves  -fcse-follow-jumps  -fcse-skip-blocks
! -fdelayed-branch   -fexpensive-optimizations
  -ffast-math  -ffloat-store  -fforce-addr  -fforce-mem -fno-math-errno
  -fdata-sections  -ffunction-sections  -fgcse 
  -finline-functions  -finline-limit=@var{n}  -fkeep-inline-functions
--- 153,159 ----
  -falign-functions=@var{n}  -falign-labels=@var{n}  -falign-loops=@var{n} 
  -falign-jumps=@var{n}  -fbranch-probabilities  
  -fcaller-saves  -fcse-follow-jumps  -fcse-skip-blocks
! -fdelayed-branch  -fdelete-null-pointer-checks -fexpensive-optimizations
  -ffast-math  -ffloat-store  -fforce-addr  -fforce-mem -fno-math-errno
  -fdata-sections  -ffunction-sections  -fgcse 
  -finline-functions  -finline-limit=@var{n}  -fkeep-inline-functions
*************** Run the loop optimizer twice.
*** 2458,2463 ****
--- 2458,2471 ----
  @item -fgcse
  Perform a global common subexpression elimination pass.
  This pass also performs global constant and copy propagation.
+ 
+ @item -fdelete-null-pointer-checks
+ Use global dataflow analysis to identify and eliminate useless null
+ pointer checks.  Programs which rely on NULL pointer dereferences @emph{not}
+ halting the program may not work properly with this option.  Use
+ -fno-delete-null-pointer-checks to disable this optimizing for programs
+ which depend on that behavior.
+ 
  
  @item -fexpensive-optimizations
  Perform a number of minor optimizations that are relatively expensive.
Index: toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.228
diff -c -3 -p -r1.228 toplev.c
*** toplev.c	1999/09/22 00:35:28	1.228
--- toplev.c	1999/09/23 19:51:27
*************** int flag_syntax_only = 0;
*** 568,573 ****
--- 568,578 ----
  
  static int flag_gcse;
  
+ /* Nonzero means to use global dataflow analysis to eliminate
+    useless null pointer tests.  */
+ 
+ static int flag_delete_null_pointer_checks;
+ 
  /* Nonzero means to rerun cse after loop optimization.  This increases
     compilation time about 20% and picks up a few more common expressions.  */
  
*************** lang_independent_options f_options[] =
*** 894,899 ****
--- 899,906 ----
     "Run CSE pass after loop optimisations"},
    {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
     "Run the loop optimiser twice"},
+   {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
+    "Delete useless null pointer checks" },
    {"pretend-float", &flag_pretend_float, 1,
     "Pretend that host and target use the same FP format"},
    {"schedule-insns", &flag_schedule_insns, 1,
*************** rest_of_compilation (decl)
*** 3707,3713 ****
      goto exit_rest_of_compilation;
  
    /* Try to identify useless null pointer tests and delete them.  */
!   if (optimize > 1)
      TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
  
    /* Dump rtl code after jump, if we are doing that.  */
--- 3714,3720 ----
      goto exit_rest_of_compilation;
  
    /* Try to identify useless null pointer tests and delete them.  */
!   if (flag_delete_null_pointer_checks)
      TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
  
    /* Dump rtl code after jump, if we are doing that.  */
*************** rest_of_compilation (decl)
*** 3746,3752 ****
  					   !JUMP_AFTER_REGSCAN));
   
        /* Try to identify useless null pointer tests and delete them.  */
!       if (optimize > 1)
  	TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
  
        /* Dump rtl code after cse, if we are doing that.  */
--- 3753,3759 ----
  					   !JUMP_AFTER_REGSCAN));
   
        /* Try to identify useless null pointer tests and delete them.  */
!       if (flag_delete_null_pointer_checks)
  	TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
  
        /* Dump rtl code after cse, if we are doing that.  */
*************** main (argc, argv)
*** 5322,5327 ****
--- 5329,5335 ----
  #endif
        flag_regmove = 1;
        flag_strict_aliasing = 1;
+       flag_delete_null_pointer_checks = 1;
      }
  
    if (optimize >= 3)





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