[Bug lto/55113] ICE with LTO and -fshort-double
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 27 08:58:00 GMT 2014
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.
More information about the Gcc-bugs
mailing list