Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-05 Thread Martin Jambor
Hi, On Wed, Feb 05, 2014 at 12:47:30AM +0100, Jan Hubicka wrote: - if (TREE_CODE (t) != TREE_BINFO) + /* Try to work out BINFO from virtual table pointer value in replacements. */ + if (!t agg_reps !ie-indirect_info-by_ref) At this point you know that

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-05 Thread Jan Hubicka
I think it would be better, yes. IIRC, We want to re-organize indirect_info anyway (I vaguely remember we want to split the overloaded offset field into two but forgot the exact reason why but I have it written somewhere), I suppose we'll be turning it into a union (or class hierarchy?)

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-04 Thread Paolo Carlini
Hi, On 02/04/2014 06:43 AM, Jan Hubicka wrote: Hi, this patch solves the actual ICE in PR59831 by using ipa-devirt instead of gimple_extract_devirt_binfo_from_cst as discussed in the first post. Honza PR ipa/59831 * ipa-cp.c (ipa_get_indirect_edge_target_1): Use ipa-devirt

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-04 Thread Paolo Carlini
.. to wit, for 27_io/basic_stringbuf/sputbackc/char/9425.cc: 0xbb482f crash_signal /scratch/Gcc/svn-dirs/trunk/gcc/toplev.c:337 0x10ce353 contains_struct_check /scratch/Gcc/svn-dirs/trunk/gcc/tree.h:2822 0x10ce353 ipa_get_indirect_edge_target_1

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-04 Thread Markus Trippelsdorf
On 2014.02.04 at 14:18 +0100, Paolo Carlini wrote: .. to wit, for 27_io/basic_stringbuf/sputbackc/char/9425.cc: 0xbb482f crash_signal /scratch/Gcc/svn-dirs/trunk/gcc/toplev.c:337 0x10ce353 contains_struct_check /scratch/Gcc/svn-dirs/trunk/gcc/tree.h:2822 0x10ce353

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-04 Thread Jan Hubicka
Hi, On 02/04/2014 06:43 AM, Jan Hubicka wrote: Hi, this patch solves the actual ICE in PR59831 by using ipa-devirt instead of gimple_extract_devirt_binfo_from_cst as discussed in the first post. Honza PR ipa/59831 * ipa-cp.c (ipa_get_indirect_edge_target_1): Use ipa-devirt

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-04 Thread Jan Hubicka
Hi, I went ahead and comitted Markus' patch. I updated the testcase to use hidden visibility. With default visibility the gimple-fold change will enable devirtualization. Honza Index: ChangeLog === --- ChangeLog (revision 207477)

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-04 Thread Martin Jambor
Hi, On Fri, Jan 31, 2014 at 07:22:55AM +0100, Jan Hubicka wrote: ... PR ipa/59831 * gimple-fold.c (gimple_extract_devirt_binfo_from_cst): Remove. * ipa-devirt.c (get_poymorphic_call_info_for_decl): Break out from ... (get_polymorphic_call_info): ... here.

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-04 Thread Martin Jambor
Hi, On Mon, Feb 03, 2014 at 12:52:49AM +0100, Jan Hubicka wrote: Hi, this patch fixes the bug in extr_type_from_vtbl_ptr_store that made it to consider store of construction virtual table or virtual table of virtual base as store of type's virtual table. In the testcase we have after early

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-04 Thread Jan Hubicka
Hi, On Mon, Feb 03, 2014 at 12:52:49AM +0100, Jan Hubicka wrote: Hi, this patch fixes the bug in extr_type_from_vtbl_ptr_store that made it to consider store of construction virtual table or virtual table of virtual base as store of type's virtual table. In the testcase we have

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-03 Thread Jan Hubicka
Hi, this is the first half of the original fix to the PR, bit expanded in length. The main change is simple: we now devirtualize when aggregate propagation tells us the virtual table pointer value. This is done to prevent fold() doing it during inliner's function saving that confuses the cgraph on

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-03 Thread Jan Hubicka
Hi, this patch solves the actual ICE in PR59831 by using ipa-devirt instead of gimple_extract_devirt_binfo_from_cst as discussed in the first post. Honza PR ipa/59831 * ipa-cp.c (ipa_get_indirect_edge_target_1): Use ipa-devirt to figure out targets of polymorphic calls

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-02 Thread Jan Hubicka
Hi, since we hit can of worms here, I decided to decompose the changes into minimal patches. This is first one fixing small bug introduced last July in Martin's change to add a flags to passthrough about the type preservation. This does not affect gcc-4.8 Bootstrapped/regtested x86_64-linux,

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-02-02 Thread Jan Hubicka
Hi, this patch fixes the bug in extr_type_from_vtbl_ptr_store that made it to consider store of construction virtual table or virtual table of virtual base as store of type's virtual table. In the testcase we have after early inlining: virtual C::~C() (struct C * const this) { unsigned int i;

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-01-31 Thread Markus Trippelsdorf
On 2014.01.31 at 07:22 +0100, Jan Hubicka wrote: +tree +vtable_pointer_value_to_binfo (tree t) +{ + /* We expect MEM[(void *)virtual_table + 16B]. + We obtain object's BINFO from the context of the virtual table. + This one contains pointer to virtual table represented via +

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-01-31 Thread Jan Hubicka
I've tested your patch a little bit and hit the gcc_assert above: markus@x4 tmp % cat test.ii class A { public: unsigned length; }; class B {}; class MultiTermDocs : public virtual B { protected: A readerTermDocs; A subReaders; virtual B *m_fn1(int *); virtual

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-01-31 Thread Jan Hubicka
Hi, this is variant of testcase that produces wrong code on Mainline. $ ./xgcc -B ./ -O3 ~/t.C -S -fno-partial-inlining -fno-early-inlining -fdump-ipa-all ; g++ t.s; ./a.out Aborted The bug is that we determine wrong type on call of ~MultiTermDocs within ~C (it is determined as C, while it

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-01-31 Thread Jan Hubicka
Hi, here is even better testcase (in a sense that my patch does not solve the wrong code issue) Compile with ./xgcc -B ./ -O3 ~/t.C -S -fno-partial-inlining -fno-early-inlining -fdump-ipa-all -fdump-tree-all -fipa-cp -fno-ipa-sra Here the sequence is bit different. Here we have contstruction

PR ipa/59831 (ipa-cp devirt issues)

2014-01-30 Thread Jan Hubicka
Hi, PR ipa/59831 has testcase with one virtual call that shows really interesting sequence of events. First we speculatively identify the target of call. Next ipa-cp correctly works out the target and decides to clone. While creating a clone it however no longer identifies the direct edge. It

Re: PR ipa/59831 (ipa-cp devirt issues)

2014-01-30 Thread Jakub Jelinek
On Fri, Jan 31, 2014 at 07:22:55AM +0100, Jan Hubicka wrote: --- ipa-devirt.c (revision 207287) +++ ipa-devirt.c (working copy) @@ -972,6 +972,120 @@ contains_type_p (tree outer_type, HOST_W return get_class_context (context, otr_type); } +/* Proudce polymorphic call context