>
> Yep, there is such code in place. It is done by
> insert_bndret_call_after. You are right, I should use the same
> interface for both these cases.
That would be nice indeed. We should separate out and unify the code for
porducing
a wrapper call next stage1 (as Jeff mentions too).
>
> >> > + if (instrumentation_clone
> >> > + && !DECL_BY_REFERENCE (resdecl)
> >> > + && restmp
> >> > + && BOUNDED_P (restmp))
> >> > + {
> >> > + tree fn = targetm.builtin_chkp_function
> >> > (BUILT_IN_CHKP_BNDRET);
> >> > + gcall *retbnd = gimple_build_call (fn, 1, restmp);
> >> > +
> >> > + resbnd = create_tmp_reg (pointer_bounds_type_node,
> >> > "retbnd");
> >> > + gimple_call_set_lhs (retbnd, resbnd);
> >> > +
> >> > + gsi_insert_after (&bsi, retbnd, GSI_NEW_STMT);
> >> > + create_edge (get_create (fn), retbnd, callees->count,
> >> > callees->frequency);
> >> > + }
> >
> > I am not sure why we need to check here: Originaly we have two bounded
> > functions, A and B.
> > We turn function B to a wrapper of function A. If callers of bounded
> > functions need
> > to call a builtin, I would expect all callers of B to do it already, so I
> > would expect
> > that wrapper is safe here?
>
> The problem with instrumented call is that instrumented function
> returns two values and call lhs gets only the first one. Thus we
> generate bndret call to get the second one to build own return with
> two values.
I see, patch is OK then (preferably merging as much as possible with ipa-split)
Honza
>
> >
> > Or do we mix instrumented and non-instrumented versions somehow?
> >
> > Addding code handling return value is going to turn the call to
> > non-tailcall, so you probably
> > want to drop the tailcall flag, too.
>
> No, function still return what the last call return, thus may keep tailcall.
>
> Thanks,
> Ilya
>
> >
> > Honza