Hi,

On 24/11/16 19:48, Richard Biener wrote:
On Wed, Nov 23, 2016 at 4:33 PM, Martin Jambor <mjam...@suse.cz> wrote:
Hi,

On Fri, Nov 18, 2016 at 12:38:18PM +1100, kugan wrote:
Hi,

I was relying on ipa_get_callee_param_type to get type of parameter and thenHi,
convert arguments to this type while computing jump functions. However, in
cases like shown in PR78365, ipa_get_callee_param_type, instead of giving
up, would return the wrong type.

At what stage does this happen?  During analysis
(ipa_compute_jump_functions_for_edge) or at WPA
(propagate_constants_accross_call)?  Both?

Hmm, where does jump function compute require the callee type?
In my view the jump function should record

 (expected-incoming-type) arg [OP X]

for each call argument in its body.  Thus required conversions are
done at WPA propagation time.

I think the current uses of
ipa_get_callee_param_type are fine with this.

Attached patch now uses callee's DECL_ARGUMENTS to get the type. If it
cannot be found, then I would give up and set the jump function to varying.

But DECL_ARGUMENTS is not available at WPA stage with LTO so your
patch would make our IPA layer to optimize less with LTO.  This was
the reason to go through the hoops of TYPE_ARG_TYPES in the first
place.

If TYPE_ARG_TYPES cannot be trusted, then I'm afraid we are back to
square one and indeed need to put the correct type in jump functions.

If DECL_ARGUMENTS is not available at WPA stage then I see no other
way than to put the types on the jump functions.

OK. I will record the type in jump function and send a revised patch.

Thanks,
Kugan

If just preferring DECL_ARGUMENTS is enough, then changing
ipa_get_callee_param_type to use that if is is available, as Richi
suggested, would indeed be preferable.  But if even falling back on it
can cause errors, then I am not sure if it helps.

In any event, thanks for diligently dealing with the fallout,

Martin



Bootstrapped and regression tested on x86_64-linux-gnu with no new
regressions. Is this OK for trunk?

Thanks,
Kugan

gcc/testsuite/ChangeLog:

2016-11-18  Kugan Vivekanandarajah  <kug...@linaro.org>

      PR IPA/78365
      * gcc.dg/torture/pr78365.c: New test.

gcc/ChangeLog:

2016-11-18  Kugan Vivekanandarajah  <kug...@linaro.org>

      PR IPA/78365
      * ipa-cp.c (propagate_constants_accross_call): get param type from callees
      DECL_ARGUMENTS if available.
      * ipa-prop.c (ipa_compute_jump_functions_for_edge): Likewise.
      (ipcp_update_vr):  Remove now redundant conversion of precision for VR.
      * ipa-prop.h: Make ipa_get_callee_param_type local again.

Reply via email to