[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-08-19 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Jambor  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #23 from Martin Jambor  ---
(In reply to Martin Liška from comment #22)
> Should be fixed now.

So let's assume it is.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-30 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #22 from Martin Liška  ---
Should be fixed now.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-30 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #21 from Martin Liška  ---
Author: marxin
Date: Tue Jul 30 14:52:29 2019
New Revision: 273910

URL: https://gcc.gnu.org/viewcvs?rev=273910=gcc=rev
Log:
Use edge->indirect_unknown_callee in cgraph_edge::make_direct (PR ipa/89330).

2019-07-30  Martin Liska  

PR ipa/89330
* cgraph.c (cgraph_edge::make_direct): Use
edge->indirect_unknown_callee as edge->resolve_speculation can
deallocate edge which is this pointer.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/cgraph.c

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-30 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Liška  changed:

   What|Removed |Added

   Assignee|marxin at gcc dot gnu.org  |jamborm at gcc dot 
gnu.org

--- Comment #20 from Martin Liška  ---
Ok, one can reproduce the problem with:

$ ../configure --enable-languages=c,c++,lto,fortran --disable-multilib
--prefix=/home/marxin/bin/gcc2 --enable-checking=release --without-isl
--disable-libsanitizer --disable-bootstrap

Reduced test-case:

$ cat /tmp/tree-ssa-sccvn-ice.ii
class A {
public:
  int dest;
};
class B {
public:
  B(int);
  virtual int m_fn1();
};
int B::m_fn1() { return __null; }
void fn1(B , bool, bool, bool, bool, bool) {
  for (;;) {
p1.m_fn1();
p1.m_fn1();
  }
}
A a;
void fn2(bool p1) {
  B b(a.dest);
  fn1(b, false, false, p1, fn2, );
}

I also have a debugging patch that shows which released edge is used:

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 81250acb70c..c585713b23a 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1008,8 +1008,10 @@ symbol_table::free_edge (cgraph_edge *e)
   if (e->m_summary_id != -1)
 edge_released_summary_ids.safe_push (e->m_summary_id);

+  fprintf (stderr, "releasing: %p: %p->%p\n", e, e->caller, e->callee);
   if (e->indirect_info)
 ggc_free (e->indirect_info);
+  e->caller = NULL;
   ggc_free (e);
 }

@@ -,6 +1113,8 @@ cgraph_edge::speculative_call_info (cgraph_edge *,
   if (e2->call_stmt)
{
  e = e->caller->get_edge (e2->call_stmt);
+ fprintf (stderr, "cgraph_edge::speculative_call_info: %p\n", e);
+ gcc_assert (e->caller);
  gcc_assert (e->speculative && !e->indirect_unknown_callee);
}
   else
@@ -1223,6 +1227,8 @@ cgraph_edge::make_direct (cgraph_node *callee)
   ggc_free (indirect_info);
   indirect_info = NULL;

+  fprintf (stderr, "cgraph_edge::make_direct: %p\n", this);
+
   /* Get the edge out of the indirect edge list. */
   if (prev_callee)
 prev_callee->next_callee = next_callee;

$ ./xgcc -B. /tmp/tree-ssa-sccvn-ice.ii -c -O2
/tmp/tree-ssa-sccvn-ice.ii: In member function ‘virtual int B::m_fn1()’:
/tmp/tree-ssa-sccvn-ice.ii:10:25: warning: converting to non-pointer type ‘int’
from NULL [-Wconversion-null]
   10 | int B::m_fn1() { return __null; }
  | ^~
releasing: 0x7fe4853894e0: 0x7fe485380438->(nil)
releasing: 0x7fe485389478: 0x7fe485380438->(nil)
releasing: 0x7fe485389820: 0x7fe4853805a0->0x7fe485380438
releasing: 0x7fe4853897b8: 0x7fe4853805a0->0x7fe485380708
releasing: 0x7fe485389958: 0x7fe485380438->(nil)
releasing: 0x7fe4853898f0: 0x7fe485380438->(nil)
releasing: 0x7fe485389af8: 0x7fe485380438->(nil)
releasing: 0x7fe485389a90: 0x7fe485380438->(nil)
releasing: 0x7fe485389a28: 0x7fe4853805a0->0x7fe485380438
releasing: 0x7fe4853899c0: 0x7fe4853805a0->0x7fe485380708
releasing: 0x7fe485389ea0: 0x7fe4853805a0->0x7fe485380438
releasing: 0x7fe485389e38: 0x7fe4853805a0->0x7fe485380708
cgraph_edge::speculative_call_info: 0x7fe485389888
cgraph_edge::speculative_call_info: 0x7fe485389888
releasing: 0x7fe4853899c0: 0x7fe4854f92d0->(nil)
cgraph_edge::make_direct: 0x7fe4853899c0
during IPA pass: inline
/tmp/tree-ssa-sccvn-ice.ii: At global scope:
/tmp/tree-ssa-sccvn-ice.ii:21:1: internal compiler error: Segmentation fault
   21 | }
  | ^
0x11f0c8a crash_signal
../../gcc/toplev.c:326
0x7fe48560de4f ???
   
/usr/src/debug/glibc-2.29-7.3.x86_64/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0xc078da cgraph_edge::make_direct(cgraph_node*)
../../gcc/cgraph.c:1238
0xef8525 ipa_make_edge_direct_to_target(cgraph_edge*, tree_node*, bool)
../../gcc/ipa-prop.c:2978
0xef951c try_make_edge_direct_virtual_call
../../gcc/ipa-prop.c:3398
0xef97cc update_indirect_edges_after_inlining
../../gcc/ipa-prop.c:3463
0xef9b71 propagate_info_to_inlined_callees
../../gcc/ipa-prop.c:3556
0xefa1ed ipa_propagate_indirect_call_infos(cgraph_edge*, vec*)
../../gcc/ipa-prop.c:3713
0x1eb1b06 inline_call(cgraph_edge*, bool, vec*,
int*, bool, bool*)
../../gcc/ipa-inline-transform.c:486
0x1ea3efd inline_small_functions
../../gcc/ipa-inline.c:2088
0x1ea58c3 ipa_inline
../../gcc/ipa-inline.c:2550
0x1ea66b0 execute
../../gcc/ipa-inline.c:2958

@Martin: Can you please take a look at that?

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-30 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #19 from Martin Liška  ---
(In reply to Andreas Schwab from comment #18)
> This breaks bootstrap with --enable-checking=release.
> 
> during IPA pass: cp
> ../../gcc/gcc/tree-ssa-sccvn.c:7307:1: internal compiler error: in
> speculative_call_info, at cgraph.c:1114
>  7307 | }
>   | ^
> 0xc0dc0e cgraph_edge::speculative_call_info(cgraph_edge*&, cgraph_edge*&,
> ipa_ref*&)
> ../../gcc/gcc/cgraph.c:1114
> 0xc0ddbb cgraph_edge::resolve_speculation(tree_node*)
> ../../gcc/gcc/cgraph.c:1155
> 0xc0e025 cgraph_edge::make_direct(cgraph_node*)
> ../../gcc/gcc/cgraph.c:1215
> 0xefefaa ipa_make_edge_direct_to_target(cgraph_edge*, tree_node*, bool)
> ../../gcc/gcc/ipa-prop.c:2978
> 0x1eb40da ipcp_discover_new_direct_edges
> ../../gcc/gcc/ipa-cp.c:3348
> 0x1eb55b9 create_specialized_node
> ../../gcc/gcc/ipa-cp.c:3913
> 0x1eb731f decide_whether_version_node
> ../../gcc/gcc/ipa-cp.c:4803
> 0x1eb77c7 ipcp_decision_stage
> ../../gcc/gcc/ipa-cp.c:4915
> 0x1eb7fd6 ipcp_driver
> ../../gcc/gcc/ipa-cp.c:5092
> 0x1eb81b8 execute
> ../../gcc/gcc/ipa-cp.c:5183

Confirmed, I've got a patch candidate that I'll send soon.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-29 Thread sch...@linux-m68k.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Andreas Schwab  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #18 from Andreas Schwab  ---
This breaks bootstrap with --enable-checking=release.

during IPA pass: cp
../../gcc/gcc/tree-ssa-sccvn.c:7307:1: internal compiler error: in
speculative_call_info, at cgraph.c:1114
 7307 | }
  | ^
