From: Martin Jambor <mjambor@suse.cz>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 5/6] Indirect inlining of virtual calls
Date: Wed, 10 Mar 2010 13:45:00 -0000 [thread overview]
Message-ID: <20100310131202.GA9996@virgil.suse.cz> (raw)
In-Reply-To: <20100222163742.GF3140@atrey.karlin.mff.cuni.cz>
Hi,
On Mon, Feb 22, 2010 at 05:37:43PM +0100, Jan Hubicka wrote:
> > Index: icln/gcc/ipa-prop.c
> > ===================================================================
> > --- icln.orig/gcc/ipa-prop.c
> > +++ icln/gcc/ipa-prop.c
> > +/* Given that an actual argument is an SSA_NAME that is a result of a phi
> > + statement PHI, try to find out whether NAME is in fact a
> > + multiple-inheritance typecast from a descendant into an ancestor of a formal
> > + parameter and thus can be described by an ancestor jump function and if so,
> > + write the appropriate function into JFUNC.
> > +
> > + Essentially we want to match the following pattern:
> > +
> > + if (obj_2(D) != 0B)
> > + goto <bb 3>;
> > + else
> > + goto <bb 4>;
> > +
> > + <bb 3>:
> > + iftmp.1_3 = &obj_2(D)->D.1762;
> > +
> > + <bb 4>:
> > + # iftmp.1_1 = PHI <iftmp.1_3(3), 0B(2)>
> > + D.1879_6 = middleman_1 (iftmp.1_1, i_5(D));
> > + return D.1879_6; */
>
> Hmm, fragile, but this is old code, right?
I don't understand. This is what typecasting to a second-or-later
ancestor looks like (NULL for NULL, add offset otherwise). The
function that builds ANCESTOR jump functions needs to match it.
>
> > +/* Try to find a base info of BINFO that would have its field decl at offset
> > + OFFSET within the BINFO type and which i of EXPECTED_TYPE. If it can be
> > + found, return, otherwise return NULL_TREE. */
>
> I guess stuff like this (supporting the overall devirtualization in
> gimple) should go into tree.c or similar common place.
OK, I've moved it there.
> It would be nice if someone C++ FE aware took a look on this.
Indeed.
Thanks,
Martin
> > +
> > +static tree
> > +get_binfo_at_offset (tree binfo, HOST_WIDE_INT offset, tree expected_type)
> > +{
> > + tree type;
> > +
> > + if (offset == 0)
> > + return binfo;
> > +
> > + type = TREE_TYPE (binfo);
> > + while (offset > 0)
> > + {
> > + tree base_binfo, found_binfo;
> > + HOST_WIDE_INT pos, size;
> > + tree fld;
> > + int i;
> > +
> > + if (TREE_CODE (type) != RECORD_TYPE)
> > + return NULL_TREE;
> > +
> > + for (fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld))
> > + {
> > + if (TREE_CODE (fld) != FIELD_DECL)
> > + continue;
> > +
> > + pos = int_bit_position (fld);
> > + size = tree_low_cst (DECL_SIZE (fld), 1);
> > + if (pos <= offset && (pos + size) > offset)
> > + break;
> > + }
> > + if (!fld)
> > + return NULL_TREE;
> > +
> > + found_binfo = NULL_TREE;
> > + for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
> > + if (TREE_TYPE (base_binfo) == TREE_TYPE (fld))
> > + {
> > + found_binfo = base_binfo;
> > + break;
> > + }
> > +
> > + if (!found_binfo)
> > + return NULL_TREE;
> > +
> > + type = TREE_TYPE (fld);
> > + binfo = found_binfo;
> > + offset -= pos;
> > + }
> > + if (type != expected_type)
> > + return NULL_TREE;
> > + return binfo;
> > +}
> > +
>
> Patch is OK for pretty-ipa.
>
> Honza
next prev parent reply other threads:[~2010-03-10 13:12 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-13 18:03 [PATCH 0/6] Cgraph changes and various devirtualizations Martin Jambor
2010-02-13 18:03 ` [PATCH 1/6] Clarify edge redirection for inline clones Martin Jambor
2010-02-22 14:23 ` Jan Hubicka
2010-02-13 18:04 ` [PATCH 3/6] Folding of virtual calls Martin Jambor
2010-02-13 18:12 ` Richard Guenther
2010-02-13 18:04 ` [PATCH 5/6] Indirect inlining " Martin Jambor
2010-02-22 16:49 ` Jan Hubicka
2010-03-10 13:45 ` Martin Jambor [this message]
2010-03-10 15:24 ` Jan Hubicka
2010-02-13 18:04 ` [PATCH 6/6] Devirtualization in ipa-cp Martin Jambor
2010-02-22 16:37 ` Jan Hubicka
2010-03-11 13:42 ` Martin Jambor
2010-02-13 18:04 ` [PATCH 2/6] Indirect call graph edges Martin Jambor
2010-02-13 18:17 ` Richard Guenther
2010-02-13 18:25 ` Richard Guenther
2010-03-05 17:06 ` Martin Jambor
2010-02-22 15:52 ` Jan Hubicka
2010-02-22 16:05 ` Richard Guenther
2010-02-22 16:06 ` Jan Hubicka
2010-02-13 18:04 ` [PATCH 4/6] Remove unused ipa_note_param_call.called flag (approved) Martin Jambor
2010-02-13 18:14 ` Richard Guenther
2010-03-05 16:19 ` Martin Jambor
2010-02-22 15:04 ` Jan Hubicka
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=20100310131202.GA9996@virgil.suse.cz \
--to=mjambor@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
/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).