On Fri, Feb 03 2023, Richard Biener wrote:
> On Thu, Feb 2, 2023 at 5:20 PM Martin Jambor <mjam...@suse.cz> wrote:
>>
>> Hi,
>>
>> when the compiled program contains type mismatches between callers and
>> callees when it comes to a parameter, IPA-CP can try to propagate one
>> constant from callers while IPA-SRA may try to split a parameter
>> expecting a value of a different size on the same offset.  This then
>> currently leads to creation of a VIEW_CONVERT_EXPR with mismatching
>> type sizes of LHS and RHS which is correctly flagged by the GIMPLE
>> verifier as invalid.
>>
>> It seems that the best course of action is to try and avoid the
>> situation altogether and so this patch adds a check to IPA-SRA that
>> peeks into the result of IPA-CP and when it sees a value on the same
>> offset but with a mismatching size, it just decides to leave that
>> particular parameter be.
>>
>> Bootstrapped and tested on x86_64-linux, OK for master?
>
> OK.  I suppose there are guards elsewhere that never lets a
> non-UHWI size type (like variable size or poly-int-size) through
> any of the SRA or CP lattices?

SRA tracks its accesses in simple integers so yes for that part.

As far IPA-CP is concerned... all the values tracked conform to
is_gimple_ip_invariant, so are either ADDR_EXPRs of a global variable or
is_gimple_constant's.  So its size should never be variable and I hope
also never a complex poly-int.  If you think it would be better, I can
of course add the check.

Thanks,

Martin


>> gcc/ChangeLog:
>>
>> 2023-02-02  Martin Jambor  <mjam...@suse.cz>
>>
>>         PR ipa/108384
>>         * ipa-sra.cc (push_param_adjustments_for_index): Remove a size check
>>         when comparing to an IPA-CP value.
>>         (dump_list_of_param_indices): New function.
>>         (adjust_parameter_descriptions): Check for mismatching IPA-CP values.
>>         Dump removed candidates using dump_list_of_param_indices.
>>         * ipa-param-manipulation.cc
>>         (ipa_param_body_adjustments::modify_expression): Add assert checking
>>         sizes of a VIEW_CONVERT_EXPR will match.
>>         (ipa_param_body_adjustments::modify_assignment): Likewise.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2023-02-02  Martin Jambor  <mjam...@suse.cz>
>>
>>         PR ipa/108384
>>         * gcc.dg/ipa/pr108384.c: New test.
>> ---

Reply via email to