memory explosion during gcse

Zack Weinberg zack@bitmover.com
Mon Sep 6 23:39:00 GMT 1999


Franz Sirl wrote:
> 
> Hi,
> 
> with the current mainline and --enable-checking on Linux/PPC gcc
> uses excessive memory during gcse (actually in pre_lcm) while
> compiling insn-extract.c. After adding another swapfile I saw that
> the memory usage topped out at 395MB!

Could you please try this patch?  I suspect it will make things worse,
but there's a chance it will help.  And it might also break things
horribly.

zw

1999-09-06 23:19 -0700  Zack Weinberg  <zack@bitmover.com>

	* rtl.h [ENABLE_CHECKING defined] (RTL_CHECK1, RTL_CHECK2,
	RTL_CHECKC1, RTL_CHECKC2, RTVEC_ELT): Use inline helper
	functions, not statement expressions.

===================================================================
Index: rtl.h
--- rtl.h	1999/09/04 18:25:41	1.130
+++ rtl.h	1999/09/07 06:18:11
@@ -230,52 +230,6 @@ typedef struct rtvec_def{
 /* General accessor macros for accessing the fields of an rtx.  */
 
 #if defined ENABLE_CHECKING  && (__GNUC__ > 2 || __GNUC_MINOR__ > 6)
-/* The bit with a star outside the statement expr and an & inside is
-   so that N can be evaluated only once.  */
-#define RTL_CHECK1(RTX, N, C1)						\
-(*({ rtx _rtx = (RTX); int _n = (N);					\
-     enum rtx_code _code = GET_CODE (_rtx);				\
-     if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
-       rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,		\
-				__PRETTY_FUNCTION__);			\
-     if (GET_RTX_FORMAT(_code)[_n] != C1)				\
-       rtl_check_failed_type1 (_rtx, _n, C1, __FILE__, __LINE__,	\
-			       __PRETTY_FUNCTION__);			\
-     &_rtx->fld[_n]; }))
-
-#define RTL_CHECK2(RTX, N, C1, C2)					\
-(*({ rtx _rtx = (RTX); int _n = (N);					\
-     enum rtx_code _code = GET_CODE (_rtx);				\
-     if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
-       rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,		\
-				__PRETTY_FUNCTION__);			\
-     if (GET_RTX_FORMAT(_code)[_n] != C1				\
-	 && GET_RTX_FORMAT(_code)[_n] != C2)				\
-       rtl_check_failed_type2 (_rtx, _n, C1, C2, __FILE__, __LINE__,	\
-			       __PRETTY_FUNCTION__);			\
-     &_rtx->fld[_n]; }))
-
-#define RTL_CHECKC1(RTX, N, C)						\
-(*({ rtx _rtx = (RTX); int _n = (N);					\
-     if (GET_CODE (_rtx) != C)						\
-       rtl_check_failed_code1 (_rtx, C, __FILE__, __LINE__,		\
-			       __PRETTY_FUNCTION__);			\
-     &_rtx->fld[_n]; }))
-
-#define RTL_CHECKC2(RTX, N, C1, C2)					\
-(*({ rtx _rtx = (RTX); int _n = (N);					\
-     enum rtx_code _code = GET_CODE (_rtx);				\
-     if (_code != C1 && _code != C2)					\
-       rtl_check_failed_code2 (_rtx, C1, C2, __FILE__, __LINE__,	\
-			       __PRETTY_FUNCTION__);			\
-     &_rtx->fld[_n]; }))
-
-#define RTVEC_ELT(RTVEC, I)						\
-(*({ rtvec _rtvec = (RTVEC); int _i = (I);				\
-     if (_i < 0 || _i >= GET_NUM_ELEM (_rtvec))				\
-       rtvec_check_failed_bounds (_rtvec, _i, __FILE__, __LINE__,	\
-				  __PRETTY_FUNCTION__);			\
-     &_rtvec->elem[_i]; }))
 
 extern void rtl_check_failed_bounds PROTO((rtx, int,
 					   const char *, int, const char *))
@@ -295,6 +249,93 @@ extern void rtl_check_failed_code2 PROTO
 extern void rtvec_check_failed_bounds PROTO((rtvec, int,
 					     const char *, int, const char *))
     ATTRIBUTE_NORETURN;
