From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8202 invoked by alias); 22 Feb 2010 16:37:52 -0000 Received: (qmail 8179 invoked by uid 22791); 22 Feb 2010 16:37:50 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from ksp.mff.cuni.cz (HELO atrey.karlin.mff.cuni.cz) (195.113.26.206) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Feb 2010 16:37:45 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 4018) id 32804F0A81; Mon, 22 Feb 2010 17:37:43 +0100 (CET) Date: Mon, 22 Feb 2010 16:49:00 -0000 From: Jan Hubicka To: Martin Jambor Cc: GCC Patches , Jan Hubicka Subject: Re: [PATCH 5/6] Indirect inlining of virtual calls Message-ID: <20100222163742.GF3140@atrey.karlin.mff.cuni.cz> References: <20100213180136.555197900@alvy.suse.cz> <20100213180157.538628963@alvy.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100213180157.538628963@alvy.suse.cz> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-02/txt/msg00882.txt.bz2 > 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 ; > + else > + goto ; > + > + : > + iftmp.1_3 = &obj_2(D)->D.1762; > + > + : > + # iftmp.1_1 = PHI > + D.1879_6 = middleman_1 (iftmp.1_1, i_5(D)); > + return D.1879_6; */ Hmm, fragile, but this is old code, right? > +/* 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. It would be nice if someone C++ FE aware took a look on this. > + > +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