public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PR 88214] Check that an argument is pointer before attempting agg jf construction from it
Date: Wed, 16 Jan 2019 15:26:00 -0000	[thread overview]
Message-ID: <ri6sgxs1v51.fsf@suse.cz> (raw)
In-Reply-To: <CAFiYyc3QmA+giL9hUsUsb21tEJCqhFHi=4UXmXzKt6_YJTVV7Q@mail.gmail.com>

Hi,

On Mon, Dec 10 2018, Richard Biener wrote:
> On Fri, Dec 7, 2018 at 3:59 PM Martin Jambor <mjambor@suse.cz> wrote:
>>
>> Hi,
>>
>> ICE in PR 88214 happens because a type-mismatch in K&R C code makes
>> IPA-CP analysis call ao_ref_init_from_ptr_and_size on an integer
>> SSA_NAME, this function in turn constructs a temporary MEM_REF based on
>> that integer SSA_NAME and then later on call_may_clobber_ref_p_1 treats
>> the MEM_REF base as a pointer, gets its SSA_NAME_PTR_INFO and tries to
>> work with bitmaps there.  But because the SSA_NAME is an integer, there
>> is no SSA_NAME_PTR_INFO, there is range info instead and this leads to a
>> crash.
>>

...

>> The bug itself can be fixed with the patch below.  I have verified it
>> avoids the ICE on powerpc64-linux and did a full bootstrap and test on
>> an x86_64-linux.  The patch is simple enough that I believe that is good
>> enough.
>
> OK.
>
> Richard.

I have bootstrapped the patch on gcc-8 an gcc-7 branches too and will
commit it there in a few moments too.

Thanks,

Martin


>
>>
>> 2018-12-06  Martin Jambor  <mjambor@suse.cz>
>>
>>         PR ipa/88214
>>         * ipa-prop.c (determine_locally_known_aggregate_parts): Make sure
>>         we check pointers against pointers.
>>
>>         testsuite/
>>         * gcc.dg/ipa/pr88214.c: New test.
>> ---
>>  gcc/ipa-prop.c                     |  3 ++-
>>  gcc/testsuite/gcc.dg/ipa/pr88214.c | 10 ++++++++++
>>  2 files changed, 12 insertions(+), 1 deletion(-)
>>  create mode 100644 gcc/testsuite/gcc.dg/ipa/pr88214.c
>>
>> diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
>> index 74052350ac1..4dbe26829e3 100644
>> --- a/gcc/ipa-prop.c
>> +++ b/gcc/ipa-prop.c
>> @@ -1569,7 +1569,8 @@ determine_locally_known_aggregate_parts (gcall *call, tree arg,
>>        if (TREE_CODE (arg) == SSA_NAME)
>>         {
>>           tree type_size;
>> -          if (!tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (arg_type))))
>> +          if (!tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (arg_type)))
>> +             || !POINTER_TYPE_P (TREE_TYPE (arg)))
>>              return;
>>           check_ref = true;
>>           arg_base = arg;
>> diff --git a/gcc/testsuite/gcc.dg/ipa/pr88214.c b/gcc/testsuite/gcc.dg/ipa/pr88214.c
>> new file mode 100644
>> index 00000000000..4daa9829e75
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/ipa/pr88214.c
>> @@ -0,0 +1,10 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O2" } */
>> +
>> +void i();
>> +  short a;
>> +  void b(e) char * e;
>> +  {
>> +    i();
>> +    b(a);
>> +  }
>> --
>> 2.19.1
>>
>>
>>

      parent reply	other threads:[~2019-01-16 15:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-07 14:59 Martin Jambor
2018-12-10 10:27 ` Richard Biener
2018-12-20 14:21   ` Martin Jambor
2019-01-16 15:26   ` Martin Jambor [this message]

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=ri6sgxs1v51.fsf@suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    /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).