* [Bug fortran/29952] Flag to give runtime information " array temporary was created for argument"
2006-11-23 9:49 [Bug fortran/29952] New: Flag to give runtime information " array temporary was created for argument" burnus at gcc dot gnu dot org
@ 2006-11-23 18:31 ` pault at gcc dot gnu dot org
2008-07-21 21:40 ` tkoenig at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-11-23 18:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pault at gcc dot gnu dot org 2006-11-23 18:31 -------
Confirmed.... sort of.
>
> While one can sometimes not prevent the need for a array temporary, one often
> can and should do so to speed up the program.
{
void * D.1019;
struct array1_real4 parm.2;
int4 D.1008;
D.1008 = i;
parm.2.dtype = 281;
parm.2.dim[0].lbound = 1;
parm.2.dim[0].ubound = 3;
parm.2.dim[0].stride = 20;
parm.2.data = (void *) &coord[D.1008 + -1];
parm.2.offset = 0;
D.1019 = _gfortran_internal_pack (&parm.2);
d = distance (D.1019);
if (D.1019 != (real4[0:] *) parm.2.data)
{
_gfortran_internal_unpack (&parm.2, D.1019);
_gfortran_internal_free (D.1019);
}
else
{
(void) 0;
}
}
It is the parm.2.dim[0].stride = 20; that determines the need for a temporary.
If it has a value of 1, internal pack returns a pointer to the source array.
Thus, such an option would work for constant strides of other than one but
would have to report in real-time for variable strides.
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-11-23 18:31:25
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29952
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/29952] Flag to give runtime information " array temporary was created for argument"
2006-11-23 9:49 [Bug fortran/29952] New: Flag to give runtime information " array temporary was created for argument" burnus at gcc dot gnu dot org
2006-11-23 18:31 ` [Bug fortran/29952] " pault at gcc dot gnu dot org
@ 2008-07-21 21:40 ` tkoenig at gcc dot gnu dot org
2008-07-23 16:13 ` burnus at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-07-21 21:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from tkoenig at gcc dot gnu dot org 2008-07-21 21:40 -------
Created an attachment (id=15936)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15936&action=view)
patch for compile-time check
This passes regression-tests, make info and make dvi.
All that's needed is a proper test case.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29952
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/29952] Flag to give runtime information " array temporary was created for argument"
2006-11-23 9:49 [Bug fortran/29952] New: Flag to give runtime information " array temporary was created for argument" burnus at gcc dot gnu dot org
2006-11-23 18:31 ` [Bug fortran/29952] " pault at gcc dot gnu dot org
2008-07-21 21:40 ` tkoenig at gcc dot gnu dot org
@ 2008-07-23 16:13 ` burnus at gcc dot gnu dot org
2008-07-24 8:33 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-07-23 16:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2008-07-23 16:12 -------
Test case for the run-time check. Only for the second call a warning is needed.
One way to add it is the following. One simply inserts
if (parm.1.data != D.1036)
printf("test.f90:5: In call to FOO, an array temporary "
"was created for argument #1\n");
between the following lines:
D.1036 = _gfortran_internal_pack (&parm.1);
foo (D.1036);
(The "if" line is copied from the _gfortran_internal_unpack block.)
Test case:
program test
implicit none
integer :: a(3,3)
call foo(a(:,1)) ! OK, no temporary created
call foo(a(1,:)) ! BAD, temporary var created
contains
subroutine foo(x)
integer :: x(3)
x = 5
end subroutine foo
end program test
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29952
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/29952] Flag to give runtime information " array temporary was created for argument"
2006-11-23 9:49 [Bug fortran/29952] New: Flag to give runtime information " array temporary was created for argument" burnus at gcc dot gnu dot org
` (2 preceding siblings ...)
2008-07-23 16:13 ` burnus at gcc dot gnu dot org
@ 2008-07-24 8:33 ` burnus at gcc dot gnu dot org
2008-07-24 9:28 ` tkoenig at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-07-24 8:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2008-07-24 08:33 -------
(In reply to comment #3)
> Test case for the run-time check.
By itself this PR not related is PR 36909. However, both require that
gfc_conv_function_call passes on information. For PR 36909 one needs to have
the INTENT of the formal argument, for this PR one needs to pass the procedure
name and either the formal-argument name or its position.
Thus I think one could fix both PRs simultaneously.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29952
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/29952] Flag to give runtime information " array temporary was created for argument"
2006-11-23 9:49 [Bug fortran/29952] New: Flag to give runtime information " array temporary was created for argument" burnus at gcc dot gnu dot org
` (3 preceding siblings ...)
2008-07-24 8:33 ` burnus at gcc dot gnu dot org
@ 2008-07-24 9:28 ` tkoenig at gcc dot gnu dot org
2008-07-27 10:47 ` burnus at gcc dot gnu dot org
2008-07-27 10:55 ` burnus at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-07-24 9:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from tkoenig at gcc dot gnu dot org 2008-07-24 09:27 -------
Subject: Bug 29952
Author: tkoenig
Date: Thu Jul 24 09:26:43 2008
New Revision: 138112
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138112
Log:
2008-07-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/29952
* gfortran.h: Add "warn_array_temp" to gfc_option_t.
* lang.opt: Add -Warray-temporaries.
* invoke.texi: Document -Warray-temporaries
* trans-array.h (gfc_trans_create_temp_array): Add argument of
type *locus.
(gfc_conv_loop_setup): Likewise.
* trans-array.c (gfc_trans_create_temp_array): If
-Warray-temporaries is given and locus is present, warn about
creation of array temporaries.
(gfc_trans_array_constructor_subarray): Add locus to call
of gfc_conv_loop_setup.
(gfc_trans_array_constructor): Add where argument. Pass where
argument to call of gfc_trans_create_temp_array.
(gfc_add_loop_ss_code): Add where argument. Pass where argument
to recursive call of gfc_add_loop_ss_code and to call of
gfc_trans_array_constructor.
(gfc_conv_loop_setup): Add where argument. Pass where argument
to calls to gfc_add_loop_ss_code and to gfc_trans_create_temp_array.
(gfc_conv_expr_descriptor): Pass location to call of
gfc_conv_loop_setup.
(gfc_conv_array_parameter): If -Warray-temporaries is given,
warn about creation of temporary arrays.
* trans-expr.c (gfc_conv_subref_array_arg): Add where argument
to call to gfc_conv_loop_setup.
(gfc_conv_function_call): Add where argument to call to
gfc_trans_creat_temp_array.
(gfc_trans_subarray_assign): Likewise.
(gfc_trans_assignment_1): Add where argument to call to
gfc_conv_loop_setup.
* trans-stmt.c (gfc_conv_elemental_dependencies): Add where
argument to call to gfc_trans_create_temp_array.
(gfc_trans_call): Add where argument to call to gfc_conv_loop_setup.
(generate_loop_for_temp_to_lhs): Likewise.
(generate_loop_for_rhs_to_temp): Likewise.
(compute_inner_temp_size): Likewise.
(gfc_trans-pointer_assign_need_temp): Likewise.
(gfc_evaluate_where_mask): Likewise.
(gfc_trans_where_assign): Likewise.
(gfc_trans_where_3): Likewise.
* trans-io.c (transfer_srray_component): Add where argument
to function. Add where argument to call to gfc_conv_loop_setup.
(transfer_expr): Add where argument to call to
transfer_array_component.
(gfc_trans_transfer): Add where expression to call to
gfc_conv_loop_setup.
* trans-intrinsic.c (gfc_conv_intrinsic_anyall): Add
where argument to call to gfc_conv_loop_setup.
(gfc_conv_intrinsic_count): Likewise.
(gfc_conv_intrinsic_arith): Likewise.
(gfc_conv_intrinsic_dot_product): Likewise.
(gfc_conv_intrinsic_minmaxloc): Likewise.
(gfc_conv_intrinsic_minmaxval): Likewise.
(gfc_conv_intrinsic_array_transfer): Warn about
creation of temporary array.
Add where argument to call to gfc_trans_create_temp_array.
* options.c (gfc_init_options): Initialize gfc_option.warn_array_temp.
(gfc_handle_option): Set gfc_option.warn_array_temp.
2008-07-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/29952
* gfortran.dg/array_temporaries_1.f90: New test case.
Added:
trunk/gcc/testsuite/gfortran.dg/array_temporaries_1.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/invoke.texi
trunk/gcc/fortran/lang.opt
trunk/gcc/fortran/options.c
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans-array.h
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-intrinsic.c
trunk/gcc/fortran/trans-io.c
trunk/gcc/fortran/trans-stmt.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29952
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/29952] Flag to give runtime information " array temporary was created for argument"
2006-11-23 9:49 [Bug fortran/29952] New: Flag to give runtime information " array temporary was created for argument" burnus at gcc dot gnu dot org
` (4 preceding siblings ...)
2008-07-24 9:28 ` tkoenig at gcc dot gnu dot org
@ 2008-07-27 10:47 ` burnus at gcc dot gnu dot org
2008-07-27 10:55 ` burnus at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-07-27 10:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from burnus at gcc dot gnu dot org 2008-07-27 10:46 -------
Subject: Bug 29952
Author: burnus
Date: Sun Jul 27 10:45:44 2008
New Revision: 138186
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138186
Log:
2008-07-27 Tobias Burnus <burnus@net-b.de>
PR fortran/36132
PR fortran/29952
PR fortran/36909
* trans.c (gfc_trans_runtime_check): Allow run-time warning
* besides
run-time error.
* trans.h (gfc_trans_runtime_check): Update declaration.
* trans-array.c
* (gfc_trans_array_ctor_element,gfc_trans_array_bound_check,
gfc_conv_array_ref,gfc_conv_ss_startstride,gfc_trans_dummy_array_bias):
Updated gfc_trans_runtime_check calls.
(gfc_conv_array_parameter): Implement flag_check_array_temporaries,
fix packing/unpacking for nonpresent optional actuals to optional
formals.
* trans-array.h (gfc_conv_array_parameter): Update declaration.
* trans-expr.c (gfc_conv_substring,gfc_trans_arrayfunc_assign,
gfc_conv_function_call): Updated gfc_trans_runtime_check calls.
(gfc_conv_function_call): Update gfc_conv_array_parameter calls.
* trans-expr.c (gfc_trans_goto): Updated gfc_trans_runtime_check
calls.
* trans-io.c (set_string,gfc_conv_intrinsic_repeat): Ditto.
(gfc_conv_intrinsic_transfer,gfc_conv_intrinsic_loc): Same for
gfc_conv_array_parameter.
* trans-intrinsics.c (gfc_conv_intrinsic_bound): Ditto.
* trans-decl.c (gfc_build_builtin_function_decls): Add
gfor_fndecl_runtime_warning_at.
* lang.opt: New option fcheck-array-temporaries.
* gfortran.h (gfc_options): New flag_check_array_temporaries.
* options.c (gfc_init_options, gfc_handle_option): Handle flag.
* invoke.texi: New option fcheck-array-temporaries.
2008-07-27 Tobias Burnus <burnus@net-b.de>
PR fortran/36132
PR fortran/29952
PR fortran/36909
* runtime/error.c: New function runtime_error_at.
* gfortran.map: Ditto.
* libgfortran.h: Ditto.
2008-07-27 Tobias Burnus <burnus@net-b.de>
PR fortran/36132
PR fortran/29952
PR fortran/36909
gfortran.dg/internal_pack_4.f90: New.
gfortran.dg/internal_pack_5.f90: New.
gfortran.dg/array_temporaries_2.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/array_temporaries_2.f90
trunk/gcc/testsuite/gfortran.dg/internal_pack_4.f90
trunk/gcc/testsuite/gfortran.dg/internal_pack_5.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/invoke.texi
trunk/gcc/fortran/lang.opt
trunk/gcc/fortran/options.c
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans-array.h
trunk/gcc/fortran/trans-decl.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-intrinsic.c
trunk/gcc/fortran/trans-io.c
trunk/gcc/fortran/trans-stmt.c
trunk/gcc/fortran/trans.c
trunk/gcc/fortran/trans.h
trunk/gcc/testsuite/ChangeLog
trunk/libgfortran/ChangeLog
trunk/libgfortran/gfortran.map
trunk/libgfortran/libgfortran.h
trunk/libgfortran/runtime/error.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29952
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/29952] Flag to give runtime information " array temporary was created for argument"
2006-11-23 9:49 [Bug fortran/29952] New: Flag to give runtime information " array temporary was created for argument" burnus at gcc dot gnu dot org
` (5 preceding siblings ...)
2008-07-27 10:47 ` burnus at gcc dot gnu dot org
@ 2008-07-27 10:55 ` burnus at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-07-27 10:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from burnus at gcc dot gnu dot org 2008-07-27 10:54 -------
Now also run-time warnings are printed.
-> FIXED on the trunk (4.4).
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29952
^ permalink raw reply [flat|nested] 8+ messages in thread