public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/55113] ICE with LTO and -fshort-double
Date: Thu, 27 Feb 2014 08:58:00 -0000	[thread overview]
Message-ID: <bug-55113-4-SBLGnd9pVN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55113-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55113

--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to pmatos from comment #13)
> (In reply to Richard Biener from comment #11)
> > If double_type_node is FE dependent then it needs treatment in
> > tree-streamer.c:preload_common_nodes:
> > 
> > static void
> > preload_common_nodes (struct streamer_tree_cache_d *cache)
> > {
> >   unsigned i;
> > 
> >   for (i = 0; i < itk_none; i++)
> >     /* Skip itk_char.  char_type_node is dependent on -f[un]signed-char.  */
> >     if (i != itk_char)
> >       record_common_node (cache, integer_types[i]);
> > 
> >   for (i = 0; i < stk_type_kind_last; i++)
> >     record_common_node (cache, sizetype_tab[i]);
> > 
> >   for (i = 0; i < TI_MAX; i++)
> >     /* Skip boolean type and constants, they are frontend dependent.  */
> >     if (i != TI_BOOLEAN_TYPE
> >         && i != TI_BOOLEAN_FALSE
> >         && i != TI_BOOLEAN_TRUE)
> >       record_common_node (cache, global_trees[i]);
> > }
> 
> Richard,
> I tried what you suggested but led me nowhere. In the meantime I noticed
> that -fshort-double shows up in COLLECT_GCC_OPTIONS before collect2 is
> called:
> 
> COLLECT_GCC_OPTIONS='-fshort-double' '-flto' '-nostdlib' '-o' 'test'
> '-save-temps' '-v' '-da' '-fdump-tree-all-all' '-mcpu=8540'
>  /home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-
> eabispe/4.8.3/collect2 -plugin
> /home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-
> eabispe/4.8.3/liblto_plugin.so
> -plugin-opt=/home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/
> powerpc-eabispe/4.8.3/lto-wrapper -plugin-opt=-fresolution=pr55113.res -flto
> --sysroot=/home/pmatos/work/pr55113/top-4_8/toolchain/prex_sysroot
> --eh-frame-hdr -V -dn -Bstatic -o test
> -L/home/pmatos/work/pr55113/top-4_8/toolchain/install/lib/gcc/powerpc-
> eabispe/4.8.3
> -L/home/pmatos/work/pr55113/top-4_8/toolchain/install/lib/gcc/powerpc-
> eabispe/4.8.3/../../../../powerpc-eabispe/lib pr55113.o
> 
> but not after when lto1 is called:
> COLLECT_GCC_OPTIONS='-c' '-mcpu=8540' '-nostdlib' '-save-temps' '-v' '-da'
> '-fdump-tree-all-all' '-mcpu=8540' '-dumpdir' './' '-dumpbase' 'test.wpa'
> '-fltrans-output-list=test.ltrans.out' '-fwpa' '-fresolution=pr55113.res'
>  /home/pmatos/work/pr55113/top-4_8/toolchain/install/libexec/gcc/powerpc-
> eabispe/4.8.3/lto1 -quiet -da -dumpdir ./ -dumpbase test.wpa -mcpu=8540
> -mcpu=8540 -auxbase pr55113 -version -fdump-tree-all-all
> -fltrans-output-list=test.ltrans.out -fwpa -fresolution=pr55113.res
> @/tmp/ccW7YQPl
> 
> Somewhere along the line the option is lost. It seems to be that only some
> options are kept and optimization options are lost, like fshort-double.

-fshort-double is a C frontend family option and thus not generally available
(you can add LTO to the list of FEs that support it).

> However, in lto/lto-lang.c:lto_init you have:
>   /* Create the basic integer types.  */
>   build_common_tree_nodes (flag_signed_char, /*short_double=*/false);
> 
> This hardcodes short double to false. If I were to hardcode this to true,
> Patricks example would work.
> 
> I think similarly to what we do in c-family/c-common.c:
>   build_common_tree_nodes (flag_signed_char, flag_short_double);
> 
> we need to pass flag_short_double but the only way to do so is by letting
> fshort-double pass through the flag filtering that goes on before lto1 is
> called.

Yes, see above - this will fix the immediate issue.  Of course it won't
fix things if you have mismatched -fshort-double options in TUs or
in compile vs. link-time.  For this was my original suggestion - do not
stream double_type_node but stream the type literally.

Index: tree-streamer.c
===================================================================
--- tree-streamer.c     (revision 208066)
+++ tree-streamer.c     (working copy)
@@ -264,7 +264,8 @@

   gcc_checking_assert (node != boolean_type_node
                       && node != boolean_true_node
-                      && node != boolean_false_node);
+                      && node != boolean_false_node
+                      && node != double_type_node);

   /* We have to make sure to fill exactly the same number of
      elements for all frontends.  That can include NULL trees.
@@ -318,7 +319,10 @@
     /* Skip boolean type and constants, they are frontend dependent.  */
     if (i != TI_BOOLEAN_TYPE
        && i != TI_BOOLEAN_FALSE
-       && i != TI_BOOLEAN_TRUE)
+       && i != TI_BOOLEAN_TRUE
+       && i != TI_DOUBLE_TYPE
+       && i != TI_COMPLEX_DOUBLE_TYPE
+       && i != TI_DOUBLE_PTR_TYPE)
       record_common_node (cache, global_trees[i]);
 }

This should fix both errors - not passing on -fshort-double _and_ mixing
-f[no-]short-double.

Well.  At least to my theory (didn't try).

> I will prepare a patch to add this exception, let me know if you think
> there's a better way.

See above - if that works I'd prefer that.


  parent reply	other threads:[~2014-02-27  8:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-28 22:26 [Bug lto/55113] New: internal compiler error: in emit_library_call_value_1, at calls.c:3739 patrick at motec dot com.au
2012-10-28 23:27 ` [Bug lto/55113] " pinskia at gcc dot gnu.org
2012-10-29 14:49 ` rguenth at gcc dot gnu.org
2012-11-21  2:34 ` patrick at motec dot com.au
2012-11-21  3:06 ` patrick at motec dot com.au
2012-11-21  3:11 ` patrick at motec dot com.au
2012-11-21  3:12 ` patrick at motec dot com.au
2013-03-25  5:42 ` patrick at motec dot com.au
2013-06-05 22:17 ` [Bug lto/55113] ICE in emit_library_call_value_1, at calls.c:3757 patrick at motec dot com.au
2013-06-05 22:19 ` patrick at motec dot com.au
2014-01-20  9:34 ` [Bug lto/55113] ICE with LTO and -fshort-double rguenth at gcc dot gnu.org
2014-02-26 21:03 ` pmatos at gcc dot gnu.org
2014-02-27  8:58 ` rguenth at gcc dot gnu.org [this message]
2014-02-27  9:22 ` pmatos at gcc dot gnu.org
2014-02-28 10:17 ` pmatos at gcc dot gnu.org
2014-03-02 20:14 ` pmatos at gcc dot gnu.org
2014-03-04 11:51 ` pmatos at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-55113-4-SBLGnd9pVN@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).