diff mbox

Fix streaming of target optimization/option nodes

Message ID 20141215223611.GE6931@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka Dec. 15, 2014, 10:36 p.m. UTC
Hi,
this is final version I comitted.  20110201-1_0.c actually tests that we
optimize cabs on function copmiled with -O0 that is no longer supposed to
happen.

Honza

	PR lto/64043
	* gcc.dg/lto/20110201-1_0.c: New testcase.

	* tree-streamer.c (preload_common_nodes): Skip preloading
	of main_identifier_node, pid_type and optimization/option nodes.

Comments

Thomas Schwinge Dec. 22, 2014, 11:02 a.m. UTC | #1
Hi!

On Mon, 15 Dec 2014 23:36:11 +0100, Jan Hubicka <hubicka@ucw.cz> wrote:
> this is final version I comitted.

> 	PR lto/64043

> 	* tree-streamer.c (preload_common_nodes): Skip preloading
> 	of main_identifier_node, pid_type and optimization/option nodes.

> --- tree-streamer.c	(revision 218726)
> +++ tree-streamer.c	(working copy)
> @@ -324,7 +324,18 @@ preload_common_nodes (struct streamer_tr
>      /* 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
> +	/* MAIN_IDENTIFIER is not always initialized by Fortran FE.  */
> +	&& i != TI_MAIN_IDENTIFIER
> +	/* PID_TYPE is initialized only by C family front-ends.  */
> +	&& i != TI_PID_TYPE
> +	/* Skip optimization and target option nodes; they depend on flags.  */
> +	&& i != TI_OPTIMIZATION_DEFAULT
> +	&& i != TI_OPTIMIZATION_CURRENT
> +	&& i != TI_TARGET_OPTION_DEFAULT
> +	&& i != TI_TARGET_OPTION_CURRENT
> +	&& i != TI_CURRENT_TARGET_PRAGMA
> +	&& i != TI_CURRENT_OPTIMIZE_PRAGMA)
>        record_common_node (cache, global_trees[i]);
>  }

This regresses offloading (tested Intel MIC emulation):

    FAIL: libgomp.c/examples-4/e.53.5.c (internal compiler error)
    FAIL: libgomp.c/for-3.c (internal compiler error)
    FAIL: libgomp.c++/for-11.C (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O2  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O3 -fomit-frame-pointer  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O3 -fomit-frame-pointer -funroll-loops  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O3 -g  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.3.f90   -Os  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.4.f90   -O2  (test for excess errors)
    FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O0  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O1  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O2  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O3 -fomit-frame-pointer  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O3 -fomit-frame-pointer -funroll-loops  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O3 -g  (internal compiler error)
    FAIL: libgomp.fortran/examples-4/e.53.5.f90   -Os  (internal compiler error)

    FAIL: libgomp.c/examples-4/e.53.5.c (internal compiler error)

    [...]/source-gcc/libgomp/testsuite/libgomp.c/examples-4/e.53.5.c: In function 'accum._omp_fn.1':
    [...]/source-gcc/libgomp/testsuite/libgomp.c/examples-4/e.53.5.c:53:13: error: unrecognizable insn:
         #pragma omp parallel for reduction(+:tmp)
                 ^
    (insn 176 66 177 4 (set (reg:DI 0 ax)
            (symbol_ref:DI ("Q") <var_decl 0x2ad2db659900 Q>)) -1
         (nil))
    [...]/source-gcc/libgomp/testsuite/libgomp.c/examples-4/e.53.5.c:53:13: internal compiler error: in extract_insn, at recog.c:2327
    0x9c124a _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
            [...]/source-gcc/gcc/rtl-error.c:110
    0x9c1279 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
            [...]/source-gcc/gcc/rtl-error.c:118
    0x98f346 extract_insn(rtx_insn*)
            [...]/source-gcc/gcc/recog.c:2327
    0x9902c8 extract_constrain_insn(rtx_insn*)
            [...]/source-gcc/gcc/recog.c:2228
    0x998a16 copyprop_hardreg_forward_1
            [...]/source-gcc/gcc/regcprop.c:773
    0x99978a execute
            [...]/source-gcc/gcc/regcprop.c:1279

    FAIL: libgomp.c/for-3.c (internal compiler error)

    [...]/source-gcc/libgomp/testsuite/libgomp.c/for-2.h: In function 'f13_d_normal':
    [...]/source-gcc/libgomp/testsuite/libgomp.c/for-2.h:171:1: error: unrecognizable insn:
     }
     ^
    (insn 73 72 55 5 (set (reg/f:DI 1 dx [orig:106 D.6870 ] [106])
            (plus:DI (reg:DI 0 ax [orig:105 D.6869 ] [105])
                (symbol_ref:DI ("a") <var_decl 0x2b249985d900 a>))) -1
         (nil))
    [...]/source-gcc/libgomp/testsuite/libgomp.c/for-2.h:171:1: internal compiler error: in extract_insn, at recog.c:2327
    0x9c124a _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
            [...]/source-gcc/gcc/rtl-error.c:110
    0x9c1279 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
            [...]/source-gcc/gcc/rtl-error.c:118
    0x98f346 extract_insn(rtx_insn*)
            [...]/source-gcc/gcc/recog.c:2327
    0x98f3c4 extract_insn_cached(rtx_insn*)
            [...]/source-gcc/gcc/recog.c:2218
    0x749cdd cleanup_subreg_operands(rtx_insn*)
            [...]/source-gcc/gcc/final.c:3124
    0x98caf7 split_insn
            [...]/source-gcc/gcc/recog.c:2937
    0x991657 split_all_insns()
            [...]/source-gcc/gcc/recog.c:2991
    0x9916d8 rest_of_handle_split_after_reload
            [...]/source-gcc/gcc/recog.c:3938
    0x9916d8 execute
            [...]/source-gcc/gcc/recog.c:3967

