Thomas König
2018-09-20 19:29:37 UTC
Hi,
the patch below tries to clobber scalar intent(out) arguments
on procedure entry.
Index: trans-decl.c
===================================================================
--- trans-decl.c (Revision 264423)
+++ trans-decl.c (Arbeitskopie)
@@ -4143,6 +4143,19 @@ init_intent_out_dt (gfc_symbol * proc_sym, gfc_wra
gfc_add_expr_to_block (&init, tmp);
}
+ else if (f->sym->attr.dummy && !f->sym->attr.dimension
+ && f->sym->attr.intent == INTENT_OUT
+ && !f->sym->attr.codimension && !f->sym->attr.allocatable
+ && (f->sym->ts.type != BT_CLASS
+ || (!CLASS_DATA (f->sym)->attr.dimension
+ && !(CLASS_DATA (f->sym)->attr.codimension
+ && CLASS_DATA (f->sym)->attr.allocatable))))
+ {
+ tree t1, t2;
+ t1 = build_fold_indirect_ref_loc (input_location,
f->sym->backend_decl);
+ t2 = build_clobber (TREE_TYPE (t1));
+ gfc_add_modify (&init, t1, t2);
+ }
gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
}
With this patch,
module x
contains
subroutine foo(a)
real, intent(out) :: a
a = 21.
a = a + 22.
end subroutine foo
end module x
generates, with -fdump-tree-original
foo (real(kind=4) & restrict a)
{
*a = {CLOBBER};
*a = 2.1e+1;
*a = *a + 2.2e+1;
}
Is this the right way to proceed?
(The if statement is not yet correct, so this version causes
regressions, that would have to be adjusted).
Regards
Thomas
the patch below tries to clobber scalar intent(out) arguments
on procedure entry.
Index: trans-decl.c
===================================================================
--- trans-decl.c (Revision 264423)
+++ trans-decl.c (Arbeitskopie)
@@ -4143,6 +4143,19 @@ init_intent_out_dt (gfc_symbol * proc_sym, gfc_wra
gfc_add_expr_to_block (&init, tmp);
}
+ else if (f->sym->attr.dummy && !f->sym->attr.dimension
+ && f->sym->attr.intent == INTENT_OUT
+ && !f->sym->attr.codimension && !f->sym->attr.allocatable
+ && (f->sym->ts.type != BT_CLASS
+ || (!CLASS_DATA (f->sym)->attr.dimension
+ && !(CLASS_DATA (f->sym)->attr.codimension
+ && CLASS_DATA (f->sym)->attr.allocatable))))
+ {
+ tree t1, t2;
+ t1 = build_fold_indirect_ref_loc (input_location,
f->sym->backend_decl);
+ t2 = build_clobber (TREE_TYPE (t1));
+ gfc_add_modify (&init, t1, t2);
+ }
gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
}
With this patch,
module x
contains
subroutine foo(a)
real, intent(out) :: a
a = 21.
a = a + 22.
end subroutine foo
end module x
generates, with -fdump-tree-original
foo (real(kind=4) & restrict a)
{
*a = {CLOBBER};
*a = 2.1e+1;
*a = *a + 2.2e+1;
}
Is this the right way to proceed?
(The if statement is not yet correct, so this version causes
regressions, that would have to be adjusted).
Regards
Thomas