Bug 59199 - [4.9 Regression] r205032 caused LTO bootstrap to fail with bootstrap-profile
Summary: [4.9 Regression] r205032 caused LTO bootstrap to fail with bootstrap-profile
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: 4.9.0
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-20 03:16 UTC by H.J. Lu
Modified: 2013-12-02 15:15 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-11-29 00:00:00


Attachments
A patch (978 bytes, patch)
2013-11-27 21:13 UTC, H.J. Lu
Details | Diff
fixed patch (404 bytes, patch)
2013-12-02 10:04 UTC, Richard Biener
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2013-11-20 03:16:39 UTC
On Linux/x86, r205032 caused LTO bootstrap to fail with bootstrap-profile:

Existing SSA name for symbol marked for renaming: aloop_37
In member function \u2018__base_ctor \u2019:
lto1: internal compiler error: SSA corruption
0xcd84eb update_ssa(unsigned int)
	/export/project/git/gcc-regression/gcc/gcc/tree-into-ssa.c:3246
0xa5814c input_function
	/export/project/git/gcc-regression/gcc/gcc/lto-streamer-in.c:1006
0xa5814c lto_read_body
	/export/project/git/gcc-regression/gcc/gcc/lto-streamer-in.c:1070
0xa5814c lto_input_function_body(lto_file_decl_data*, cgraph_node*, char const*)
	/export/project/git/gcc-regression/gcc/gcc/lto-streamer-in.c:1112
0x66d2bc cgraph_get_body(cgraph_node*)
	/export/project/git/gcc-regression/gcc/gcc/cgraph.c:2981
0x99aa58 ipa_merge_profiles(cgraph_node*, cgraph_node*)
	/export/project/git/gcc-regression/gcc/gcc/ipa-utils.c:699
0x595a86 lto_cgraph_replace_node
	/export/project/git/gcc-regression/gcc/gcc/lto/lto-symtab.c:82
0x596159 lto_symtab_merge_symbols_1
	/export/project/git/gcc-regression/gcc/gcc/lto/lto-symtab.c:561
0x596159 lto_symtab_merge_symbols()
	/export/project/git/gcc-regression/gcc/gcc/lto/lto-symtab.c:589
0x5850dd read_cgraph_and_symbols
	/export/project/git/gcc-regression/gcc/gcc/lto/lto.c:2946
0x5850dd lto_main()
	/export/project/git/gcc-regression/gcc/gcc/lto/lto.c:3255
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /export/project/git/gcc-regression-bootstrap/master/205032/bld/./prev-gcc/xg++ returned 1 exit status
/usr/local/x86_64-unknown-linux-gnu/bin/ld: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [lto1] Error 1
make[3]: *** Waiting for unfinished jobs....
Existing SSA name for symbol marked for renaming: aloop_37
In member function \u2018__base_ctor \u2019:
lto1: internal compiler error: SSA corruption
0xcd84eb update_ssa(unsigned int)
	/export/project/git/gcc-regression/gcc/gcc/tree-into-ssa.c:3246
0xa5814c input_function
	/export/project/git/gcc-regression/gcc/gcc/lto-streamer-in.c:1006
0xa5814c lto_read_body
	/export/project/git/gcc-regression/gcc/gcc/lto-streamer-in.c:1070
0xa5814c lto_input_function_body(lto_file_decl_data*, cgraph_node*, char const*)
	/export/project/git/gcc-regression/gcc/gcc/lto-streamer-in.c:1112
0x66d2bc cgraph_get_body(cgraph_node*)
	/export/project/git/gcc-regression/gcc/gcc/cgraph.c:2981
0x99aa58 ipa_merge_profiles(cgraph_node*, cgraph_node*)
	/export/project/git/gcc-regression/gcc/gcc/ipa-utils.c:699
0x595a86 lto_cgraph_replace_node
	/export/project/git/gcc-regression/gcc/gcc/lto/lto-symtab.c:82
