http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57084
Martin Jambor <jamborm at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org --- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> 2013-05-02 15:46:35 UTC --- OK, after I verified and re-verified that the call target determined by devirtualization is actually correct, I have noticed that the call graph of the target is an inlined node. I'm not sure what effects exactly that has but the following (untested) patch helps while still performing the devirtualization (and the assembly around the calls is slightly different). I think that the final patch will look a bit different because a) the new code is basically copied from ipa_make_edge_direct_to_target an thus we'd better commonize it somehow (and I'd like to discuss with Honza at least the name of the new function) and b) I see no reason why the constructor-based devirtualization method in PRE cannot have the same problem and so we'll probably want to handle it there instead (Honza said on IRC something about a patch he already had but I am not sure what he meant). Another interesting point is that at least in the 64 bit non-LTO build, these polymorphic calls are devirtualized during inlining. I'm going to look at why we do not do it in 32 bit LTO one (so far I do not know which one is the problem). Index: src/gcc/ipa-prop.c =================================================================== --- src.orig/gcc/ipa-prop.c +++ src/gcc/ipa-prop.c @@ -1978,6 +1978,7 @@ ipa_analyze_node (struct cgraph_node *no tree ipa_intraprocedural_devirtualization (gimple call) { + struct cgraph_node *callee; tree binfo, token, fndecl; struct ipa_jump_func jfunc; tree otr = gimple_call_fn (call); @@ -1993,6 +1994,18 @@ ipa_intraprocedural_devirtualization (gi token = OBJ_TYPE_REF_TOKEN (otr); fndecl = gimple_get_virt_method_for_binfo (tree_low_cst (token, 1), binfo); + if (!fndecl) + return NULL_TREE; + + callee = cgraph_get_node (fndecl); + if (!callee || callee->global.inlined_to) + { + if (!canonicalize_constructor_val (fndecl, NULL) + || !TREE_PUBLIC (fndecl)) + return NULL_TREE; + cgraph_get_create_real_symbol_node (fndecl); + } + return fndecl; }