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> 2019-05-26 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/90539 PR fortran/90539
......
...@@ -1866,6 +1866,9 @@ typedef struct gfc_namespace ...@@ -1866,6 +1866,9 @@ typedef struct gfc_namespace
/* Set to 1 for !$ACC ROUTINE namespaces. */ /* Set to 1 for !$ACC ROUTINE namespaces. */
unsigned oacc_routine:1; unsigned oacc_routine:1;
/* Set to 1 if there are any calls to procedures with implicit interface. */
unsigned implicit_interface_calls:1;
} }
gfc_namespace; gfc_namespace;
......
...@@ -3686,6 +3686,7 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where) ...@@ -3686,6 +3686,7 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
gfc_warning (OPT_Wimplicit_procedure, gfc_warning (OPT_Wimplicit_procedure,
"Procedure %qs called at %L is not explicitly declared", "Procedure %qs called at %L is not explicitly declared",
sym->name, where); sym->name, where);
gfc_find_proc_namespace (sym->ns)->implicit_interface_calls = 1;
} }
if (sym->attr.if_source == IFSRC_UNKNOWN) if (sym->attr.if_source == IFSRC_UNKNOWN)
......
...@@ -181,7 +181,8 @@ and warnings}. ...@@ -181,7 +181,8 @@ and warnings}.
@item Code Generation Options @item Code Generation Options
@xref{Code Gen Options,,Options for code generation conventions}. @xref{Code Gen Options,,Options for code generation conventions}.
@gccoptlist{-faggressive-function-elimination -fblas-matmul-limit=@var{n} @gol @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 -fcheck=@var{<all|array-temps|bounds|do|mem|pointer|recursion>} @gol
-fcoarray=@var{<none|single|lib>} -fexternal-blas -ff2c -fcoarray=@var{<none|single|lib>} -fexternal-blas -ff2c
-ffrontend-loop-interchange @gol -ffrontend-loop-interchange @gol
...@@ -1622,8 +1623,9 @@ warnings for generated array temporaries. ...@@ -1622,8 +1623,9 @@ warnings for generated array temporaries.
@c Note: This option is also referred in gcc's manpage @c Note: This option is also referred in gcc's manpage
Deprecated alias for @option{-fcheck=bounds}. Deprecated alias for @option{-fcheck=bounds}.
@item -fbroken-callers @item -ftail-call-workaround
@opindex @code{broken-callers} @itemx -ftail-call-workaround=@var{n}
@opindex @code{tail-call-workaround}
Some C interfaces to Fortran codes violate the gfortran ABI by Some C interfaces to Fortran codes violate the gfortran ABI by
omitting the hidden character length arguments as described in omitting the hidden character length arguments as described in
@xref{Argument passing conventions}. This can lead to crashes @xref{Argument passing conventions}. This can lead to crashes
...@@ -1631,7 +1633,11 @@ because pushing arguments for tail calls can overflow the stack. ...@@ -1631,7 +1633,11 @@ because pushing arguments for tail calls can overflow the stack.
To provide a workaround for existing binary packages, this option To provide a workaround for existing binary packages, this option
disables tail call optimization for gfortran procedures with character 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 Using this option can lead to problems including crashes due to
insufficient stack space. insufficient stack space.
...@@ -1644,10 +1650,10 @@ source code. ...@@ -1644,10 +1650,10 @@ source code.
Support for this option will likely be withdrawn in a future release Support for this option will likely be withdrawn in a future release
of gfortran. of gfortran.
The negative form, @option{-fno-broken-callers}, can be used to The negative form, @option{-fno-tail-call-workaround} or equivalent
disable this option. @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. in future releases.
@item -fcheck-array-temporaries @item -fcheck-array-temporaries
......
...@@ -397,10 +397,6 @@ fblas-matmul-limit= ...@@ -397,10 +397,6 @@ fblas-matmul-limit=
Fortran RejectNegative Joined UInteger Var(flag_blas_matmul_limit) Init(30) 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. -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 fcheck-array-temporaries
Fortran Fortran
Produce a warning at runtime if a array temporary has been created for a procedure argument. Produce a warning at runtime if a array temporary has been created for a procedure argument.
...@@ -766,6 +762,13 @@ fsign-zero ...@@ -766,6 +762,13 @@ fsign-zero
Fortran Var(flag_sign_zero) Init(1) Fortran Var(flag_sign_zero) Init(1)
Apply negative sign to zero values. 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 funderscoring
Fortran Var(flag_underscoring) Init(1) Fortran Var(flag_underscoring) Init(1)
Append underscores to externally visible names. Append underscores to externally visible names.
......
...@@ -2520,9 +2520,12 @@ create_function_arglist (gfc_symbol * sym) ...@@ -2520,9 +2520,12 @@ create_function_arglist (gfc_symbol * sym)
/* Marking the length DECL_HIDDEN_STRING_LENGTH will lead /* Marking the length DECL_HIDDEN_STRING_LENGTH will lead
to tail calls being disabled. Only do that if we to tail calls being disabled. Only do that if we
potentially have broken callers. */ 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
&& 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; DECL_HIDDEN_STRING_LENGTH (length) = 1;
/* Remember the passed value. */ /* 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