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

--- Comment #18 from Jan Hubicka <hubicka at gcc dot gnu.org> 2011-03-01 
19:07:36 UTC ---
Created attachment 23507
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23507
patch I am testing

Hi,
the problem is with thunks referring thunks or aliases.

lto-symtab is wrong here and when moving thunks&aliases associated with one
node to the other node, it overwrites thunk.alias by the destination node. It
consequently turns thunk referring another thunk into thunk referring the
functoin itself.

I fixed this by adding extra loop setting alias decl to prevailing decl. Richi,
perhaps there is better place to put this?  I don't like it being in the loop
redirecting thunks&aliases from one node to another because

 1) I think that loop is not quite correct.  When one function is prevailed by
another, local static thunk from the first function should not be redirected to
another.  That happens correctly and is harmless (we end up with dead thunk)
 2) It may happen that thunks get prevailed other way than nodes they are
aliased with.  We use comdat groups that prevents this from happening, but I
would rather not 100% rely on this on all targets since not all targets
implements comdat groups.  So I think it is more robust to simply merge the
decls in alias field like we merge other decls.

Fixing this problem cause different problem with streaming.  When we have alias
A referring function F and alias B referring alias A and we are unlucky with
prevailing and other things, we might end up streaming alias B before alias A. 
This leads us to call cgraph_same_body_alias on decl of A before A is added to
cgraph as an alias.  Consequently cgraph_same_body_alias does nothing later
when we try to create alias A itself, because the node already exists.

This patch fixes it by adding node pointer into the cgraph_same_body_alias and
cgraph_add_thunk so the thunks&aliases can be added in random order w/o
problems as long as the function they are associated with is already in cgraph.

I am testing patch now.

Reply via email to