Commit ffeebc4f by Jakub Jelinek Committed by Jakub Jelinek

re PR fortran/90329 (Incompatibility between gfortran and C lapack calls)

	PR fortran/90329
	* lang.opt (fbroken-callers): Remove.
	(ftail-call-workaround, ftail-call-workaround=): New options.
	* gfortran.h (struct gfc_namespace): Add implicit_interface_calls.
	* interface.c (gfc_procedure_use): Set implicit_interface_calls
	for calls to implicit interface procedures.
	* trans-decl.c (create_function_arglist): Use flag_tail_call_workaround
	instead of flag_broken_callers.  If it is not 2, also require
	sym->ns->implicit_interface_calls.
	* invoke.texi (fbroken-callers): Remove documentation.
	(ftail-call-workaround, ftail-call-workaround=): Document.

From-SVN: r271738
parent b54ecc76
2019-05-29 Jakub Jelinek <jakub@redhat.com>
PR fortran/90329
* lang.opt (fbroken-callers): Remove.
(ftail-call-workaround, ftail-call-workaround=): New options.
* gfortran.h (struct gfc_namespace): Add implicit_interface_calls.
* interface.c (gfc_procedure_use): Set implicit_interface_calls
for calls to implicit interface procedures.
* trans-decl.c (create_function_arglist): Use flag_tail_call_workaround
instead of flag_broken_callers. If it is not 2, also require
sym->ns->implicit_interface_calls.
* invoke.texi (fbroken-callers): Remove documentation.
(ftail-call-workaround, ftail-call-workaround=): Document.
2019-05-26 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/90539
......
......@@ -1866,6 +1866,9 @@ typedef struct gfc_namespace
/* Set to 1 for !$ACC ROUTINE namespaces. */
unsigned oacc_routine:1;
/* Set to 1 if there are any calls to procedures with implicit interface. */
unsigned implicit_interface_calls:1;
}
gfc_namespace;
......
......@@ -3686,6 +3686,7 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
gfc_warning (OPT_Wimplicit_procedure,
"Procedure %qs called at %L is not explicitly declared",
sym->name, where);
gfc_find_proc_namespace (sym->ns)->implicit_interface_calls = 1;
}
if (sym->attr.if_source == IFSRC_UNKNOWN)
......
......@@ -181,7 +181,8 @@ and warnings}.
@item Code Generation Options
@xref{Code Gen Options,,Options for code generation conventions}.
@gccoptlist{-faggressive-function-elimination -fblas-matmul-limit=@var{n} @gol
-fbounds-check -fbroken-callers -fcheck-array-temporaries @gol
-fbounds-check -ftail-call-workaround -ftail-call-workaround=@var{n} @gol
-fcheck-array-temporaries @gol
-fcheck=@var{<all|array-temps|bounds|do|mem|pointer|recursion>} @gol
-fcoarray=@var{<none|single|lib>} -fexternal-blas -ff2c
-ffrontend-loop-interchange @gol
......@@ -1622,8 +1623,9 @@ warnings for generated array temporaries.
@c Note: This option is also referred in gcc's manpage
Deprecated alias for @option{-fcheck=bounds}.
@item -fbroken-callers
@opindex @code{broken-callers}
@item -ftail-call-workaround
@itemx -ftail-call-workaround=@var{n}
@opindex @code{tail-call-workaround}
Some C interfaces to Fortran codes violate the gfortran ABI by
omitting the hidden character length arguments as described in
@xref{Argument passing conventions}. This can lead to crashes
......@@ -1631,7 +1633,11 @@ because pushing arguments for tail calls can overflow the stack.
To provide a workaround for existing binary packages, this option
disables tail call optimization for gfortran procedures with character
arguments.
arguments. With @option{-ftail-call-workaround=2} tail call optimization
is disabled in all gfortran procedures with character arguments,
with @option{-ftail-call-workaround=1} or equivalent
@option{-ftail-call-workaround} only in gfortran procedures with character
arguments that call implicitly prototyped procedures.
Using this option can lead to problems including crashes due to
insufficient stack space.
......@@ -1644,10 +1650,10 @@ source code.
Support for this option will likely be withdrawn in a future release
of gfortran.
The negative form, @option{-fno-broken-callers}, can be used to
disable this option.
The negative form, @option{-fno-tail-call-workaround} or equivalent
@option{-ftail-call-workaround=0}, can be used to disable this option.
Default is currently @option{-fbroken-callers}, this will change
Default is currently @option{-ftail-call-workaround}, this will change
in future releases.
@item -fcheck-array-temporaries
......
......@@ -397,10 +397,6 @@ fblas-matmul-limit=
Fortran RejectNegative Joined UInteger Var(flag_blas_matmul_limit) Init(30)
-fblas-matmul-limit=<n> Size of the smallest matrix for which matmul will use BLAS.
fbroken-callers
Fortran Var(flag_broken_callers) Init(1)
Disallow tail call optimization when a calling routine may have omitted character lenghts.
fcheck-array-temporaries
Fortran
Produce a warning at runtime if a array temporary has been created for a procedure argument.
......@@ -766,6 +762,13 @@ fsign-zero
Fortran Var(flag_sign_zero) Init(1)
Apply negative sign to zero values.
ftail-call-workaround
Frotran Alias(ftail-call-workaround=,1,0)
ftail-call-workaround=
Fortran RejectNegative Joined UInteger IntegerRange(0, 2) Var(flag_tail_call_workaround) Init(1)
Disallow tail call optimization when a calling routine may have omitted character lenghts.
funderscoring
Fortran Var(flag_underscoring) Init(1)
Append underscores to externally visible names.
......
......@@ -2520,9 +2520,12 @@ create_function_arglist (gfc_symbol * sym)
/* Marking the length DECL_HIDDEN_STRING_LENGTH will lead
to tail calls being disabled. Only do that if we
potentially have broken callers. */
if (flag_broken_callers && f->sym->ts.u.cl
if (flag_tail_call_workaround
&& f->sym->ts.u.cl
&& f->sym->ts.u.cl->length
&& f->sym->ts.u.cl->length->expr_type == EXPR_CONSTANT)
&& f->sym->ts.u.cl->length->expr_type == EXPR_CONSTANT
&& (flag_tail_call_workaround == 2
|| f->sym->ns->implicit_interface_calls))
DECL_HIDDEN_STRING_LENGTH (length) = 1;
/* Remember the passed value. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment