public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: Richard Biener <richard.guenther@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] ipa: Avoid invalid gimple when IPA-CP and IPA-SRA disagree on types (108384)
Date: Fri, 03 Feb 2023 10:40:28 +0100	[thread overview]
Message-ID: <ri6k00zxf1v.fsf@suse.cz> (raw)
In-Reply-To: <CAFiYyc3N6vaY4R+oaVp1o+t1cbKqvbCmVoKoRMkVgm_GejLyxA@mail.gmail.com>

On Fri, Feb 03 2023, Richard Biener wrote:
> On Thu, Feb 2, 2023 at 5:20 PM Martin Jambor <mjambor@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  <mjambor@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  <mjambor@suse.cz>
>>
>>         PR ipa/108384
>>         * gcc.dg/ipa/pr108384.c: New test.
>> ---

  reply	other threads:[~2023-02-03  9:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 16:19 Martin Jambor
2023-02-03  7:30 ` Richard Biener
2023-02-03  9:40   ` Martin Jambor [this message]
2023-02-03 11:35     ` Richard Biener
2023-02-03 16:49       ` Bernhard Reutner-Fischer
2023-02-06 14:16         ` Martin Jambor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ri6k00zxf1v.fsf@suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).