On Mon, Dec 12, 2016 at 8:57 AM, kugan <kugan.vivekanandara...@linaro.org> wrote: > Hi Richard, > >>> I am fine with the new patch but you'll need an approval from Honza >>> or Richi. >>> >>> I find it a bit saddening that we cannot really rely on >>> gimple_call_fntype but at least I do not see any other way. >> >> >> The patch looks somewhat backward. It populates the param type from >> the callee but the only thing we really know is the _originating_ type >> from the callers DECL_ARGUMENTS (if the JF is based on a parameter > > > I am not sure I understood this. I think we get param_type from callees > DECL_ARGUMENTS. > >> which is the only case where we do not know the type of the actual >> value statically -- we only know the type we expect). >> >> So the type would be present only on IPA_JF_PASS_THROUGH JFs >> (? does that also cover modified params?). >> >> At propagation time when applying the jump-function we have to make >> sure to first convert the actual parameter value to that expected type >> (or drop to BOTTOM if we can't do that conversion due to excess >> mismatches). > > > From ipa vrp point of view, that is what is being done with the patch (In > this version, I also changed the POINTER_TYPE_P to use param_type). At the > point we create ipa_compute_jump_functions_for_edge, we are covering the VR > for arguments to param_type. > > In propagate_vr_accross_jump_function also, we are doing the conversion.
Hum, I think what your patch does is only half-way correct. I'm looking a bit more into how the IPA propagation works and it looks like it's not the JF where the type needs to be stored but the lattice itself -- we need to know at propagation time what type we expect for the arguments. And if there's a mismatch with the actual type flowing through the JF then we need to convert or punt. And looking closer that type should get known during propagation as at that time we should have the actual parameter types as seen in the function body. And ipa_get_callee_param_type should go away - just use jfunc->param_type = TREE_TYPE (arg); (well, and no need to store that redundant information in the jump function -- it's there for all but pass-through JFs by means of the JF -- and pass-through JFs get their type at propagation time from the source lattice values) So we just need to get propagation correct (and not fiddle strangely with types in JF building). Richard. > Thanks, > Kugan