* [Bug fortran/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
@ 2021-12-18 23:33 ` iains at gcc dot gnu.org
2021-12-18 23:36 ` iains at gcc dot gnu.org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: iains at gcc dot gnu.org @ 2021-12-18 23:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |10.3.0, 11.1.0
Target Milestone|--- |12.0
Target| |x86_64-pc-linux-gnu,
| |x86_64-apple-darwin,
| |aarch64-apple-darwin
Keywords| |wrong-code
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
2021-12-18 23:33 ` [Bug fortran/103766] " iains at gcc dot gnu.org
@ 2021-12-18 23:36 ` iains at gcc dot gnu.org
2021-12-19 7:43 ` [Bug ipa/103766] " pinskia at gcc dot gnu.org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: iains at gcc dot gnu.org @ 2021-12-18 23:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
example optimised tree dump:
O0
;; Function sub (sub.0, funcdef_no=1, decl_uid=2979, cgraph_uid=1,
symbol_order=0)
__attribute__((fn spec (". ")))
void sub ()
{
struct __st_parameter_dt dt_parm.0;
real(kind=4) * a.2_1;
<bb 2> :
dt_parm.0.common.filename = &"t.f90"[1]{lb: 1 sz: 1};
dt_parm.0.common.line = 8;
dt_parm.0.common.flags = 128;
dt_parm.0.common.unit = 6;
_gfortran_st_write (&dt_parm.0);
a.2_1 = &CHAIN.4_8(D)->a;
_gfortran_transfer_real_write (&dt_parm.0, a.2_1, 4);
_gfortran_st_write_done (&dt_parm.0);
dt_parm.0 ={v} {CLOBBER};
return;
}
;; Function crash (MAIN__, funcdef_no=0, decl_uid=2977, cgraph_uid=2,
symbol_order=1)
__attribute__((fn spec (". ")))
void crash ()
{
struct FRAME.crash FRAME.3;
real(kind=4) a [value-expr: FRAME.3.a];
real(kind=4) D.2991;
real(kind=4) _3;
<bb 2> :
FRAME.3.FRAME_BASE.PARENT = 0B;
_3 = 1.0e+0;
FRAME.3.a = _3;
sub (); [static-chain: &FRAME.3]
GIMPLE_NOP
return;
}
;; Function main (main, funcdef_no=2, decl_uid=2983, cgraph_uid=3,
symbol_order=2)
__attribute__((externally_visible))
integer(kind=4) main (integer(kind=4) argc, character(kind=1) * * argv)
{
static integer(kind=4) options.1[7] = {2116, 4095, 0, 1, 1, 0, 31};
integer(kind=4) D.2993;
integer(kind=4) _7;
<bb 2> :
_gfortran_set_args (argc_2(D), argv_3(D));
_gfortran_set_options (7, &options.1[0]);
crash ();
_7 = 0;
<bb 3> :
<L0>:
return _7;
}
O1
;; Function sub (sub.0, funcdef_no=1, decl_uid=2979, cgraph_uid=1,
symbol_order=0) (executed once)
__attribute__((fn spec (". ")))
void sub ()
{
struct __st_parameter_dt dt_parm.0;
real(kind=4) * a.2_1;
<bb 2> [local count: 1073741824]:
dt_parm.0.common.filename = &"t.f90"[1]{lb: 1 sz: 1};
dt_parm.0.common.line = 8;
dt_parm.0.common.flags = 128;
dt_parm.0.common.unit = 6;
_gfortran_st_write (&dt_parm.0);
a.2_1 = &CHAIN.4_8(D)->a;
_gfortran_transfer_real_write (&dt_parm.0, a.2_1, 4);
_gfortran_st_write_done (&dt_parm.0);
dt_parm.0 ={v} {CLOBBER};
return;
}
;; Function main (main, funcdef_no=2, decl_uid=2983, cgraph_uid=3,
symbol_order=2) (executed once)
__attribute__((externally_visible))
integer(kind=4) main (integer(kind=4) argc, character(kind=1) * * argv)
{
struct FRAME.crash FRAME.3;
static integer(kind=4) options.1[7] = {2116, 4095, 0, 1, 1, 0, 31};
<bb 2> [local count: 1073741824]:
_gfortran_set_args (argc_2(D), argv_3(D));
_gfortran_set_options (7, &options.1[0]);
sub (); [static-chain: &FRAME.3]
return 0;
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
2021-12-18 23:33 ` [Bug fortran/103766] " iains at gcc dot gnu.org
2021-12-18 23:36 ` iains at gcc dot gnu.org
@ 2021-12-19 7:43 ` pinskia at gcc dot gnu.org
2021-12-19 7:51 ` pinskia at gcc dot gnu.org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-19 7:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I tried to reproduce it with the following GNU C code but it still
worked:struct __st_parameter_dt
{
const char *filename ;
int linenum;
int flags;
int unit;
};
[[gnu::noinline, gnu::access(read_only, 1), gnu::access(read_only, 2, 3),
gnu::noclone, gnu::leaf]]
void print(struct __st_parameter_dt *b, void *a, int);
[[gnu::noinline, gnu::access(read_only, 1), gnu::noclone, gnu::leaf]]
void print1(struct __st_parameter_dt *b);
[[gnu::noinline, gnu::access(read_only, 1), gnu::noclone, gnu::leaf]]
void print2(struct __st_parameter_dt *b);
int main(void)
{
double a;
a = 1;
[[gnu::noinline]]
void f()
{
struct __st_parameter_dt b;
b.filename = "a.c";
b.linenum = 20;
b.flags =128;
b.unit = 1;
print1(&b);
print(&b, &a, sizeof(a));
print2(&b);
}
f();
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (2 preceding siblings ...)
2021-12-19 7:43 ` [Bug ipa/103766] " pinskia at gcc dot gnu.org
@ 2021-12-19 7:51 ` pinskia at gcc dot gnu.org
2021-12-19 16:03 ` kargl at gcc dot gnu.org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-19 7:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-12-19
Status|UNCONFIRMED |NEW
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-fno-ipa-modref fixes the issue though.
I can't figure out why the store to the frame is being removed.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (3 preceding siblings ...)
2021-12-19 7:51 ` pinskia at gcc dot gnu.org
@ 2021-12-19 16:03 ` kargl at gcc dot gnu.org
2021-12-19 16:57 ` hubicka at gcc dot gnu.org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu.org @ 2021-12-19 16:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
CC| |kargl at gcc dot gnu.org
--- Comment #4 from kargl at gcc dot gnu.org ---
Host association is fundamental to Fortran.
This has worked for 20 years. Looks like a P1
issue.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (4 preceding siblings ...)
2021-12-19 16:03 ` kargl at gcc dot gnu.org
@ 2021-12-19 16:57 ` hubicka at gcc dot gnu.org
2021-12-19 20:52 ` hubicka at gcc dot gnu.org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-12-19 16:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |hubicka at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
There seems to be wrong no_direct_read flag on the static chain parameter
comming out of the ipa propagation. I will take a look.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (5 preceding siblings ...)
2021-12-19 16:57 ` hubicka at gcc dot gnu.org
@ 2021-12-19 20:52 ` hubicka at gcc dot gnu.org
2021-12-19 21:33 ` iains at gcc dot gnu.org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-12-19 20:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
--- Comment #6 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
This is yet another stupid early exit in the propagation code (next stage1 i
guess I will want to go through them and make it more systematic - those
originate from quite early versions of modref when it was easier to rule out
cases where propagation is no longer useful)
I would welcome a testuite friendly version of the fortran testcase
diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index d3590f0b62b..7152d66c251 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -5020,8 +5020,14 @@ modref_merge_call_site_flags (escape_summary *sum,
bool ignore_stores = ignore_stores_p (caller, callee_ecf_flags);
/* If we have no useful info to propagate. */
- if ((!cur_summary || !cur_summary->arg_flags.length ())
- && (!cur_summary_lto || !cur_summary_lto->arg_flags.length ()))
+ if ((!cur_summary
+ || (!cur_summary->arg_flags.length ()
+ && !cur_summary->static_chain_flags
+ && !cur_summary->retslot_flags))
+ && (!cur_summary_lto
+ || (!cur_summary_lto->arg_flags.length ()
+ && !cur_summary_lto->static_chain_flags
+ && !cur_summary_lto->retslot_flags)))
return false;
FOR_EACH_VEC_ELT (sum->esc, i, ee)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (6 preceding siblings ...)
2021-12-19 20:52 ` hubicka at gcc dot gnu.org
@ 2021-12-19 21:33 ` iains at gcc dot gnu.org
2021-12-19 21:39 ` hubicka at kam dot mff.cuni.cz
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: iains at gcc dot gnu.org @ 2021-12-19 21:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
--- Comment #7 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #6)
> I would welcome a testuite friendly version of the fortran testcase
Both Andrew and I failed to make a C reproducer - what about just taking the
-fdump-tree-gimple, as input would that work ?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (7 preceding siblings ...)
2021-12-19 21:33 ` iains at gcc dot gnu.org
@ 2021-12-19 21:39 ` hubicka at kam dot mff.cuni.cz
2021-12-19 21:40 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: hubicka at kam dot mff.cuni.cz @ 2021-12-19 21:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
--- Comment #8 from hubicka at kam dot mff.cuni.cz ---
> > I would welcome a testuite friendly version of the fortran testcase
>
> Both Andrew and I failed to make a C reproducer - what about just taking the
> -fdump-tree-gimple, as input would that work ?
Me too. The testcase depends on fnspec annotations produced by Fortran
so we get both noescape and noread to trigger the wrong code. I guess
we may try to feed fnspec to gimple frontend but I am not even sure it
is possible, since fnspec is internal attribute....
I suppose we can also live without a testcase - I hope I will not do
again such a stupid oversight.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (8 preceding siblings ...)
2021-12-19 21:39 ` hubicka at kam dot mff.cuni.cz
@ 2021-12-19 21:40 ` cvs-commit at gcc dot gnu.org
2021-12-19 21:42 ` hubicka at gcc dot gnu.org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-19 21:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jan Hubicka <hubicka@gcc.gnu.org>:
https://gcc.gnu.org/g:fcbf94a5be9e0c1ecad92da773a6632b86b7f70a
commit r12-6067-gfcbf94a5be9e0c1ecad92da773a6632b86b7f70a
Author: Jan Hubicka <jh@suse.cz>
Date: Sun Dec 19 22:28:40 2021 +0100
Fix early exit in modref_merge_call_site_flags
When adding support for static chain and return slot flags I forgot to
update
early exit condition in modref_merge_call_site_flags. This yields to wrong
code as demonstrated by the Fortran testcase attached to PR (which I hope
someone will help me to turn into testuite one).
gcc/ChangeLog:
2021-12-19 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103766
* ipa-modref.c (modref_merge_call_site_flags): Fix early exit
condition
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (9 preceding siblings ...)
2021-12-19 21:40 ` cvs-commit at gcc dot gnu.org
@ 2021-12-19 21:42 ` hubicka at gcc dot gnu.org
2021-12-19 21:58 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-12-19 21:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #10 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (10 preceding siblings ...)
2021-12-19 21:42 ` hubicka at gcc dot gnu.org
@ 2021-12-19 21:58 ` pinskia at gcc dot gnu.org
2021-12-19 22:11 ` hubicka at kam dot mff.cuni.cz
2021-12-21 19:10 ` fxcoudert at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-19 21:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Iain Sandoe from comment #7)
> (In reply to Jan Hubicka from comment #6)
>
> > I would welcome a testuite friendly version of the fortran testcase
>
> Both Andrew and I failed to make a C reproducer - what about just taking the
> -fdump-tree-gimple, as input would that work ?
Even trying to find a Fortran testsuite friendly version is hard because the
issue can only happen with print, I tried even doing internal write to a string
it is passing without any changes.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (11 preceding siblings ...)
2021-12-19 21:58 ` pinskia at gcc dot gnu.org
@ 2021-12-19 22:11 ` hubicka at kam dot mff.cuni.cz
2021-12-21 19:10 ` fxcoudert at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: hubicka at kam dot mff.cuni.cz @ 2021-12-19 22:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
--- Comment #12 from hubicka at kam dot mff.cuni.cz ---
> Even trying to find a Fortran testsuite friendly version is hard because the
> issue can only happen with print, I tried even doing internal write to a string
> it is passing without any changes.
Yep, any reads that happen in the code visible to compiler will prevent
the bug from happening. It is a hard case - but as I said I think
there is quite low chance of it going back.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/103766] [12 Regression] Initialization of variable passed via static chain is lost.
2021-12-18 23:31 [Bug fortran/103766] New: [12 Regression] Initialization of variable passed via static chain is lost iains at gcc dot gnu.org
` (12 preceding siblings ...)
2021-12-19 22:11 ` hubicka at kam dot mff.cuni.cz
@ 2021-12-21 19:10 ` fxcoudert at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2021-12-21 19:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103766
Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu.org
--- Comment #13 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
I think this is a Fortran reproducer that does not depend on printing to
stdout:
program crash
implicit none
real :: a
a = 1.
call sub()
contains
subroutine sub()
character(len=100) :: s
real :: x
write(s,*) a
read(s,*) x
if (x /= 1.) stop 1
end subroutine sub
end program crash
It fails for me with trunk (before patch), but passed with 11.2.0
Could it be added to the testsuite please?
^ permalink raw reply [flat|nested] 15+ messages in thread