This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR64277


2015-01-27 13:59 GMT+03:00 Richard Biener <rguenther@suse.de>:
> On Tue, 27 Jan 2015, Ilya Enkovich wrote:
>
>> 2015-01-27 12:47 GMT+03:00 Richard Biener <rguenther@suse.de>:
>> > On Tue, 27 Jan 2015, Jakub Jelinek wrote:
>> >
>> >> On Tue, Jan 27, 2015 at 10:25:48AM +0100, Richard Biener wrote:
>> >> >
>> >> > This disables array-bound warnings from VRP2 as discussed.
>> >> >
>> >> > Bootstrapped and tested on x86_64-unknown-linux-gnu - ok for trunk?
>> >>
>> >> So nothing in the testsuite needed to change?  Nice.
>> >
>> > Yes.
>> >
>> >> Ok for trunk.
>> >>
>> >> > I'll search for duplicates and add a few testcases.
>> >>
>> >> Thanks.
>> >
>> > Committed as follows (first testcase in PR59124 not fixed - it warns
>> > from the first pass).
>>
>> Are you going to port it to 4.9 branch?
>
> I plan to do that (4.8 as well) after some time.

Great, thanks!

Ilya

>
> Richard.
>
>> Thanks,
>> Ilya
>>
>> >
>> > 2015-01-27  Richard Biener  <rguenther@suse.de>
>> >
>> >         PR tree-optimization/56273
>> >         PR tree-optimization/59124
>> >         PR tree-optimization/64277
>> >         * tree-vrp.c (vrp_finalize): Emit array-bound warnings only
>> >         from the first VRP pass.
>> >
>> >         * g++.dg/warn/Warray-bounds-6.C: New testcase.
>> >         * gcc.dg/Warray-bounds-12.c: Likewise.
>> >         * gcc.dg/Warray-bounds-13.c: Likewise.
>> >
>> > Index: gcc/tree-vrp.c
>> > ===================================================================
>> > *** gcc/tree-vrp.c.orig 2015-01-27 10:34:26.453743828 +0100
>> > --- gcc/tree-vrp.c      2015-01-27 10:43:04.970610102 +0100
>> > *************** vrp_finalize (void)
>> > *** 10229,10235 ****
>> >     substitute_and_fold (op_with_constant_singleton_value_range,
>> >                        vrp_fold_stmt, false);
>> >
>> > !   if (warn_array_bounds)
>> >       check_all_array_refs ();
>> >
>> >     /* We must identify jump threading opportunities before we release
>> > --- 10229,10235 ----
>> >     substitute_and_fold (op_with_constant_singleton_value_range,
>> >                        vrp_fold_stmt, false);
>> >
>> > !   if (warn_array_bounds && first_pass_instance)
>> >       check_all_array_refs ();
>> >
>> >     /* We must identify jump threading opportunities before we release
>> > Index: gcc/testsuite/g++.dg/warn/Warray-bounds-6.C
>> > ===================================================================
>> > *** /dev/null   1970-01-01 00:00:00.000000000 +0000
>> > --- gcc/testsuite/g++.dg/warn/Warray-bounds-6.C 2015-01-27 10:40:31.311871855 +0100
>> > ***************
>> > *** 0 ****
>> > --- 1,26 ----
>> > + // { dg-do compile }
>> > + // { dg-options "-O3 -Warray-bounds" }
>> > +
>> > + struct type {
>> > +     bool a, b;
>> > +     bool get_b() { return b; }
>> > + };
>> > +
>> > + type stuff[9u];
>> > +
>> > + void bar();
>> > +
>> > + void foo()
>> > + {
>> > +   for(unsigned i = 0u; i < 9u; i++)
>> > +     {
>> > +       if(!stuff[i].a)
>> > +       continue;
>> > +
>> > +       bar();
>> > +
>> > +       for(unsigned j = i + 1u; j < 9u; j++)
>> > +       if(stuff[j].a && stuff[j].get_b()) // { dg-bogus "above array bounds" }
>> > +         return;
>> > +     }
>> > + }
>> > Index: gcc/testsuite/gcc.dg/Warray-bounds-12.c
>> > ===================================================================
>> > *** /dev/null   1970-01-01 00:00:00.000000000 +0000
>> > --- gcc/testsuite/gcc.dg/Warray-bounds-12.c     2015-01-27 10:40:58.196175989 +0100
>> > ***************
>> > *** 0 ****
>> > --- 1,26 ----
>> > + /* { dg-do compile } */
>> > + /* { dg-options "-O3 -Warray-bounds" } */
>> > + /* { dg-additional-options "-mssse3" { target x86_64-*-* i?86-*-* } } */
>> > +
>> > + void foo(short a[], short m)
>> > + {
>> > +   int i, j;
>> > +   int f1[10];
>> > +   short nc;
>> > +
>> > +   nc = m + 1;
>> > +   if (nc > 3)
>> > +     {
>> > +       for (i = 0; i <= nc; i++)
>> > +       {
>> > +         f1[i] = f1[i] + 1;
>> > +       }
>> > +     }
>> > +
>> > +   for (i = 0, j = m; i < nc; i++, j--)
>> > +     {
>> > +       a[i] = f1[i]; /* { dg-bogus "above array bounds" } */
>> > +       a[j] = i;
>> > +     }
>> > +   return;
>> > + }
>> > Index: gcc/testsuite/gcc.dg/Warray-bounds-13.c
>> > ===================================================================
>> > *** /dev/null   1970-01-01 00:00:00.000000000 +0000
>> > --- gcc/testsuite/gcc.dg/Warray-bounds-13.c     2015-01-27 10:42:43.738369929 +0100
>> > ***************
>> > *** 0 ****
>> > --- 1,18 ----
>> > + /* { dg-do compile } */
>> > + /* { dg-options "-O3 -Warray-bounds" } */
>> > +
>> > + extern char *bar[17];
>> > +
>> > + int foo(int argc, char **argv)
>> > + {
>> > +   int i;
>> > +   int n = 0;
>> > +
>> > +   for (i = 0; i < argc; i++)
>> > +     n++;
>> > +
>> > +   for (i = 0; i < argc; i++)
>> > +     argv[i] = bar[i + n]; /* { dg-bogus "above array bounds" } */
>> > +
>> > +   return 0;
>> > + }
>>
>>
>
> --
> Richard Biener <rguenther@suse.de>
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Jennifer Guild,
> Dilip Upmanyu, Graham Norton HRB 21284 (AG Nuernberg)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]