0xc0dc0e cgraph_edge::speculative_call_info(cgraph_edge*&, cgraph_edge*&,
ipa_ref*&)
../../gcc/gcc/cgraph.c:1114
0xc0ddbb cgraph_edge::resolve_speculation(tree_node*)
../../gcc/gcc/cgraph.c:1155
0xc0e025 cgraph_edge::make_direct(cgraph_node*)
../../gcc/gcc/cgraph.c:1215
0xefefaa ipa_make_edge_direct_to_target(cgraph_edge*, tree_node*, bool)
../../gcc/gcc/ipa-prop.c:2978
0x1eb40da ipcp_discover_new_direct_edges
../../gcc/gcc/ipa-cp.c:3348
0x1eb55b9 create_specialized_node
../../gcc/gcc/ipa-cp.c:3913
0x1eb731f decide_whether_version_node
../../gcc/gcc/ipa-cp.c:4803
0x1eb77c7 ipcp_decision_stage
../../gcc/gcc/ipa-cp.c:4915
0x1eb7fd6 ipcp_driver
../../gcc/gcc/ipa-cp.c:5092
0x1eb81b8 execute
../../gcc/gcc/ipa-cp.c:5183

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-28 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Liška  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #17 from Martin Liška  ---
Should be fixed now.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-28 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #16 from Martin Liška  ---
Author: marxin
Date: Sun Jul 28 17:10:26 2019
New Revision: 273857

