This is the mail archive of the gcc@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]
Other format: [Raw text]

[DEBUG] RTX allocation debugging


Often when doing things like what Jeff and I are up to (looking for
wasteful RTL allocations and whatnot) it helps to be able to set
breakpoints on every RTL allocation.  Since ggc_alloc_rtx is a macro
that isn't so easy (unless you enjoy setting a LOT of breakpoints at
the callsites :-)

So this is a useful debugging patch I frequently stick into my tree so
that these macros are real function you can set breakpoints on and
then proceed to look at the backtrace.

Maybe we can conditionalize this with some flag so that it could be
put into the repository yet not cause all the added overhead unless
the developer explicitly tells configure he wants this.

--- ./ggc-common.c.~1~	Tue Jun  4 14:06:28 2002
+++ ./ggc-common.c	Thu Jun 13 02:09:54 2002
@@ -304,6 +304,30 @@ ggc_calloc (s1, s2)
   return ggc_alloc_cleared (s1 * s2);
 }
 
+struct rtx_def *
+ggc_alloc_rtx (nslots)
+     size_t nslots;
+{
+  size_t len;
+
+  len = sizeof (struct rtx_def);
+  len += ((nslots - 1) * sizeof (rtunion));
+
+  return (struct rtx_def *) ggc_alloc (len);
+}
+
+struct rtvec_def *
+ggc_alloc_rtvec (nelt)
+     size_t nelt;
+{
+  size_t len;
+
+  len = sizeof (struct rtvec_def);
+  len += ((nelt - 1) * sizeof (rtx));
+
+  return (struct rtvec_def *) ggc_alloc (len);
+}
+
 /* Print statistics that are independent of the collector in use.  */
 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
 		  ? (x) \
--- ./ggc.h.~1~	Tue Jun  4 14:06:29 2002
+++ ./ggc.h	Thu Jun 13 02:13:20 2002
@@ -109,13 +109,8 @@ extern void *ggc_realloc	PARAMS ((void *
 /* Like ggc_alloc_cleared, but performs a multiplication.  */
 extern void *ggc_calloc		PARAMS ((size_t, size_t));
 
-#define ggc_alloc_rtx(NSLOTS)						  \
-  ((struct rtx_def *) ggc_alloc (sizeof (struct rtx_def)		  \
-				 + ((NSLOTS) - 1) * sizeof (rtunion)))
-
-#define ggc_alloc_rtvec(NELT)						  \
-  ((struct rtvec_def *) ggc_alloc (sizeof (struct rtvec_def)		  \
-				   + ((NELT) - 1) * sizeof (rtx)))
+extern struct rtx_def *ggc_alloc_rtx PARAMS ((size_t));
+extern struct rtvec_def *ggc_alloc_rtvec PARAMS ((size_t));
 
 #define ggc_alloc_tree(LENGTH) ((union tree_node *) ggc_alloc (LENGTH))
 
--- ./ggc-none.c.~1~	Tue Jun  4 14:06:28 2002
+++ ./ggc-none.c	Thu Jun 13 02:13:35 2002
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "system.h"
 #include "ggc.h"
+#include "rtl.h"
 
 void *
 ggc_alloc (size)
@@ -46,4 +47,28 @@ ggc_realloc (x, size)
      size_t size;
 {
   return xrealloc (x, size);
+}
+
+struct rtx_def *
+ggc_alloc_rtx (nslots)
+     size_t nslots;
+{
+  size_t len;
+
+  len = sizeof (struct rtx_def);
+  len += ((nslots - 1) * sizeof (rtunion));
+
+  return (struct rtx_def *) ggc_alloc (len);
+}
+
+struct rtvec_def *
+ggc_alloc_rtvec (nelt)
+     size_t nelt;
+{
+  size_t len;
+
+  len = sizeof (struct rtvec_def);
+  len += ((nelt - 1) * sizeof (rtx));
+
+  return (struct rtvec_def *) ggc_alloc (len);
 }


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