* PATCH: Throttle GCSE memory usage
@ 2001-04-11 11:09 Mark Mitchell
2001-04-11 12:44 ` Joseph S. Myers
0 siblings, 1 reply; 2+ messages in thread
From: Mark Mitchell @ 2001-04-11 11:09 UTC (permalink / raw)
To: gcc-patches
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 */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: Throttle GCSE memory usage
2001-04-11 11:09 PATCH: Throttle GCSE memory usage Mark Mitchell
@ 2001-04-11 12:44 ` Joseph S. Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph S. Myers @ 2001-04-11 12:44 UTC (permalink / raw)
To: Mark Mitchell; +Cc: gcc-patches
On Wed, 11 Apr 2001, Mark Mitchell wrote:
> * 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.
The new parameter should also go in the table of --param arguments in
invoke.texi.
--
Joseph S. Myers
jsm28@cam.ac.uk
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-04-11 12:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-11 11:09 PATCH: Throttle GCSE memory usage Mark Mitchell
2001-04-11 12:44 ` Joseph S. Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).