URL: https://gcc.gnu.org/viewcvs?rev=273857=gcc=rev
Log:
Release cgraph_{node,edge} via ggc_free (PR ipa/89330).

2019-07-28  Martin Liska  

PR ipa/89330
* cgraph.c (symbol_table::create_edge): Always allocate
a cgraph_edge.
(symbol_table::free_edge): Store summary_id to
edge_released_summary_ids if != -1;
* cgraph.h (NEXT_FREE_NODE): Remove.
(SET_NEXT_FREE_NODE): Likewise.
(NEXT_FREE_EDGE): Likewise.
(symbol_table::release_symbol): Store summary_id to
cgraph_released_summary_ids if != -1;
(symbol_table::allocate_cgraph_symbol): Always allocate
a cgraph_node.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/cgraph.c
trunk/gcc/cgraph.h

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-28 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Liška  changed:

   What|Removed |Added

   Assignee|jamborm at gcc dot gnu.org |marxin at gcc dot 
gnu.org

--- Comment #15 from Martin Liška  ---
I'll take the issue as Martin installed the patch. I'm testing right now the
patch that releases deleted edges.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-26 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #14 from Martin Jambor  ---
Author: jamborm
Date: Fri Jul 26 08:44:51 2019
New Revision: 273825

URL: https://gcc.gnu.org/viewcvs?rev=273825=gcc=rev
Log:
[PR 89330] Remove non-useful speculations from new_edges

2019-07-26  Martin Jambor  

PR ipa/89330
* ipa-inline-transform.c (check_speculations_1): New function.
(push_all_edges_in_set_to_vec): Likewise.
(check_speculations): Use check_speculations_1, new parameter
new_edges.
(inline_call): Pass new_edges to check_speculations.
* ipa-inline.c (add_new_edges_to_heap): Assert edge_callee is not
NULL.
(speculation_useful_p): Early return true if edge is inlined, remove
later checks for inline_failed.

testsuite/
* g++.dg/lto/pr89330_[01].C: New test.
* g++.dg/tree-prof/devirt.C: Added -fno-profile-values to dg-options.


Added:
trunk/gcc/testsuite/g++.dg/lto/pr89330_0.C
trunk/gcc/testsuite/g++.dg/lto/pr89330_1.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/ipa-inline-transform.c
trunk/gcc/ipa-inline.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/tree-prof/devirt.C

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-25 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #13 from Martin Jambor  ---
I have proposed this patch on the mailing list:

https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01648.html

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-10 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Jambor  changed:

   What|Removed |Added

  Attachment #45730|0   |1
is obsolete||
  Attachment #46544|0   |1
is obsolete||

--- Comment #12 from Martin Jambor  ---
Created attachment 46584
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46584=edit
Another WIP patch

Thanks for tracking that down, indeed we found that the speculation
was undoing inlining decisions which is something that is generally
unsupported by the inliner.

This patch fixes that and it indeed survives LTO bootstrap of all
languages (profiled LTO bootstrap is underway).  Unfortunately, it
causes the following tests to fail:

FAIL: g++.dg/tree-prof/devirt.C scan-tree-dump-times tracer "folding virtual
function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 1
FAIL: g++.dg/tree-prof/devirt.C scan-tree-dump-times tracer "folding virtual
function call to virtual unsigned int mozPersonalDictionary::AddRef" 1

