public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "Paulo J. Matos" <paulo@matos-sorge.com>
Cc: gcc@gcc.gnu.org
Subject: Re: fold_builtin changes tree
Date: Tue, 20 Mar 2012 10:30:00 -0000	[thread overview]
Message-ID: <20120320103006.GB6148@sunsite.ms.mff.cuni.cz> (raw)
In-Reply-To: <jk9lnp$ge8$1@dough.gmane.org>

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	other threads:[~2012-03-20 10:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19 17:51 Paulo J. Matos
2012-03-20  5:50 ` Ian Lance Taylor
2012-03-20 10:22   ` Paulo J. Matos
2012-03-20 10:30     ` Jakub Jelinek [this message]
2012-03-21 16:30       ` Paulo J. Matos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120320103006.GB6148@sunsite.ms.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=paulo@matos-sorge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).