Etc.


There also are related issues still open:
<http://news.gmane.org/find-root.php?message_id=%3C546DDE1C.6060203%40t-online.de%3E>,
<http://news.gmane.org/find-root.php?message_id=%3C543D0DAE.1050500%40codesourcery.com%3E>.


Grüße,
 Thomas
H.J. Lu Jan. 5, 2015, 4:59 p.m. UTC | #2
On Mon, Dec 22, 2014 at 3:02 AM, Thomas Schwinge
<thomas@codesourcery.com> wrote:
> Hi!
>
> On Mon, 15 Dec 2014 23:36:11 +0100, Jan Hubicka <hubicka@ucw.cz> wrote:
>> this is final version I comitted.
>
>>       PR lto/64043
>
>>       * tree-streamer.c (preload_common_nodes): Skip preloading
>>       of main_identifier_node, pid_type and optimization/option nodes.
>

>
> This regresses offloading (tested Intel MIC emulation):
>
>     FAIL: libgomp.c/examples-4/e.53.5.c (internal compiler error)
>     FAIL: libgomp.c/for-3.c (internal compiler error)
>     FAIL: libgomp.c++/for-11.C (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O2  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O3 -fomit-frame-pointer  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O3 -fomit-frame-pointer -funroll-loops  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.3.f90   -O3 -g  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.3.f90   -Os  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.4.f90   -O2  (test for excess errors)
>     FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O0  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O1  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O2  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O3 -fomit-frame-pointer  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O3 -fomit-frame-pointer -funroll-loops  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.5.f90   -O3 -g  (internal compiler error)
>     FAIL: libgomp.fortran/examples-4/e.53.5.f90   -Os  (internal compiler error)
>
>     FAIL: libgomp.c/examples-4/e.53.5.c (internal compiler error)
>
>     [...]/source-gcc/libgomp/testsuite/libgomp.c/examples-4/e.53.5.c: In function 'accum._omp_fn.1':
>     [...]/source-gcc/libgomp/testsuite/libgomp.c/examples-4/e.53.5.c:53:13: error: unrecognizable insn:
>          #pragma omp parallel for reduction(+:tmp)
>                  ^
>     (insn 176 66 177 4 (set (reg:DI 0 ax)
>             (symbol_ref:DI ("Q") <var_decl 0x2ad2db659900 Q>)) -1
>          (nil))
>     [...]/source-gcc/libgomp/testsuite/libgomp.c/examples-4/e.53.5.c:53:13: internal compiler error: in extract_insn, at recog.c:2327
>     0x9c124a _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
>             [...]/source-gcc/gcc/rtl-error.c:110
>     0x9c1279 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
>             [...]/source-gcc/gcc/rtl-error.c:118
>     0x98f346 extract_insn(rtx_insn*)
>             [...]/source-gcc/gcc/recog.c:2327
>     0x9902c8 extract_constrain_insn(rtx_insn*)
>             [...]/source-gcc/gcc/recog.c:2228
>     0x998a16 copyprop_hardreg_forward_1
>             [...]/source-gcc/gcc/regcprop.c:773
>     0x99978a execute
>             [...]/source-gcc/gcc/regcprop.c:1279
>
>     FAIL: libgomp.c/for-3.c (internal compiler error)
>
>     [...]/source-gcc/libgomp/testsuite/libgomp.c/for-2.h: In function 'f13_d_normal':
>     [...]/source-gcc/libgomp/testsuite/libgomp.c/for-2.h:171:1: error: unrecognizable insn:
>      }
>      ^
>     (insn 73 72 55 5 (set (reg/f:DI 1 dx [orig:106 D.6870 ] [106])
>             (plus:DI (reg:DI 0 ax [orig:105 D.6869 ] [105])
>                 (symbol_ref:DI ("a") <var_decl 0x2b249985d900 a>))) -1
>          (nil))
>     [...]/source-gcc/libgomp/testsuite/libgomp.c/for-2.h:171:1: internal compiler error: in extract_insn, at recog.c:2327
>     0x9c124a _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
>             [...]/source-gcc/gcc/rtl-error.c:110
>     0x9c1279 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
>             [...]/source-gcc/gcc/rtl-error.c:118
>     0x98f346 extract_insn(rtx_insn*)
>             [...]/source-gcc/gcc/recog.c:2327
>     0x98f3c4 extract_insn_cached(rtx_insn*)
>             [...]/source-gcc/gcc/recog.c:2218
>     0x749cdd cleanup_subreg_operands(rtx_insn*)
>             [...]/source-gcc/gcc/final.c:3124
>     0x98caf7 split_insn
>             [...]/source-gcc/gcc/recog.c:2937
>     0x991657 split_all_insns()
>             [...]/source-gcc/gcc/recog.c:2991
>     0x9916d8 rest_of_handle_split_after_reload
>             [...]/source-gcc/gcc/recog.c:3938
>     0x9916d8 execute
>             [...]/source-gcc/gcc/recog.c:3967
>
> Etc.
>
>
> There also are related issues still open:
> <http://news.gmane.org/find-root.php?message_id=%3C546DDE1C.6060203%40t-online.de%3E>,
> <http://news.gmane.org/find-root.php?message_id=%3C543D0DAE.1050500%40codesourcery.com%3E>.
>