So far all my attempts to quickly fix this without actually having to
understand what is going on in the testcase have failed.  I'm afraid
I'll have to look deeper into it which will take time, so far I did
not even manage to reproduce the problem manually.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-04 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #11 from Martin Liška  ---
(In reply to Martin Jambor from comment #10)
> Created attachment 46544 [details]
> WIP patch
> 
> I have written another patch that removes the edges from the vector at
> the time speculation is resolved rather than preventing creation of
> the edges in the first place.
> 
> Unfortunately, the patch still trips over the added assert when LTO
> bootstrapping D.  So we'll have to look into it and find out where the
> edges get deleted other than in check_speculations before figuring out
> whether this is the right approach or not.

Life cycle for edge->callee is:

Hardware watchpoint 5: *$2

Old value = 
New value = 
symbol_table::create_edge (this=0x7733a100, caller=, callee=, call_stmt=0x0,
count=..., indir_unknown_callee=true) at ../../gcc/cgraph.c:867
867   edge->prev_caller = NULL;
(gdb) bt
#0  symbol_table::create_edge (this=0x7733a100, caller=, callee=, call_stmt=0x0,
count=..., indir_unknown_callee=true) at ../../gcc/cgraph.c:867
#1  0x009d0a32 in cgraph_node::create_indirect_edge (this=, call_stmt=0x0, ecf_flags=0,
count=..., compute_indirect_info=false) at ../../gcc/cgraph.c:955
#2  0x009ecf92 in cgraph_edge::clone (this= -> )>,
n=, call_stmt=0x0, stmt_uid=4,
num=..., den=..., 
update_original=true) at ../../gcc/cgraphclones.c:113
#3  0x009ee828 in cgraph_node::create_clone (this=, new_decl=, prof_count=..., update_original=true, redirect_callers=...,
call_duplication_hook=true, 
new_inlined_to=,
args_to_skip=0x0, suffix=0x0) at ../../gcc/cgraphclones.c:502
#4  0x01eb48ea in clone_inlined_nodes (e= -> )>, duplicate=true, update_original=true, 
overall_size=0x3233d30 <_ZL12overall_size>) at
../../gcc/ipa-inline-transform.c:221
#5  0x01eb4996 in clone_inlined_nodes (e= -> )>, duplicate=true, update_original=true, 
overall_size=0x3233d30 <_ZL12overall_size>) at
../../gcc/ipa-inline-transform.c:236
#6  0x01eb4996 in clone_inlined_nodes (
e=
-> )>,
duplicate=true, 
update_original=true, overall_size=0x3233d30 <_ZL12overall_size>) at
../../gcc/ipa-inline-transform.c:236
#7  0x01eb4996 in clone_inlined_nodes (
e= -> )>,
 
duplicate=true, update_original=true, overall_size=0x3233d30
<_ZL12overall_size>) at ../../gcc/ipa-inline-transform.c:236
#8  0x01eb4996 in clone_inlined_nodes (e= -> )>, duplicate=true,
update_original=true, 
overall_size=0x3233d30 <_ZL12overall_size>) at
../../gcc/ipa-inline-transform.c:236
#9  0x01eb4996 in clone_inlined_nodes (e= -> )>, duplicate=true, update_original=true,
overall_size=0x3233d30 <_ZL12overall_size>)
at ../../gcc/ipa-inline-transform.c:236
#10 0x01eb55f3 in inline_call (e= -> )>, update_original=true, Python Exception
 There is no member or method named m_vecpfx.: 
new_edges=0x7fffdad0, overall_size=0x3233d30 <_ZL12overall_size>, 
update_overall_summary=true, callee_removed=0x0) at
../../gcc/ipa-inline-transform.c:477
#11 0x01ea6a68 in inline_small_functions () at
../../gcc/ipa-inline.c:2085
#12 0x01ea85c0 in ipa_inline () at ../../gcc/ipa-inline.c:2547
#13 0x01ea945f in (anonymous namespace)::pass_ipa_inline::execute
(this=0x32978f0) at ../../gcc/ipa-inline.c:2955
#14 0x00f0ddff in execute_one_pass (pass=) at ../../gcc/passes.c:2473
#15 0x00f0ed7a in execute_ipa_pass_list (pass=) at ../../gcc/passes.c:2913
#16 0x008cbf7a in do_whole_program_analysis () at
../../gcc/lto/lto.c:456
#17 0x008cc2a6 in lto_main () at ../../gcc/lto/lto.c:628
#18 0x01073ff8 in compile_file () at ../../gcc/toplev.c:456
#19 0x01076c7a in do_compile () at ../../gcc/toplev.c:2209
#20 0x01076f5a in toplev::main (this=0x7fffdf90, argc=1068,
argv=0x3267250) at ../../gcc/toplev.c:2344
#21 0x01fd06b9 in main (argc=30, argv=0x7fffe098) at
../../gcc/main.c:39
(gdb) c
Continuing.

Hardware watchpoint 5: *$2