0x596159 lto_symtab_merge_symbols_1
	/export/project/git/gcc-regression/gcc/gcc/lto/lto-symtab.c:561
0x596159 lto_symtab_merge_symbols()
	/export/project/git/gcc-regression/gcc/gcc/lto/lto-symtab.c:589
0x5850dd read_cgraph_and_symbols
	/export/project/git/gcc-regression/gcc/gcc/lto/lto.c:2946
0x5850dd lto_main()
	/export/project/git/gcc-regression/gcc/gcc/lto/lto.c:3255
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /export/project/git/gcc-regression-bootstrap/master/205032/bld/./prev-gcc/xg++ returned 1 exit status
/usr/local/x86_64-unknown-linux-gnu/bin/ld: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [cc1] Error 1
Existing SSA name for symbol marked for renaming: aloop_37
In member function \u2018__base_ctor \u2019:
lto1: internal compiler error: SSA corruption
0xcd84eb update_ssa(unsigned int)
	/export/project/git/gcc-regression/gcc/gcc/tree-into-ssa.c:3246
0xa5814c input_function
	/export/project/git/gcc-regression/gcc/gcc/lto-streamer-in.c:1006
0xa5814c lto_read_body
	/export/project/git/gcc-regression/gcc/gcc/lto-streamer-in.c:1070
0xa5814c lto_input_function_body(lto_file_decl_data*, cgraph_node*, char const*)
	/export/project/git/gcc-regression/gcc/gcc/lto-streamer-in.c:1112
0x66d2bc cgraph_get_body(cgraph_node*)
	/export/project/git/gcc-regression/gcc/gcc/cgraph.c:2981
0x99aa58 ipa_merge_profiles(cgraph_node*, cgraph_node*)
	/export/project/git/gcc-regression/gcc/gcc/ipa-utils.c:699
0x595a86 lto_cgraph_replace_node
	/export/project/git/gcc-regression/gcc/gcc/lto/lto-symtab.c:82
0x596159 lto_symtab_merge_symbols_1
	/export/project/git/gcc-regression/gcc/gcc/lto/lto-symtab.c:561
0x596159 lto_symtab_merge_symbols()
	/export/project/git/gcc-regression/gcc/gcc/lto/lto-symtab.c:589
0x5850dd read_cgraph_and_symbols
	/export/project/git/gcc-regression/gcc/gcc/lto/lto.c:2946
0x5850dd lto_main()
	/export/project/git/gcc-regression/gcc/gcc/lto/lto.c:3255
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /export/project/git/gcc-regression-bootstrap/master/205032/bld/./prev-gcc/xg++ returned 1 exit status
/usr/local/x86_64-unknown-linux-gnu/bin/ld: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [cc1plus] Error 1
Comment 1 Richard Biener 2013-11-20 10:44:53 UTC
Well, I'd say it can only have exposed it.
Comment 2 H.J. Lu 2013-11-27 21:13:41 UTC
Created attachment 31315 [details]
A patch

I don't know why this patch works.
Comment 3 Richard Biener 2013-11-28 08:45:55 UTC
It probably hides the underlying bug.
Comment 4 Richard Biener 2013-11-29 14:41:27 UTC
Reproduced and debugged somewhat.  We have

# DEBUG = &foo

foo_2 = ...;


that's a no-no and confused the operand scanner to record 'foo' as real
operand during the update_stmt on stream-in.

Likely a update_address_taken bug, eventual fix:

@@ -1329,6 +1336,10 @@ non_rewritable_mem_ref_base (tree ref)
   if (DECL_P (ref))
     return NULL_TREE;
 
+  /* For DEBUG_STMTs we have to look through ADDR_EXPRs.  */
+  if (TREE_CODE (ref) == ADDR_EXPR)
+    ref = TREE_OPERAND (ref, 0);
+
   while (handled_component_p (base))
     base = TREE_OPERAND (base, 0);
