------- Comment #6 from jamborm at gcc dot gnu dot org  2009-11-30 22:22 -------
The lattices are OK per se.  Lattices really only represent arguments
of calls that are represented in the call graph.  When there might be
other calls that are not represented in the graph, the function body
is cloned and the original should be used for those.  But it appears
it isn't.  (In fact it is always cloned because that's how replacement
with constants works.)

Specifically, the problem is that the wrong version of callback is
_inlined_ into CallFunctionRec.  Since indirect inlining is not
involved, I'm surprised that this indirect call is inlined.  So it all
comes down to the fact that we have a wrong edge in the call graph
after ipa-cp.

This happens in the following way:

1. CallFunctionRec is cloned because fun is constant.  fun is replaced
   by callback in the call statement.  It then calls rebuild
   cgraph_edges so that a call graph edge is created for the statement
   (among other things, I believe cgraph verifier mandates this).

2. callback is cloned.  IPA-CP does a rather nasty trick when
   redirecting callers:  It redirects all of them and then figures out
   later when it was wrong.  However a clone calling a clone is
   considered always safe.  That would be so, however, only if the
   edge we created in the previous cloning was also part of the
   call graph when we did our analysis.  But we added it later.

We do not have this issue in trunk at least since may because the
clone is now virtual, has no body and so we do not rebuild outgoing
call graph edges in this way.  (In fact, for the sake of indirect
inlining, we should be creating these edges too.)

Anyway, my proposed fix would be to replace the call
rebuild_cgraph_edges in ipcp_update_cloned_node with something that
just adds new call graph edges and also marks the new ones as
indirect.  Then it would be enough to tell ipcp_update_callgraph to
redirect these edges back to (hm, actually from) the original nodes as
well.

If there are no objections, I'll prepare a patch along these lines in
the next few days.


-- 

jamborm at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jh at suse dot cz


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42231

Reply via email to