* [patch, fortran] Some cleanup / fixes in front-end statement walker
@ 2011-10-16 21:02 Thomas Koenig
2011-10-16 22:07 ` Steven Bosscher
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2011-10-16 21:02 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 860 bytes --]
Hello world,
working on PR 50690, I noticed a few things which are
not quite right in front-end optimization statement
walking:
- BLOCKs were walked via their namespaces, not directly.
This caused out-of-order walking, which was confusing.
- current_ns was not marked static.
- ASSOCIATE lists were not walked.
This patch corrects these things. Regression-tested.
OK for trunk? (I will not be able to commit for a few
days due to business travel, unless somebody is _really_
fast :-)
Thomas
2011-10-16 Thomas Koenig <tkoenig@gcc.gnu.org>
* frontend-passes.c (current_ns): Make static.
(create_var): Note parent of newly created namespace.
(optimize_namespace): Don't wak sibling namespaces
if they are EXEC_BLOCK because this is handled...
(gfc_code_walker): ... here. Also walk ASSOCIATE lists.
[-- Attachment #2: frontend-cleanup-1.diff --]
[-- Type: text/x-patch, Size: 1830 bytes --]
Index: frontend-passes.c
===================================================================
--- frontend-passes.c (Revision 179770)
+++ frontend-passes.c (Arbeitskopie)
@@ -60,7 +60,7 @@ static gfc_code *inserted_block, **changed_stateme
/* The namespace we are currently dealing with. */
-gfc_namespace *current_ns;
+static gfc_namespace *current_ns;
/* If we are within any forall loop. */
@@ -261,6 +261,7 @@ create_var (gfc_expr * e)
(*current_code)->next = NULL;
/* Insert the BLOCK at the right position. */
*current_code = inserted_block;
+ ns->parent = current_ns;
}
else
ns = inserted_block->ext.block.ns;
@@ -509,8 +510,12 @@ optimize_namespace (gfc_namespace *ns)
gfc_code_walker (&ns->code, cfe_code, cfe_expr_0, NULL);
gfc_code_walker (&ns->code, optimize_code, optimize_expr, NULL);
+ /* BLOCKs are handled in the expression walker below. */
for (ns = ns->contained; ns; ns = ns->sibling)
- optimize_namespace (ns);
+ {
+ if (ns->code == NULL || ns->code->op != EXEC_BLOCK)
+ optimize_namespace (ns);
+ }
}
/* Replace code like
@@ -1143,6 +1148,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
gfc_code *b;
gfc_actual_arglist *a;
gfc_code *co;
+ gfc_association_list *alist;
/* There might be statement insertions before the current code,
which must not affect the expression walker. */
@@ -1151,6 +1157,13 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
switch (co->op)
{
+
+ case EXEC_BLOCK:
+ WALK_SUBCODE (co->ext.block.ns->code);
+ for (alist = co->ext.block.assoc; alist; alist = alist->next)
+ WALK_SUBEXPR (alist->target);
+ break;
+
case EXEC_DO:
WALK_SUBEXPR (co->ext.iterator->var);
WALK_SUBEXPR (co->ext.iterator->start);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch, fortran] Some cleanup / fixes in front-end statement walker
2011-10-16 21:02 [patch, fortran] Some cleanup / fixes in front-end statement walker Thomas Koenig
@ 2011-10-16 22:07 ` Steven Bosscher
2011-10-17 6:19 ` Thomas Koenig
0 siblings, 1 reply; 3+ messages in thread
From: Steven Bosscher @ 2011-10-16 22:07 UTC (permalink / raw)
To: Thomas Koenig; +Cc: fortran, gcc-patches
> This patch corrects these things. Regression-tested.
> OK for trunk? (I will not be able to commit for a few
> days due to business travel, unless somebody is _really_
> fast :-)
Looks OK to me. Fast enough for you?
Ciao!
Steven
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch, fortran] Some cleanup / fixes in front-end statement walker
2011-10-16 22:07 ` Steven Bosscher
@ 2011-10-17 6:19 ` Thomas Koenig
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Koenig @ 2011-10-17 6:19 UTC (permalink / raw)
To: Steven Bosscher; +Cc: fortran, gcc-patches
Steven Bosscher wote:
>> This patch corrects these things. Regression-tested.
>> OK for trunk? (I will not be able to commit for a few
>> days due to business travel, unless somebody is _really_
>> fast :-)
>
> Looks OK to me. Fast enough for you?
Yes indeed. Committed as rev. 180063.
Thanks a lot!
Thomas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-16 22:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-16 21:02 [patch, fortran] Some cleanup / fixes in front-end statement walker Thomas Koenig
2011-10-16 22:07 ` Steven Bosscher
2011-10-17 6:19 ` Thomas Koenig
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).