> Hi, > > On Wed, Oct 14 2020, Jan Hubicka wrote: > > Hi, > > here is updated patch with cap on number of iterations. > > I set the limit to 8 and bootstrapped it with additional assert that the > > limit is not met, it did not fire. > > > > Bootstrapped/regtested x86_64-linux, OK? > > > > gcc/ChangeLog: > > > > 2020-10-14 Jan Hubicka <hubi...@ucw.cz> > > > > * doc/invoke.texi: (ipa-jump-function-lookups): Document param. > > * ipa-modref.c (merge_call_side_effects): Use > > unadjusted_ptr_and_unit_offset. > > * ipa-prop.c (unadjusted_ptr_and_unit_offset): New function. > > * ipa-prop.h (unadjusted_ptr_and_unit_offset): Declare. > > * params.opt: (-param-ipa-jump-function-lookups): New. > > > > diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c > > index 2d09d913051..cf3da6a6568 100644 > > --- a/gcc/ipa-prop.c > > +++ b/gcc/ipa-prop.c > > @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see > > #include "domwalk.h" > > #include "builtins.h" > > #include "tree-cfgcleanup.h" > > +#include "options.h" > > > > /* Function summary where the parameter infos are actually stored. */ > > ipa_node_params_t *ipa_node_params_sum = NULL; > > @@ -1222,6 +1223,73 @@ load_from_unmodified_param_or_agg (struct > > ipa_func_body_info *fbi, > > return index; > > } > > > > +/* Walk pointer adjustemnts from OP (such as POINTER_PLUS and ADDR_EXPR) > > + to find original pointer. Initialize RET to the pointer which results > > from > > + the walk. > > + If offset is known return true and initialize OFFSET_RET. */ > > + > > +bool > > +unadjusted_ptr_and_unit_offset (tree op, tree *ret, poly_int64 *offset_ret) > > +{ > > + poly_int64 offset = 0; > > + bool offset_known = true; > > + int i; > > + > > + for (i = 0; i < param_ipa_jump_function_lookups; i++) > > + { > > + if (TREE_CODE (op) == ADDR_EXPR) > > + { > > + poly_int64 extra_offset = 0; > > + tree base = get_addr_base_and_unit_offset (TREE_OPERAND (op, 0), > > + &offset); > > + if (!base) > > + { > > + base = get_base_address (TREE_OPERAND (op, 0)); > > + if (TREE_CODE (base) != MEM_REF) > > + break; > > + offset_known = false; > > Umm, did you really intend to clear offset_known only after the break? > (I may not understand the nuances of the get_base... functions but it > strikes me as odd.)
Yes, offset_known relates to op. We try tolookup base and if it is MEM_REF we will be able to update op. If this is a decl or something else we thus need to give up (since we are required to return pointer). So in first case we will return current op for which offset_known stil lapplies, however if we found MEM_REF we will update op but lose track of offset, since get_addr_base_and_unit_offset failed. Honza > > Thanks, > > Martin