* [PATCH] Fix PR86321
@ 2018-06-29 2:37 Richard Biener
2018-06-29 20:08 ` Janne Blomqvist
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2018-06-29 2:37 UTC (permalink / raw)
To: gcc-patches; +Cc: fortran, Jakub Jelinek
The fortran FE creates array descriptor types via build_distinct_type_copy
which ends up re-using the TYPE_FIELDs chain of FIELD_DECLs between
types in different type-variant chains. While that seems harmless
in practice it breaks once we try to generate C-like debug info for
it because dwarf2out doesn't expect such sharing to occur (and I
wouldn't be surprised of other odd behavior elsewhere that simply
doesn't manifest in a as fatal way as PR86321).
We generate C-like debug info when you use LTO and -g0 at compile-time
and -g at link-time (that's the way targets w/o debug-copy implementation
end up wired). For non-LTO we avoid directly generating debug for
the array descriptor types by detecting them via a langhook.
The solution seems to be to adhere to the invariant that TYPE_FIELDs
(and thus FIELD_DECL) sharing is only valid between variant types
and their main variant. Thus, copy the chain.
Bootstrap / regtest pending on x86_64-unknown-linux-gnu.
I suppose verify_type () could check proper ownership of the
FIELD_DECLs (simply verify that DECL_CONTEXT is TYPE_MAIN_VARIANT).
But I guess this may break in different ways. Honza - did you
originally try to verify that? It currently says
for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld))
{
/* TODO: verify properties of decls. */
if (TREE_CODE (fld) == FIELD_DECL)
;
...
OK for trunk?
Thanks,
Richard.
2018-06-28 Richard Biener <rguenther@suse.de>
fortran/
PR lto/86321
* trans-types.c (gfc_get_array_type_bounds): Unshare TYPE_FIELDs
for the distinct type copy.
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c (revision 262132)
+++ gcc/fortran/trans-types.c (working copy)
@@ -1923,6 +1923,14 @@ gfc_get_array_type_bounds (tree etype, i
base_type = gfc_get_array_descriptor_base (dimen, codimen, restricted);
fat_type = build_distinct_type_copy (base_type);
+ /* Unshare TYPE_FIELDs. */
+ for (tree *tp = &TYPE_FIELDS (fat_type); *tp; tp = &DECL_CHAIN (*tp))
+ {
+ tree next = DECL_CHAIN (*tp);
+ *tp = copy_node (*tp);
+ DECL_CONTEXT (*tp) = fat_type;
+ DECL_CHAIN (*tp) = next;
+ }
/* Make sure that nontarget and target array type have the same canonical
type (and same stub decl for debug info). */
base_type = gfc_get_array_descriptor_base (dimen, codimen, false);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix PR86321
2018-06-29 2:37 [PATCH] Fix PR86321 Richard Biener
@ 2018-06-29 20:08 ` Janne Blomqvist
0 siblings, 0 replies; 3+ messages in thread
From: Janne Blomqvist @ 2018-06-29 20:08 UTC (permalink / raw)
To: Richard Biener; +Cc: GCC Patches, Fortran List, Jakub Jelinek
On Thu, Jun 28, 2018 at 12:16 PM, Richard Biener <rguenther@suse.de> wrote:
>
> The fortran FE creates array descriptor types via build_distinct_type_copy
> which ends up re-using the TYPE_FIELDs chain of FIELD_DECLs between
> types in different type-variant chains. While that seems harmless
> in practice it breaks once we try to generate C-like debug info for
> it because dwarf2out doesn't expect such sharing to occur (and I
> wouldn't be surprised of other odd behavior elsewhere that simply
> doesn't manifest in a as fatal way as PR86321).
>
> We generate C-like debug info when you use LTO and -g0 at compile-time
> and -g at link-time (that's the way targets w/o debug-copy implementation
> end up wired). For non-LTO we avoid directly generating debug for
> the array descriptor types by detecting them via a langhook.
>
> The solution seems to be to adhere to the invariant that TYPE_FIELDs
> (and thus FIELD_DECL) sharing is only valid between variant types
> and their main variant. Thus, copy the chain.
>
> Bootstrap / regtest pending on x86_64-unknown-linux-gnu.
>
> I suppose verify_type () could check proper ownership of the
> FIELD_DECLs (simply verify that DECL_CONTEXT is TYPE_MAIN_VARIANT).
> But I guess this may break in different ways. Honza - did you
> originally try to verify that? It currently says
>
> for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld))
> {
> /* TODO: verify properties of decls. */
> if (TREE_CODE (fld) == FIELD_DECL)
> ;
> ...
>
> OK for trunk?
>
Ok, thanks for the patch, and to Dominique for testing!
--
Janne Blomqvist
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix PR86321
@ 2018-06-29 18:45 Dominique d'Humières
0 siblings, 0 replies; 3+ messages in thread
From: Dominique d'Humières @ 2018-06-29 18:45 UTC (permalink / raw)
To: Richard Biener; +Cc: gfortran, gcc-patches
The patch fixes PR86321 without regression.
Thanks,
Dominique
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-29 18:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-29 2:37 [PATCH] Fix PR86321 Richard Biener
2018-06-29 20:08 ` Janne Blomqvist
2018-06-29 18:45 Dominique d'Humières
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).