It also caused:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64415
diff mbox

Patch

Index: testsuite/gcc.dg/lto/20110201-1_0.c
===================================================================
--- testsuite/gcc.dg/lto/20110201-1_0.c	(revision 218726)
+++ testsuite/gcc.dg/lto/20110201-1_0.c	(working copy)
@@ -1,6 +1,5 @@ 
 /* { dg-lto-do run } */
 /* { dg-lto-options { { -O0 -flto } } } */
-/* { dg-extra-ld-options "-O2 -ffast-math -fuse-linker-plugin" } */
 /* { dg-require-linker-plugin "" } */
 
 /* We require a linker plugin because otherwise we'd need to link
@@ -9,7 +8,7 @@ 
    which does not have folded cabs.  */
 
 double cabs(_Complex double);
-double __attribute__((used))
+double __attribute__((used)) __attribute__ ((optimize ("O2,fast-math")))
 foo (_Complex double x, int b)
 {
   if (b)
Index: tree-streamer.c
===================================================================
--- tree-streamer.c	(revision 218726)
+++ tree-streamer.c	(working copy)
@@ -324,7 +324,18 @@  preload_common_nodes (struct streamer_tr
     /* 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
+	/* MAIN_IDENTIFIER is not always initialized by Fortran FE.  */
+	&& i != TI_MAIN_IDENTIFIER
+	/* PID_TYPE is initialized only by C family front-ends.  */
+	&& i != TI_PID_TYPE
+	/* Skip optimization and target option nodes; they depend on flags.  */
+	&& i != TI_OPTIMIZATION_DEFAULT
+	&& i != TI_OPTIMIZATION_CURRENT
+	&& i != TI_TARGET_OPTION_DEFAULT
+	&& i != TI_TARGET_OPTION_CURRENT
+	&& i != TI_CURRENT_TARGET_PRAGMA
+	&& i != TI_CURRENT_OPTIMIZE_PRAGMA)
       record_common_node (cache, global_trees[i]);
 }