On Tue, Mar 20, 2012 at 10:21:45AM +0000, Paulo J. Matos wrote:
> > I'm not sure what you are folding the builtin to, but perhaps you could
> > retain a reference to the function.
> > 
> 
> I am folding the function call __function_size(foobar) to a new symbol 
> foobar@size. The reference to function foobar disappears. Can I keep a 
> reference foobar attached to the symbol somehow?

Folding it, at least too early, is definitely a bad idea, especially if you
set DECL_PRESERVED_P.  Because that will prevent the referenced function
from being removed, even if the function containing __function_size is
removed.  You really want to do it in the expander instead.

> I thought that the only way to replace a builtin expression was to use 
> fold_builtin and expand_builtin had other purposes. How can I use the 
> expand_builtin to do replacement?

Like any other builtin expander?  There are many dozens of examples in
builtins.c.  It is called with the tree argument, so you verify it, complain
if the argument is not the one you are expecting, and just expand it as the
symbol instead of expanding the call.  Basically you could do what you
currently do in the folder, and feed what you'd return from that to
expand_normal or expand_expr.

        Jakub

Reply via email to