This is the mail archive of the gcc-patches@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]

Re: [gfortran] patch for pr 21130 - 38822 lines of Fortran 90 takes more than 10 minutes to compile on a dual 3GHz P4 Linux box with lots of RAM


Bud,

changelog and patch attached.



OK for trunk and 4.1.

That's brilliant! I can only say that I am a bit ashamed of the time that I spent looking at that bit of code without realising that there is such a time penalty involved. I have just a couple of minor points on the patch.

Thanks

Paul

------------------------------------------------------------------------

Index: gcc/gcc/fortran/module.c
===================================================================
--- gcc/gcc/fortran/module.c	(revision 112482)
+++ gcc/gcc/fortran/module.c	(working copy)
@@ -3052,26 +3052,27 @@
}

/* Recursive function to traverse the pointer_info tree and load a
- needed symbol. We return nonzero if we load a symbol and stop the
- traversal, because the act of loading can alter the tree. */
+ needed symbol. Because the act of loading can alter the tree, we
+ keep a count of all possible symbols to deal with. */


Because the act of loading can alter the tree, we return the number of loads that were made.


-static int
-load_needed (pointer_info * p)
+static void
+load_needed (pointer_info * p, int * symbols_remaining)


Shouldn't this be symbols_loaded, rather than symbols remaining??

{
  gfc_namespace *ns;
  pointer_info *q;
  gfc_symbol *sym;

  if (p == NULL)
-    return 0;
-  if (load_needed (p->left))
-    return 1;
-  if (load_needed (p->right))
-    return 1;
+    return ;

+  load_needed (p->left, symbols_remaining);
+  load_needed (p->right, symbols_remaining);
+
  if (p->type != P_SYMBOL || p->u.rsym.state != NEEDED)
-    return 0;
+    return ;

+  (*symbols_remaining)++;
+
  p->u.rsym.state = USED;

  set_module_locus (&p->u.rsym.where);
@@ -3101,7 +3102,7 @@
  mio_symbol (sym);
  sym->attr.use_assoc = 1;

-  return 1;
+  return ;
}


@@ -3155,6 +3156,7 @@ gfc_use_rename *u; gfc_symtree *st; gfc_symbol *sym; + int symbols_remaining;

get_module_locus (&operator_interfaces); /* Skip these for now */
skip_list ();
@@ -3323,7 +3325,12 @@
been loaded yet. If one symbol requires another, the other gets
marked as NEEDED if its previous state was UNUSED. */


Thus, we keep on traversing the tree until no more symbols are loaded.


- while (load_needed (pi_root));
+ do + { + symbols_remaining = 0;
+ load_needed (pi_root, &symbols_remaining);
+ }
+ while (symbols_remaining > 0);


/* Make sure all elements of the rename-list were found in the
module. */





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