-fconserve-stack

Jan Hubicka jh@suse.cz
Mon Sep 10 00:31:00 GMT 2007


Hi,
Andi asked me for an command line option to instruct GCC avoiding
increasing stack frame.  At the moemnt only inliner knows how to trottle
down stack frame usage so this option basically sets the inliner
parameters, but in future we might invent more usage for this and it is
better than forcing kernel using magic --param values.

Bootstrapped x86_64-linux, routing full testing on i686-linux in
progress, OK?
Honza

	* invoke.texi (-fconserve-stack): Document.
	* opts.c (decode_options): Handle conserve_stack.
	* common.opt (fconvserve_stack): New.
Index: doc/invoke.texi
===================================================================
*** doc/invoke.texi	(revision 128301)
--- doc/invoke.texi	(working copy)
*************** Objective-C and Objective-C++ Dialects}.
*** 320,326 ****
  -fbounds-check -fmudflap -fmudflapth -fmudflapir @gol
  -fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize @gol
  -fbranch-target-load-optimize2 -fbtr-bb-exclusive @gol
! -fcaller-saves  -fcprop-registers  -fcse-follow-jumps @gol
  -fcse-skip-blocks  -fcx-limited-range  -fdata-sections @gol
  -fdelayed-branch  -fdelete-null-pointer-checks -fearly-inlining @gol
  -fexpensive-optimizations  -ffast-math  -ffloat-store @gol
--- 320,326 ----
  -fbounds-check -fmudflap -fmudflapth -fmudflapir @gol
  -fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize @gol
  -fbranch-target-load-optimize2 -fbtr-bb-exclusive @gol
! -fcaller-saves -fconserve-stack -fcprop-registers  -fcse-follow-jumps @gol
  -fcse-skip-blocks  -fcx-limited-range  -fdata-sections @gol
  -fdelayed-branch  -fdelete-null-pointer-checks -fearly-inlining @gol
  -fexpensive-optimizations  -ffast-math  -ffloat-store @gol
*************** those which have no call-preserved regis
*** 5640,5645 ****
--- 5640,5652 ----
  
  Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  
+ @item -fconserve-stack
+ @opindex fconserve-stack
+ Disable optimizations noticeably increasing stack usage.  This is useful for
+ stack restricted environments, like kernels.  Currently the option imply
+ setting @option{large-stack-frame} to 16 and @option{large-stack-fram-growth}
+ to 200.
+ 
  @item -ftree-reassoc
  Perform Reassociation on trees  This flag is enabled by default
  at @option{-O} and higher.
Index: opts.c
===================================================================
*** opts.c	(revision 128301)
--- opts.c	(working copy)
*************** decode_options (unsigned int argc, const
*** 989,994 ****
--- 989,1002 ----
        flag_reorder_blocks_and_partition = 0;
        flag_reorder_blocks = 1;
      }
+   if (flag_conserve_stack)
+     {
+       if (!PARAM_SET_P (PARAM_LARGE_STACK_FRAME))
+         PARAM_VALUE (PARAM_LARGE_STACK_FRAME) = 16;
+       if (!PARAM_SET_P (PARAM_STACK_FRAME_GROWTH))
+         PARAM_VALUE (PARAM_STACK_FRAME_GROWTH) = 200;
+     }
+ 
  }
  
  #define LEFT_COLUMN	27
Index: common.opt
===================================================================
*** common.opt	(revision 128301)
--- common.opt	(working copy)
*************** fcommon
*** 369,374 ****
--- 369,378 ----
  Common Report Var(flag_no_common,0) Optimization
  Do not put uninitialized globals in the common section
  
+ fconserve-stack
+ Common Var(flag_conserve_stack,0) Optimization
+ Do not perform optimizations increasing noticeably stack usage
+ 
  fcprop-registers
  Common Report Var(flag_cprop_registers) Optimization
  Perform a register copy-propagation optimization pass



More information about the Gcc-patches mailing list