This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Indirect inlining of virtual calls


On Fri, May 14, 2010 at 12:43 PM, Martin Jambor <mjambor@suse.cz> wrote:
> Hi,
>
> This patch improves the main inlining pass so that it is able to
> inline virtual calls which will have known base type because of
> previous inlining decisions. ?I believe many C++ applications where
> small virtual methods are used extensively will benefit tangibly. ?In
> any way, this patch only provides inliner with more choices and so at
> least in theory should not lead to any regressions.
>
> This patch adds a new type of jump function that simply carries over
> a known base type of the function, adds some information about the
> O_T_R to the indirect edges and substantially improves the code
> combining various types of jump functions when inlining. ?Then the
> framework we already have for indirect inlining works well with only
> minor tweaks to extract types from known global constants and the
> like.
>
> I have bootstrapped and regression tested the patch on x86_64-linux
> with no problems. ?OK for trunk?

...

> Index: icln/gcc/tree.c
> ===================================================================
> *** icln.orig/gcc/tree.c
> --- icln/gcc/tree.c
> *************** lhd_gcc_personality (void)
> *** 10810,10813 ****
> --- 10810,10869 ----
> ? ?return gcc_eh_personality_decl;
> ?}
>
> + /* 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

is of

Ok if Honza acks the inliner/cgraph changes.

Thanks,
Richard.

> + ? ?found, return, otherwise return NULL_TREE. ?*/
> +
> + 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;
> + }
> +
> ?#include "gt-tree.h"
> Index: icln/gcc/tree.h
> ===================================================================
> *** icln.orig/gcc/tree.h
> --- icln/gcc/tree.h
> *************** extern location_t tree_nonartificial_loc
> *** 5087,5092 ****
> --- 5087,5094 ----
>
> ?extern tree block_ultimate_origin (const_tree);
>
> + extern tree get_binfo_at_offset (tree, HOST_WIDE_INT, tree);
> +
> ?/* In tree-nested.c */
> ?extern tree build_addr (tree, tree);
>
> Index: icln/gcc/Makefile.in
> ===================================================================
> *** icln.orig/gcc/Makefile.in
> --- icln/gcc/Makefile.in
> *************** ipa.o : ipa.c $(CONFIG_H) $(SYSTEM_H) co
> *** 2902,2908 ****
> ?ipa-prop.o : ipa-prop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
> ? ? langhooks.h $(GGC_H) $(TARGET_H) $(CGRAPH_H) $(IPA_PROP_H) $(DIAGNOSTIC_H) \
> ? ? $(TREE_FLOW_H) $(TM_H) $(TREE_PASS_H) $(FLAGS_H) $(TREE_H) \
> ! ? ?$(TREE_INLINE_H) $(TIMEVAR_H)
> ?ipa-ref.o : ipa-ref.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
> ? ? langhooks.h $(GGC_H) $(TARGET_H) $(CGRAPH_H) ?$(TREE_H) $(TARGET_H) \
> ? ? $(TREE_FLOW_H) $(TM_H) $(TREE_PASS_H) $(FLAGS_H) $(TREE_H) $(GGC_H)
> --- 2902,2908 ----
> ?ipa-prop.o : ipa-prop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
> ? ? langhooks.h $(GGC_H) $(TARGET_H) $(CGRAPH_H) $(IPA_PROP_H) $(DIAGNOSTIC_H) \
> ? ? $(TREE_FLOW_H) $(TM_H) $(TREE_PASS_H) $(FLAGS_H) $(TREE_H) \
> ! ? ?$(TREE_INLINE_H) $(GIMPLE_H) $(GIMPLE_FOLD_H) $(TIMEVAR_H)
> ?ipa-ref.o : ipa-ref.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
> ? ? langhooks.h $(GGC_H) $(TARGET_H) $(CGRAPH_H) ?$(TREE_H) $(TARGET_H) \
> ? ? $(TREE_FLOW_H) $(TM_H) $(TREE_PASS_H) $(FLAGS_H) $(TREE_H) $(GGC_H)
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]