Hi Honza,

as you know, we have a wrong code bug, when a pure or const method is called 
via a virtual thunk.
I had some more Ideas, how to fix that, but all of them had some serious 
draw-backs, so I leave the details out...


But now I have a new insight, why the "obvious" fix for this serious code 
generation bug did not work
in the first place.


And the reason was, that if ipa-pure-const.c calls set_const_flag or 
set_pure_flag for a thunk, it calls the same
function later for the called method, and this overwrites the flags of _all_ 
associated thunks and aliases.
However that should at least not be done for virtual thunks, as these need to 
be IPA_NEITHER, even if
the method itself has different attributes, that is because the assembler thunk 
accesses the vtable, while
other thunks do not.


So I re-factored set_const_flag and set_pure_flag to exclude the virtual 
thunks, taking care that other
users of call_for_symbol_thunks_and_aliases do not get a different behavior 
than before this patch.


The attached patch was boot-strapped and
regression-tested on x86_64-linux-gnu.
Ok for trunk?


PS: As a side-note, there are two identical functions, named 
"call_for_symbol_and_aliases", in
class symtab_node and in class cgraph_node, which inherits from symtab_node. 
Both functions are
not declared virtual.  Is that what's intended?  Usually this could lead to 
errors, or at least some serious
compiler warnings.


Thanks
Bernd.
                                          
2014-10-07  Bernd Edlinger  <bernd.edlin...@hotmail.de>

        PR ipa/61190
        * cgraph.h (symtab_node::call_for_symbol_and_aliases): Fix comment.
        (cgraph_node::call_for_symbol_and_aliases): Likewise.
        (cgraph_node::call_for_symbol_thunks_and_aliases_1): New function.
        (cgraph_node::call_for_symbol_thunks_and_aliases): Adjust comment.
        Call call_for_symbol_thunks_and_aliases_1.
        * cgraph.c (cgraph_node::call_for_symbol_thunks_and_aliases): Renamed
        to cgraph_node::call_for_symbol_thunks_and_aliases_1.  Added new
        parameter exclude_virtual_thunks.
        (cgraph_node::set_const_flag): Don't propagate to virtual thunks.
        (cgraph_node::set_pure_flag): Likewise.
        * ipa-pure-const.c (analyze_function): For virtual thunks
        set pure_const_state to IPA_NEITHER.

testsuite/ChangeLog:
2014-10-07  Bernd Edlinger  <bernd.edlin...@hotmail.de>

        PR ipa/61190
        * g++.old-deja/g++.mike/p4736b.C: Use -O2.

Attachment: patch-pr61190.diff
Description: Binary data

Reply via email to