[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-28 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

--- Comment #9 from CVS Commits  ---
The master branch has been updated by Sergei Trofimovich :

https://gcc.gnu.org/g:cbf10ac51c0b889e930f260a3d1fb601332befdf

commit r11-2391-gcbf10ac51c0b889e930f260a3d1fb601332befdf
Author: Sergei Trofimovich 
Date:   Sat Jul 25 19:26:50 2020 +0100

ipa/96291: don't crash on unoptimized lto functions

In PR ipa/96291 the test contained an SCC with one
unoptimized function. This tricked ipa-cp into NULL dereference.

has_undead_caller_from_outside_scc_p() did not take into account
that unoptimized funtions don't have IPA summary analysis. And
dereferenced NULL pointer causing an ICE.

gcc/
PR ipa/96291
* ipa-cp.c (has_undead_caller_from_outside_scc_p): Consider
unoptimized callers as undead.

gcc/testsuite/
PR ipa/96291
* gcc.dg/lto/pr96291_0.c: New testcase.
* gcc.dg/lto/pr96291_1.c: Support file.
* gcc.dg/lto/pr96291_2.c: Likewise.
* gcc.dg/lto/pr96291.h: Likewise.

[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-27 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

Martin Jambor  changed:

   What|Removed |Added

   Assignee|jamborm at gcc dot gnu.org |slyfox at inbox dot ru

--- Comment #8 from Martin Jambor  ---
Sergei's patch is correct (I just suggested to write the condition
differently).

[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-25 Thread slyfox at inbox dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

--- Comment #7 from Sergei Trofimovich  ---
(In reply to Sergei Trofimovich from comment #6)
> -fdump-ipa-all-all generates sdb.wpa.076i.cp that says f() has no jump
> functions:
> ...
> Is it expected?

print_all_lattices() suggests it is expected for unoptimized cases to have no
IPA info:

"""
  info = IPA_NODE_REF (node);
  /* Skip unoptimized functions and constprop clones since we don't make
 lattices for them.  */
  if (!info || info->ipcp_orig_node)
continue;
"""

The crash happens when analysing a()->e() edge. But a() was compiled with -flto
-O0 and thus has no IPA fnsummary.

Proposed patch: https://gcc.gnu.org/pipermail/gcc-patches/2020-July/550667.html

[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-25 Thread slyfox at inbox dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

--- Comment #6 from Sergei Trofimovich  ---
-fdump-ipa-all-all generates sdb.wpa.076i.cp that says f() has no jump
functions:

"""
Jump functions:
  Jump functions of caller  main/9:
  Jump functions of caller  a/8:
callsite  a/8 -> e/2 :
   no arg info
  Jump functions of caller  f/6:
  Jump functions of caller  e/2:
callsite  e/2 -> c/1 :
   param 0: CONST: 0
 value: 0x0, mask: 0x0
 Unknown VR
  Jump functions of caller  c/1:
callsite  c/1 -> a/8 :
   param 0: UNKNOWN
 value: 0x0, mask: 0x
 Unknown VR
   param 1: UNKNOWN
 value: 0x0, mask: 0x
 Unknown VR
callsite  c/1 -> f/6 :
   no arg info
"""

Is it expected?

[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-25 Thread slyfox at inbox dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

--- Comment #5 from Sergei Trofimovich  ---
I shrunk example to "single-file" (almost) example to ease local tweaking:

$ cat 1file.c
  void e(void);
  void f(void);
  void a(int, int);
  void c(int);
  #ifdef COMPILE_F1
  int b;
  void c(int d) {
f();
a(b, 0);
  }
  void e(void) { c(0); }
  #endif
  #ifdef COMPILE_F2
  void f(void) { c(0); }
  #endif
  #ifdef COMPILE_F3
  void a(int a1, int a2) { e(); }
  #endif

$ x86_64-pc-linux-gnu-gcc -c -O2 -flto -o f1.o 1file.c -DCOMPILE_F1
$ x86_64-pc-linux-gnu-gcc -c -O2 -flto -o f2.o 1file.c -DCOMPILE_F2
$ x86_64-pc-linux-gnu-gcc -c -O2 -flto -O0 -o f3.o 1file.c -DCOMPILE_F3
$ x86_64-pc-linux-gnu-gcc -O2 -flto -o sdb f1.o f2.o f3.o
during IPA pass: cp
lto1: internal compiler error: Segmentation fault

[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-24 Thread slyfox at inbox dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

--- Comment #4 from Sergei Trofimovich  ---
Peeking at the crash:
"""
Program received signal SIGSEGV, Segmentation fault.
0x01ca0fed in has_undead_caller_from_outside_scc_p
(node=0x77670438, data=0x0) at ../../gcc/gcc/ipa-cp.c:5670
5670 && !IPA_NODE_REF (cs->caller)->node_dead)
(gdb) list
5665if (cs->caller->thunk.thunk_p
5666&& cs->caller->call_for_symbol_thunks_and_aliases
5667  (has_undead_caller_from_outside_scc_p, NULL, true))
5668  return true;
5669else if (!ipa_edge_within_scc (cs)
5670 && !IPA_NODE_REF (cs->caller)->node_dead)
5671  return true;
5672  return false;
5673}
5674

(gdb) print IPA_NODE_REF(cs->caller)
$1 = (ipa_node_params *) 0x0
"""

Is it an expected invariant? Looks like most of code does not expect NULL
there:

$ git grep IPA_NODE_REF | fgrep NULL
gcc/ipa-prop.c:   && IPA_NODE_REF (node) != NULL)
gcc/ipa-prop.c:   && IPA_NODE_REF (node) != NULL)

[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-24 Thread romain.geissler at amadeus dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

Romain Geissler  changed:

   What|Removed |Added

 CC||romain.geissler at amadeus dot 
com

--- Comment #3 from Romain Geissler  ---
Hi,

FYI, I just tried to build Protobuf 3.12.3 with the trunk from a few days ago,
using "-flto" and I experience similar ICE:

[2020-07-24T12:16:07.637Z]   CXXLDprotobuf-lite-test
[2020-07-24T12:16:10.993Z] during IPA pass: cp
[2020-07-24T12:16:10.993Z] lto1: internal compiler error: Segmentation fault
[2020-07-24T12:16:15.263Z] 0x9e42da crash_signal
[2020-07-24T12:16:15.263Z]  /workdir/src/gcc-11.0.0/gcc/toplev.c:328
[2020-07-24T12:16:15.263Z] 0xfe6b04 has_undead_caller_from_outside_scc_p
[2020-07-24T12:16:15.263Z]  /workdir/src/gcc-11.0.0/gcc/ipa-cp.c:5670
[2020-07-24T12:16:15.263Z] 0xf042c0
cgraph_node::call_for_symbol_thunks_and_aliases(bool (*)(cgraph_node*, void*),
void*, bool, bool)
[2020-07-24T12:16:15.263Z]  /workdir/src/gcc-11.0.0/gcc/cgraph.c:2450
[2020-07-24T12:16:15.263Z] 0x13130bc identify_dead_nodes
[2020-07-24T12:16:15.263Z]  /workdir/src/gcc-11.0.0/gcc/ipa-cp.c:5687
[2020-07-24T12:16:15.263Z] 0x13130bc ipcp_decision_stage
[2020-07-24T12:16:15.263Z]  /workdir/src/gcc-11.0.0/gcc/ipa-cp.c:5730
[2020-07-24T12:16:15.263Z] 0x13130bc ipcp_driver
[2020-07-24T12:16:15.263Z]  /workdir/src/gcc-11.0.0/gcc/ipa-cp.c:5908
[2020-07-24T12:16:15.263Z] 0x13130bc execute
[2020-07-24T12:16:15.263Z]  /workdir/src/gcc-11.0.0/gcc/ipa-cp.c:5999
[2020-07-24T12:16:15.263Z] Please submit a full bug report,
[2020-07-24T12:16:15.263Z] with preprocessed source if appropriate.
[2020-07-24T12:16:15.263Z] Please include the complete backtrace with any bug
report.
[2020-07-24T12:16:15.263Z] See  for instructions.
[2020-07-24T12:16:15.263Z]   CXXLDprotobuf-lite-arena-test
[2020-07-24T12:16:15.263Z] lto-wrapper: fatal error: g++ returned 1 exit status
[2020-07-24T12:16:15.263Z] compilation terminated.

If you have a patch, I can try to test it as well on this Protobuf case.

Cheers,
Romain

[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-23 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

Martin Jambor  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jamborm at gcc dot 
gnu.org

--- Comment #2 from Martin Jambor  ---
I guess I should take a look

[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-23 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

Martin Liška  changed:

   What|Removed |Added

   Last reconfirmed||2020-07-23
 CC||hubicka at gcc dot gnu.org
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW

--- Comment #1 from Martin Liška  ---
Confirmed. With checking enabled WPA is stuck staging from:

  r8-1894-g29f1e2b173f1701b(07 Jul 2017 13:28)(hubi...@ucw.cz): [took: 1.445s]
result: FAILED (124)
ipa-comdats.c: Remove optimize check from gate.


* ipa-comdats.c: Remove optimize check from gate.
* ipa-fnsummary.c (ipa_fn_summary_generate): do not generate summary
for functions not optimized.
(ipa_fn_summary_read): Skip optimize check.
(ipa_fn_summary_write): Likewise.
* ipa-inline-analysis.c (do_estimate_growth_1): Check that caller
is optimized.
* ipa-inline.c (can_inline_edge_p): Not optimized functions are
uninlinable.
(can_inline_edge_p): Check flag_pcc_struct_return for match.
(check_callers): Give up on caller which is not optimized.
(inline_small_functions): Likewise.
(ipa_inline): Do not give up when not optimizing.
* ipa-visbility.c (function_and_variable_visibility): Do not optimize
away unoptimizes cdtors.
(whole_program_function_and_variable_visibility): Do
ipa_discover_readonly_nonaddressable_vars in LTO mode.
* ipa.c (process_references): Do not check optimize.
(symbol_table::remove_unreachable_nodes): Update optimize check.
(set_writeonly_bit): Update optimize check.
(pass_ipa_cdtor_merge::gate): Do not check optimize.
(pass_ipa_single_use::gate): Remove.

[Bug ipa/96291] [10/11 Regression] -flto fails as "internal compiler error: Segmentation fault" during IPA pass: cp incall_for_symbol_thunks_and_aliases()

2020-07-23 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

Richard Biener  changed:

   What|Removed |Added

 CC||jamborm at gcc dot gnu.org
   Target Milestone|--- |10.3
Summary|-flto fails as "internal|[10/11 Regression] -flto
   |compiler error: |fails as "internal compiler
   |Segmentation fault" during  |error: Segmentation fault"
   |IPA pass: cp|during IPA pass: cp
   |incall_for_symbol_thunks_an |incall_for_symbol_thunks_an
   |d_aliases() |d_aliases()