+
+
+static inline rtunion *
+rtl_check1 (_rtx, _n, _c1, _fi, _li, _fu)
+     rtx _rtx;
+     int _n, _c1;
+     const char *_fi;
+     int _li;
+     const char *_fu;
+{
+  enum rtx_code _code = GET_CODE (_rtx);
+  if (_n < 0 || _n >= GET_RTX_LENGTH (_code))
+    rtl_check_failed_bounds (_rtx, _n, _fi, _li, _fu);
+  if (GET_RTX_FORMAT(_code)[_n] != _c1)
+    rtl_check_failed_type1 (_rtx, _n, _c1, _fi, _li, _fu);
+  return &_rtx->fld[_n];
+}
+
+static inline rtunion *
+rtl_check2 (_rtx, _n, _c1, _c2, _fi, _li, _fu)
+     rtx _rtx;
+     int _n, _c1, _c2;
+     const char *_fi;
+     int _li;
+     const char *_fu;
+{
+  enum rtx_code _code = GET_CODE (_rtx);
+  if (_n < 0 || _n >= GET_RTX_LENGTH (_code))
+    rtl_check_failed_bounds (_rtx, _n, _fi, _li, _fu);
+  if (GET_RTX_FORMAT(_code)[_n] != _c1
+      && GET_RTX_FORMAT(_code)[_n] != _c2)
+    rtl_check_failed_type2 (_rtx, _n, _c1, _c2, _fi, _li, _fu);
+  return &_rtx->fld[_n];
+}
+
+static inline rtunion *
+rtl_checkc1 (_rtx, _n, _c1, _fi, _li, _fu)
+     rtx _rtx;
+     int _n;
+     enum rtx_code _c1;
+     const char *_fi;
+     int _li;
+     const char *_fu;
+{
+  if (GET_CODE(_rtx) != _c1)
+    rtl_check_failed_code1 (_rtx, _c1, _fi, _li, _fu);
+  return &_rtx->fld[_n];
+}
+
+static inline rtunion *
+rtl_checkc2 (_rtx, _n, _c1, _c2, _fi, _li, _fu)
+     rtx _rtx;
+     int _n;
+     enum rtx_code _c1, _c2;
+     const char *_fi;
+     int _li;
+     const char *_fu;
+{
+  enum rtx_code _code = GET_CODE (_rtx);
+  if (_code != _c1 && _code != _c2)
+    rtl_check_failed_code2 (_rtx, _c1, _c2, _fi, _li, _fu);
+  return &_rtx->fld[_n];
+}
+
+static inline rtx *
+rtvec_elt (_rtvec, _i, _fi, _li, _fu)
+     rtvec _rtvec;
+     int _i;
+     const char *_fi;
+     int _li;
+     const char *_fu;
+{
+  if (_i < 0 || _i >= GET_NUM_ELEM (_rtvec))
+       rtvec_check_failed_bounds (_rtvec, _i, _fi, _li, _fu);
+  return &_rtvec->elem[_i];
+}
+
+#define RTL_CHECK1(RTX, N, C1) \
+  (*rtl_check1 (RTX, N, C1, __FILE__, __LINE__, __PRETTY_FUNCTION__))
+#define RTL_CHECK2(RTX, N, C1, C2) \
+  (*rtl_check2 (RTX, N, C1, C2,  __FILE__, __LINE__, __PRETTY_FUNCTION__))
+#define RTL_CHECKC1(RTX, N, C1) \
+  (*rtl_checkc1 (RTX, N, C1, __FILE__, __LINE__, __PRETTY_FUNCTION__))
+#define RTL_CHECKC2(RTX, N, C1, C2) \
+  (*rtl_checkc2 (RTX, N, C1, C2, __FILE__, __LINE__, __PRETTY_FUNCTION__))
+#define RTVEC_ELT(RTVEC, I) \
+  (*rtvec_elt (RTVEC, I, __FILE__, __LINE__, __PRETTY_FUNCTION__))
 
 #else   /* not ENABLE_CHECKING */
 


More information about the Gcc-bugs mailing list