This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Throttle GCSE memory usage
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: Throttle GCSE memory usage
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Wed, 11 Apr 2001 11:09:19 -0700
- Organization: CodeSourcery, LLC
This patch fixes PR 884 by not running GCSE when doing so would take
huge amounts of memory. Without this patch, we tried to allocate
400MB of memory, and died on most ordinary systems.
Ideally, we would rework the algorithm to use less memory -- but we
would still need a throttle like this at some point.
Bootstrapped and tested on i686-pc-linux-gnu.
Installed on the mainline and the branch.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2001-04-11 Mark Mitchell <mark@codesourcery.com>
* Makefile.in (gcse.o): Depend on params.h.
* gcse.c: Include params.h.
(gcse_main): Don't do GCSE if doing so will take inordinate
amounts of memory.
* params.def (PARAM_MAX_GCSE_MEMORY): New parameter.
* params.h (MAX_GCSE_MEMORY): New macro.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.602.2.10
diff -c -p -r1.602.2.10 Makefile.in
*** Makefile.in 2001/03/28 19:51:08 1.602.2.10
--- Makefile.in 2001/04/11 17:34:25
*************** cse.o : cse.c $(CONFIG_H) system.h $(RTL
*** 1421,1427 ****
$(BASIC_BLOCK_H) $(GGC_H)
gcse.o : gcse.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) hard-reg-set.h \
flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) $(BASIC_BLOCK_H) \
! function.h output.h toplev.h
sibcall.o : sibcall.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) function.h \
hard-reg-set.h flags.h insn-config.h $(RECOG_H) $(BASIC_BLOCK_H)
resource.o : resource.c $(CONFIG_H) $(RTL_H) hard-reg-set.h system.h \
--- 1421,1427 ----
$(BASIC_BLOCK_H) $(GGC_H)
gcse.o : gcse.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) hard-reg-set.h \
flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) $(BASIC_BLOCK_H) \
! function.h output.h toplev.h params.h
sibcall.o : sibcall.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) function.h \
hard-reg-set.h flags.h insn-config.h $(RECOG_H) $(BASIC_BLOCK_H)
resource.o : resource.c $(CONFIG_H) $(RTL_H) hard-reg-set.h system.h \
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.113.4.1
diff -c -p -r1.113.4.1 gcse.c
*** gcse.c 2001/04/04 20:27:03 1.113.4.1
--- gcse.c 2001/04/11 17:34:26
*************** Boston, MA 02111-1307, USA. */
*** 159,164 ****
--- 159,165 ----
#include "output.h"
#include "function.h"
#include "expr.h"
+ #include "params.h"
#include "obstack.h"
#define obstack_chunk_alloc gmalloc
*************** gcse_main (f, file)
*** 689,694 ****
--- 690,708 ----
if (warn_disabled_optimization)
warning ("GCSE disabled: %d > 1000 basic blocks and %d >= 20 edges/basic block",
n_basic_blocks, n_edges / n_basic_blocks);
+ return 0;
+ }
+
+ /* If allocating memory for the cprop bitmap would take up too much
+ storage it's better just to disable the optimization. */
+ if ((n_basic_blocks
+ * SBITMAP_SET_SIZE (max_gcse_regno)
+ * sizeof (SBITMAP_ELT_TYPE)) > MAX_GCSE_MEMORY)
+ {
+ if (warn_disabled_optimization)
+ warning ("GCSE disabled: %d basic blocks and %d registers",
+ n_basic_blocks, max_gcse_regno);
+
return 0;
}
Index: params.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/params.def,v
retrieving revision 1.3.2.1
diff -c -p -r1.3.2.1 params.def
*** params.def 2001/03/01 16:56:20 1.3.2.1
--- params.def 2001/04/11 17:34:26
*************** DEFPARAM(PARAM_MAX_DELAY_SLOT_LIVE_SEARC
*** 66,71 ****
--- 66,78 ----
"The maximum number of instructions to consider to find accurate live register information",
333)
+ /* The GCSE optimization will be disabled if it would require
+ significantly more memory than this value. */
+ DEFPARAM(PARAM_MAX_GCSE_MEMORY,
+ "max-gcse-memory",
+ "The maximum amount of memory to be allocated by GCSE",
+ 50 * 1024 * 1024)
+
/*
Local variables:
mode:c
Index: params.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/params.h,v
retrieving revision 1.3.2.1
diff -c -p -r1.3.2.1 params.h
*** params.h 2001/03/01 16:56:20 1.3.2.1
--- params.h 2001/04/11 17:34:26
*************** typedef enum compiler_param
*** 88,92 ****
--- 88,94 ----
PARAM_VALUE (PARAM_MAX_DELAY_SLOT_INSN_SEARCH)
#define MAX_DELAY_SLOT_LIVE_SEARCH \
PARAM_VALUE (PARAM_MAX_DELAY_SLOT_LIVE_SEARCH)
+ #define MAX_GCSE_MEMORY \
+ ((size_t) PARAM_VALUE (PARAM_MAX_GCSE_MEMORY))
#endif /* PARAMS_H */