[Bug ipa/83506] [8 Regression] ICE: Segmentation fault in force_nonfallthru_and_redirect

2017-12-20 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83506

Jeffrey A. Law  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 CC||law at redhat dot com
 Resolution|--- |FIXED

--- Comment #8 from Jeffrey A. Law  ---
Fixed on the trunk.

[Bug ipa/83506] [8 Regression] ICE: Segmentation fault in force_nonfallthru_and_redirect

2017-12-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83506

--- Comment #7 from Jakub Jelinek  ---
Author: jakub
Date: Wed Dec 20 19:41:38 2017
New Revision: 255901

URL: https://gcc.gnu.org/viewcvs?rev=255901=gcc=rev
Log:
PR ipa/83506
* ipa-fnsummary.c (pass_data_ipa_free_fn_summary): Use 0 for
todo_flags_finish.
(pass_ipa_free_fn_summary): Add small_p private data member,
initialize to false in the ctor.
(pass_ipa_free_fn_summary::clone,
pass_ipa_free_fn_summary::set_pass_param,
pass_ipa_free_fn_summary::gate): New methods.
(pass_ipa_free_fn_summary::execute): Return TODO_remove_functions
| TODO_dump_symtab if small_p.
* passes.def: Add true parm for the existing pass_ipa_free_fn_summary
entry and add another instance of the pass with false parm after
ipa-pure-const.
* ipa-pure-const.c (pass_ipa_pure_const): Don't call
ipa_free_fn_summary here.

* gcc.dg/pr83506.c: New test.
* gcc.dg/ipa/ctor-empty-1.c: Use -fdump-ipa-free-fnsummary1 instead
of -fdump-ipa-free-fnsummary and scan in free-fnsummary1 instead of
free-fnsummary dump.

Added:
trunk/gcc/testsuite/gcc.dg/pr83506.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/ipa-fnsummary.c
trunk/gcc/ipa-pure-const.c
trunk/gcc/passes.def
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/ipa/ctor-empty-1.c

[Bug ipa/83506] [8 Regression] ICE: Segmentation fault in force_nonfallthru_and_redirect

2017-12-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83506

Jakub Jelinek  changed:

   What|Removed |Added

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

--- Comment #6 from Jakub Jelinek  ---
Created attachment 42928
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42928=edit
gcc8-pr83506.patch

IMHO cleaner approach.

[Bug ipa/83506] [8 Regression] ICE: Segmentation fault in force_nonfallthru_and_redirect

2017-12-20 Thread prathamesh3492 at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83506

--- Comment #5 from prathamesh3492 at gcc dot gnu.org ---
(In reply to Jakub Jelinek from comment #4)
> Though, I guess the real bug is that ipa_free_fn_summary (); is no longer
> called for -fno-ipa-pure-const.  While the ipa_inline pass had unconditional
> gate and so it was freed always if !flag_wpa, ipa-pure-const has a
> non-trivial gate and thus it frees only sometimes.  Calling
> ipa_free_fn_summary () in ipa-inline.c if if (!flag_wpa &&
> !flag_ipa_pure_const && !in_lto_p) is not nice, as it duplicates the
> ipa-pure-const.c gate.  So, we can do something like:
> --- gcc/ipa.c.jj  2017-09-01 09:26:37.0 +0200
> +++ gcc/ipa.c 2017-12-20 11:22:57.915226765 +0100
> @@ -1270,6 +1270,11 @@ ipa_single_use (void)
>varpool_node *var;
>hash_map single_user_map;
>  
> +  /* In WPA we use inline summaries for partitioning process.  Otherwise,
> + free it if earlier IPA passes have not done so yet.  */
> +  if (!flag_wpa)
> +ipa_free_fn_summary ();
> +
>FOR_EACH_DEFINED_VARIABLE (var)
>  if (!var->all_refs_explicit_p ())
>var->aux = BOTTOM;
> But I think I have a cleaner patch than that.

Hi Jakub,
Thanks for the fix! In r254140, I removed the call to ipa_free_fn_summary()
gated on !flag_wpa from inline pass since ipa-pure-const required it for
propagating malloc attribute, which unfortunately caused the above bug.

Regards,
Prathamesh

[Bug ipa/83506] [8 Regression] ICE: Segmentation fault in force_nonfallthru_and_redirect

2017-12-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83506

--- Comment #4 from Jakub Jelinek  ---
Though, I guess the real bug is that ipa_free_fn_summary (); is no longer
called for -fno-ipa-pure-const.  While the ipa_inline pass had unconditional
gate and so it was freed always if !flag_wpa, ipa-pure-const has a non-trivial
gate and thus it frees only sometimes.  Calling ipa_free_fn_summary () in
ipa-inline.c if if (!flag_wpa && !flag_ipa_pure_const && !in_lto_p) is not
nice, as it duplicates the ipa-pure-const.c gate.  So, we can do something
like:
--- gcc/ipa.c.jj2017-09-01 09:26:37.0 +0200
+++ gcc/ipa.c   2017-12-20 11:22:57.915226765 +0100
@@ -1270,6 +1270,11 @@ ipa_single_use (void)
   varpool_node *var;
   hash_map single_user_map;

+  /* In WPA we use inline summaries for partitioning process.  Otherwise,
+ free it if earlier IPA passes have not done so yet.  */
+  if (!flag_wpa)
+ipa_free_fn_summary ();
+
   FOR_EACH_DEFINED_VARIABLE (var)
 if (!var->all_refs_explicit_p ())
   var->aux = BOTTOM;
But I think I have a cleaner patch than that.

[Bug ipa/83506] [8 Regression] ICE: Segmentation fault in force_nonfallthru_and_redirect

2017-12-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83506

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
--- cgraphunit.c.jj 2017-12-19 18:09:05.0 +0100
+++ cgraphunit.c2017-12-20 11:00:55.141899011 +0100
@@ -354,6 +354,7 @@ symbol_table::process_new_functions (voi
case EXPANSION:
  /* Functions created during expansion shall be compiled
 directly.  */
+ gimple_register_cfg_hooks ();
  node->process = 0;
  call_cgraph_insertion_hooks (node);
  node->expand ();

fixes this, while node->expand (); calls gimple_register_cfg_hooks (), if we
need the cfg hooks before, such as in the insertion hooks, it is too late.

[Bug ipa/83506] [8 Regression] ICE: Segmentation fault in force_nonfallthru_and_redirect

2017-12-20 Thread prathamesh3492 at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83506

--- Comment #2 from prathamesh3492 at gcc dot gnu.org ---
Sorry for the breakage, I will take a look.

Regards,
Prathamesh

[Bug ipa/83506] [8 Regression] ICE: Segmentation fault in force_nonfallthru_and_redirect

2017-12-20 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83506

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-12-20
 CC||hubicka at gcc dot gnu.org,
   ||jamborm at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org,
   ||prathamesh3492 at gcc dot 
gnu.org
  Component|rtl-optimization|ipa
   Target Milestone|--- |8.0
 Ever confirmed|0   |1

--- Comment #1 from Martin Liška  ---
Confirmed, started with r254140.