Index: passes.c
===================================================================
--- passes.c	(revision 196182)
+++ passes.c	(working copy)
@@ -77,15 +77,68 @@ struct opt_pass *current_pass;
 
 static void register_pass_name (struct opt_pass *, const char *);
 
+typedef struct
+{
+  unsigned long size,resident,share,text,lib,data,dt;
+} statm_t;
+
+static void
+read_proc_memory_status (statm_t &result)
+{
+  const char* statm_path = "/proc/self/statm";
+
+  FILE *f = fopen(statm_path,"r");
+  if (!f)
+    {
+      perror (statm_path);
+      gcc_unreachable ();
+    }
+  if (7 != fscanf (f, "%lu %lu %lu %lu %lu %lu %lu",
+		   &result.size, &result.resident, &result.share,
+		   &result.text, &result.lib, &result.data,
+		   &result.dt))
+    {
+      perror (statm_path);
+      gcc_unreachable ();
+    }
+  fclose(f);
+}
+
 /* Call from anywhere to find out what pass this is.  Useful for
    printing out debugging information deep inside an service
    routine.  */
+
+#include "bitmap.h"
+#include "regset.h"
+
+static size_t
+obstack_memory_used2 (struct obstack *h)
+{
+  struct _obstack_chunk* lp;
+  size_t nbytes = 0;
+
+  for (lp = h->chunk; lp != 0; lp = lp->prev)
+    {
+      nbytes += (size_t) (lp->limit - (char *) lp);
+    }
+  return nbytes;
+}
+
 void
 print_current_pass (FILE *file)
 {
   if (current_pass)
-    fprintf (file, "current pass = %s (%d)\n",
-	     current_pass->name, current_pass->static_pass_number);
+    {
+      statm_t statm;
+      int pagesize = getpagesize ();
+      unsigned bos = obstack_memory_used2 (&bitmap_default_obstack.obstack);
+      unsigned ros = obstack_memory_used2 (&reg_obstack.obstack);
+      read_proc_memory_status (statm);
+      fprintf (file, "current pass = %32s (%3d) %12lu %12lu %12lu %12u %12u\n",
+	       current_pass->name, current_pass->static_pass_number,
+	       statm.size * pagesize, statm.resident * pagesize,
+	       statm.share * pagesize, bos, ros);
+    }
   else
     fprintf (file, "no current pass.\n");
 }
@@ -2286,7 +2339,7 @@ execute_one_pass (struct opt_pass *pass)
       current_pass = NULL;
       return false;
     }
-
+print_current_pass (stderr);
   /* Pass execution event trigger: useful to identify passes being
      executed.  */
   invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass);