Comment 5 H.J. Lu 2013-11-29 16:45:21 UTC
(In reply to Richard Biener from comment #4)
>
> Likely a update_address_taken bug, eventual fix:
> 
> @@ -1329,6 +1336,10 @@ non_rewritable_mem_ref_base (tree ref)
>    if (DECL_P (ref))
>      return NULL_TREE;
>  
> +  /* For DEBUG_STMTs we have to look through ADDR_EXPRs.  */
> +  if (TREE_CODE (ref) == ADDR_EXPR)
> +    ref = TREE_OPERAND (ref, 0);
> +
>    while (handled_component_p (base))
>      base = TREE_OPERAND (base, 0);

I tried it and I still got the same error:
Comment 6 Richard Biener 2013-12-02 09:41:48 UTC
In fact we have the same without LTO ...

  _31 = &aloopD.38206_74->numD.37604;
...
  # DEBUG ptrD.42029 => &aloopD.38206

but checking doesn't catch it.

Which is because get_expr_operands () has an early out on
ADDR_EXPRs which are is_gimple_min_invariant.

In the specific LTO case it doesn't work because decl_address_invariant_p
doesn't return true as DECL_CONTEXT is different from current_function_decl.

We input a non-prevailing function body it seems, which isn't really supported
as we've already munged trees enough to confuse all sorts of predicates.  Why
do we need stmts at all here?  Isn't it enough to input the CFG?

Honza?
Comment 7 Richard Biener 2013-12-02 10:04:00 UTC
Created attachment 31347 [details]
fixed patch

In testing.
Comment 8 H.J. Lu 2013-12-02 13:07:21 UTC
(In reply to Richard Biener from comment #7)
> Created attachment 31347 [details]
> fixed patch
> 
> In testing.

It doesn't work for me:

0xdbb0f6 tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)
        /export/gnu/import/git/gcc/gcc/tree.c:9362
0x5688df contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*)
        /export/gnu/import/git/gcc/gcc/tree.h:2816
0xd1f96c execute_update_addresses_taken()
        /export/gnu/import/git/gcc/gcc/tree-ssa.c:1659
0xa2c6d1 execute_function_todo
        /export/gnu/import/git/gcc/gcc/passes.c:1824
0xa2ba61 do_per_function
        /export/gnu/import/git/gcc/gcc/passes.c:1573
0xa2c87d execute_todo
        /export/gnu/import/git/gcc/gcc/passes.c:1877
0xa2cda0 execute_one_ipa_transform_pass
        /export/gnu/import/git/gcc/gcc/passes.c:2062
0xa2ce9f execute_all_ipa_transforms()
        /export/gnu/import/git/gcc/gcc/passes.c:2093
0x70fb68 expand_function
        /export/gnu/import/git/gcc/gcc/cgraphunit.c:1756
0x710059 expand_all_functions
        /export/gnu/import/git/gcc/gcc/cgraphunit.c:1868
0x7109b2 compile()
        /export/gnu/import/git/gcc/gcc/cgraphunit.c:2203
0x710b2b finalize_compilation_unit()
        /export/gnu/import/git/gcc/gcc/cgraphunit.c:2280
0x58a688 c_write_global_declarations()
        /export/gnu/import/git/gcc/gcc/c/c-decl.c:10397
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 9 Richard Biener 2013-12-02 15:15:11 UTC
Author: rguenth
Date: Mon Dec  2 15:13:52 2013
New Revision: 205587

URL: http://gcc.gnu.org/viewcvs?rev=205587&root=gcc&view=rev
Log:
2013-12-02  Richard Biener  <rguenther@suse.de>

	* tree-ssa-operands.c (opf_implicit): Remove.
	(opf_address_taken): New flag.
	(get_expr_operands): Remove early out, pass down
	opf_address_taken for ADDR_EXPRs, add a use operand only
	for non-opf_address_taken bases.
	(get_indirect_ref_operands): Rename to ...
	(get_mem_ref_operands): ... this.
	(get_asm_expr_operands): Rename to ...
	(get_asm_stmt_operands): ... this.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-operands.c