Old value = 
New value = 
cgraph_edge::set_callee (this= -> )>, n=) at
../../gcc/cgraph.h:3140
3140}
(gdb) bt
#0  cgraph_edge::set_callee (this= -> )>, n=) at
../../gcc/cgraph.h:3140
#1  0x009d15c4 in cgraph_edge::make_direct (this= -> )>, callee=) at ../../gcc/cgraph.c:1254
#2  0x00d3da66 in ipa_make_edge_direct_to_target (ie= -> )>, target=,
speculative=false)
at ../../gcc/ipa-prop.c:2977
#3  0x00d3eef6 in try_make_edge_direct_virtual_call (ie= -> )>, jfunc=0x7fffc6ab4468, ctx=...) at
../../gcc/ipa-prop.c:3397
#4  0x00d3f1af in update_indirect_edges_after_inlining
(cs= -> )>,
node=, Python Exception  There is no member or method named m_vecpfx.: 

new_edges=0x7fffdad0) at ../../gcc/ipa-prop.c:3462
#5  0x00d3f553 in propagate_info_to_inlined_callees (cs= -> )>, node=, Python Exception  There is no member or
method named m_vecpfx.: 

new_edges=0x7fffdad0) at ../../gcc/ipa-prop.c:3555
#6  0x00d3f58a in 

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-07-02 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #10 from Martin Jambor  ---
Created attachment 46544
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46544=edit
WIP patch

I have written another patch that removes the edges from the vector at
the time speculation is resolved rather than preventing creation of
the edges in the first place.

Unfortunately, the patch still trips over the added assert when LTO
bootstrapping D.  So we'll have to look into it and find out where the
edges get deleted other than in check_speculations before figuring out
whether this is the right approach or not.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-06-06 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Liška  changed:

   What|Removed |Added

   Target Milestone|--- |10.0

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-19 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Liška  changed:

   What|Removed |Added

  Attachment #45733|0   |1
is obsolete||

--- Comment #9 from Martin Liška  ---
Created attachment 45765
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45765=edit
Updated patch that recycles summary IDs (tested on x86_64-linux-gnu)

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-15 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Jambor  changed:

   What|Removed |Added

   Assignee|hubicka at gcc dot gnu.org |jamborm at gcc dot 
gnu.org

--- Comment #8 from Martin Jambor  ---
I have proposed the fix on the mailing list:

https://gcc.gnu.org/ml/gcc-patches/2019-02/msg01225.html

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-15 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #7 from Martin Liška  ---
Created attachment 45733
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45733=edit
Follow up patch that releases memory

Survives GCC LTO bootstrap and can build Inkscape with LTO.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-15 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #6 from Martin Jambor  ---
Created attachment 45730
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45730=edit
Untested fix

I'm testing the attached fix.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-14 Thread hubicka at ucw dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #5 from Jan Hubicka  ---
> Let me see if I can add the respective usefulness test to the code
> deciding to speculate.

I see, it is mine, sorry for blaming you :)

One alternative would be also to put the indirect part of pseculative
edge to the vector and lookup the direct one if speculation survives.
But checking prior creation should work too.

Thanks for looking into this!

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-14 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Jambor  changed:

   What|Removed |Added

 CC||jamborm at gcc dot gnu.org

--- Comment #4 from Martin Jambor  ---
The indirect inlining thingy was indeed written by me, that is true,
but that was before speculative inlining was creating and disposing of
edges at difficult to predict times.  What happens is that:

1. In the course of inlining an edge, we call ipa_propagate_indirect_call_infos
   to adjust jump functions and to add newly discovered direct edges to
   new_edges vector so that they can be added to the heap later.

2. The speculation code in try_make_edge_direct_virtual_call decides
   to create speculation, so a new speculative edge is created and
   added to the vector.

3. Immediately after calling ipa_propagate_indirect_call_infos,
   check_speculations is called, which finds the edge
   !speculation_useful_p and removes it.  But the edge already is in
   the vector.

Let me see if I can add the respective usefulness test to the code
deciding to speculate.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-13 Thread hubicka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Jan Hubicka  changed:

   What|Removed |Added

 CC||mjambor at suse dot cz

--- Comment #3 from Jan Hubicka  ---
We may have more instances of this - I think I got rid of most of that code but
once upon of time it was common in GCC to walk removed instructions and edges
knowing they are in freelist.

This code is originally Martin's. I will try to take a look how complex the
interaction beween creation and removal is these days. One way is to teach
inliner cache to maintain the list of new edges transparently without having to
have extra vector.

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-13 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2019-02-13
   Assignee|unassigned at gcc dot gnu.org  |hubicka at gcc dot 
gnu.org
 Ever confirmed|0   |1

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-13 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #2 from Martin Liška  ---
Created attachment 45691
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45691=edit
test-case

[Bug ipa/89330] IPA inliner touches released cgraph_edges

2019-02-13 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89330

--- Comment #1 from Martin Liška  ---
Created attachment 45690
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45690=edit
test-case