Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-23 Thread Qing Zhao
> On May 23, 2024, at 10:13, David Malcolm wrote: > > On Thu, 2024-05-23 at 14:03 +0000, Qing Zhao wrote: > > [...snip...] > >> Is “location_adhoc_data” an available data structure in current GCC? >> I just searched GCC source tree, cannot find it. > >

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-23 Thread Qing Zhao
> On May 23, 2024, at 07:46, Richard Biener wrote: > > On Wed, May 22, 2024 at 8:53 PM Qing Zhao wrote: >> >> >> >>> On May 22, 2024, at 03:38, Richard Biener >>> wrote: >>> >>> On Tue, May 21, 2024 at 11:36 PM David Mal

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-22 Thread Qing Zhao
> On May 22, 2024, at 03:38, Richard Biener wrote: > > On Tue, May 21, 2024 at 11:36 PM David Malcolm wrote: >> >> On Tue, 2024-05-21 at 15:13 +, Qing Zhao wrote: >>> Thanks for the comments and suggestions. >>> >>>> O

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-21 Thread Qing Zhao
Thanks for the comments and suggestions. > On May 15, 2024, at 10:00, David Malcolm wrote: > > On Tue, 2024-05-14 at 15:08 +0200, Richard Biener wrote: >> On Mon, 13 May 2024, Qing Zhao wrote: >> >>> -Warray-bounds is an important option to enable linux kernal

3rd Ping [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-20 Thread Qing Zhao
024, at 10:14, Qing Zhao wrote: > > > >> On May 7, 2024, at 10:02, Qing Zhao wrote: >> >> 2nd Ping for the middle-end change approval. -:) >> >> **Approval status: >> >> All C FE changes have been approved. >> >> **Revi

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-15 Thread Qing Zhao
> On May 15, 2024, at 02:09, Richard Biener wrote: > > On Tue, 14 May 2024, Qing Zhao wrote: > >> >> >>> On May 14, 2024, at 13:14, Richard Biener wrote: >>> >>> On Tue, 14 May 2024, Qing Zhao wrote: >>> >&g

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 14, 2024, at 13:14, Richard Biener wrote: > > On Tue, 14 May 2024, Qing Zhao wrote: > >> >> >>> On May 14, 2024, at 10:29, Richard Biener wrote: >>> > [...] >>> It would of course >>> need experimenting since we c

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 14, 2024, at 11:08, Jeff Law wrote: > > > > On 5/14/24 8:57 AM, Qing Zhao wrote: >>> On May 13, 2024, at 20:14, Kees Cook wrote: >>> >>> On Tue, May 14, 2024 at 01:38:49AM +0200, Andrew Pinski wrote: >>>> On Mon, May 13, 2024,

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 14, 2024, at 10:29, Richard Biener wrote: > > On Tue, 14 May 2024, Qing Zhao wrote: > >> >> >>> On May 14, 2024, at 09:08, Richard Biener wrote: >>> >>> On Mon, 13 May 2024, Qing Zhao wrote: >>> >>>&

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 13, 2024, at 20:14, Kees Cook wrote: > > On Tue, May 14, 2024 at 01:38:49AM +0200, Andrew Pinski wrote: >> On Mon, May 13, 2024, 11:41 PM Kees Cook wrote: >>> But it makes no sense to warn about: >>> >>> void sparx5_set (int * ptr, struct nums * sg, int index) >>> { >>> if (index

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 14, 2024, at 09:08, Richard Biener wrote: > > On Mon, 13 May 2024, Qing Zhao wrote: > >> -Warray-bounds is an important option to enable linux kernal to keep >> the array out-of-bound errors out of the source tree. >> >> However, due to

[RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-13 Thread Qing Zhao
-Warray-bounds is an important option to enable linux kernal to keep the array out-of-bound errors out of the source tree. However, due to the false positive warnings reported in PR109071 (-Warray-bounds false positive warnings due to code duplication from jump threading), -Warray-bounds=1 cannot

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-08 Thread Qing Zhao
> On May 7, 2024, at 17:52, Kees Cook wrote: > > On Tue, May 07, 2024 at 06:34:19PM +0000, Qing Zhao wrote: >> On May 7, 2024, at 13:57, Sebastian Huber >> wrote: >>> On 07.05.24 16:26, Qing Zhao wrote: >>>> Hi, Sebastian, >>>> Than

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-07 Thread Qing Zhao
(Resend since my previous email in HTML and inline quoting wasn’t work, I changed the mail setting, hopefully this time it’s good). Sorry for the inconvenience. > On May 7, 2024, at 13:57, Sebastian Huber > wrote: > > On 07.05.24 16:26, Qing Zhao wrote: >> Hi, Sebastian,

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-07 Thread Qing Zhao
On May 7, 2024, at 13:57, Sebastian Huber wrote: On 07.05.24 16:26, Qing Zhao wrote: Hi, Sebastian, Thanks for your explanation. Our goal is to deprecate the GCC extension on structure containing a flexible array member not at the end of another structure. In order to achieve this goal, we

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-07 Thread Qing Zhao
wrote: > > On 06.05.24 16:20, Qing Zhao wrote: >> Hi, Sebastian, >> Looks like that the behavior you described is correct. >> What’s your major concern? ( a little confused). > > I am concerned that the static initialization of structures with flexible > array members no

Re: Ping * 2 [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-07 Thread Qing Zhao
On May 7, 2024, at 10:02, Qing Zhao wrote: 2nd Ping for the middle-end change approval. -:) **Approval status: All C FE changes have been approved. **Review status: All Middle-end changes have been reviewed by Sid, no remaining issue. Okay for GCC15? For convenience

Ping * 2 [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-07 Thread Qing Zhao
2nd Ping for the middle-end change approval. -:) **Approval status: All C FE changes have been approved. **Review status: All Middle-end changes have been reviewed by Sid, no remaining issue. Okay for GCC15? thanks. Qing Begin forwarded message: From: Qing Zhao Subject: Re

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-06 Thread Qing Zhao
Hi, Sebastian, Looks like that the behavior you described is correct. What’s your major concern? ( a little confused). Qing On May 6, 2024, at 09:29, Sebastian Huber wrote: On 06.05.24 09:08, Richard Biener wrote: On Sat, 4 May 2024, Sebastian Huber wrote: On 07.08.23 16:22, Qing Zhao via

[PATCH v5 4/4] Update the C/C++ FEs routine

2024-05-01 Thread Qing Zhao
"add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle the cases when the DECL is union. Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the

[PATCH v5 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-05-01 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v5 2/4] C and C++ FE changes

2024-05-01 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or

[PATCH v5 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

[PATCH v5 0/4]Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
Hi, This is the 5th version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html The 2nd version is at:

Re: [PATCH v4 4/4] Update the C/C++ FE routines

2024-05-01 Thread Qing Zhao
On May 1, 2024, at 09:35, Jason Merrill wrote: On 5/1/24 08:19, Qing Zhao wrote: "add_flexible_array_elts_to_size" and "layout_var_decl" to handle the cases when the DECL is union. Add testing cases to test the _bos for flexible array members in unions or alone

[PATCH v4 2/4] C and C++ FE changes

2024-05-01 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or

[PATCH v4 4/4] Update the C/C++ FE routines

2024-05-01 Thread Qing Zhao
"add_flexible_array_elts_to_size" and "layout_var_decl" to handle the cases when the DECL is union. Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the cases

[PATCH v4 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-05-01 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v4 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

[PATCH v4 0/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
Hi, This is the 4th version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html The 2nd version is at:

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
On Apr 30, 2024, at 17:55, Kees Cook wrote: On Tue, Apr 30, 2024 at 05:51:20PM -0400, Jason Merrill wrote: On 4/30/24 14:45, Qing Zhao wrote: On Apr 30, 2024, at 15:27, Jason Merrill wrote: On 4/30/24 07:58, Qing Zhao wrote: The request for GCC to accept that the C99 flexible array member

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
> On Apr 30, 2024, at 15:52, Jason Merrill wrote: > > On 4/30/24 14:49, Qing Zhao wrote: >>> On Apr 30, 2024, at 15:45, Qing Zhao wrote: >>> >>> >>> >>>>> gcc/doc/extend.texi | 34 ++ >&g

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
On Apr 30, 2024, at 15:45, Qing Zhao wrote: gcc/doc/extend.texi | 34 ++ 1 file changed, 34 insertions(+) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 7b54a241a7bf..cba98c8aadd7 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
On Apr 30, 2024, at 15:27, Jason Merrill wrote: On 4/30/24 07:58, Qing Zhao wrote: The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC

Re: [PATCH v3 4/4] Update the C FE routine "add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle the cases when the DECL is union.

2024-04-30 Thread Qing Zhao
On Apr 30, 2024, at 15:29, Jason Merrill wrote: On 4/30/24 07:58, Qing Zhao wrote: Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the cases when the DECL is union. gcc/cp

[PATCH v3 4/4] Update the C FE routine "add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle the cases when the DECL is union.

2024-04-30 Thread Qing Zhao
Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the cases when the DECL is union. gcc/cp/ChangeLog: * decl.cc (layout_var_decl): Handle the cases when

[PATCH v3 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-04-30 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v3 2/4] C and C++ FE changes

2024-04-30 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or

[PATCH v3 0/4]Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
Hi, This is the 3rd version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html The 2nd version is at:

[PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

Re: [PATCH v2 3/3] Add testing cases for flexible array members in unions and alone in structures.

2024-04-25 Thread Qing Zhao
> On Apr 25, 2024, at 10:13, Siddhesh Poyarekar wrote: > > On 2024-04-25 10:06, Qing Zhao wrote: >> gcc/testsuite/ChangeLog: >> * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. >> * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase.

[PATCH v2 3/3] Add testing cases for flexible array members in unions and alone in structures.

2024-04-25 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v2 0/3] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-25 Thread Qing Zhao
Hi, This is the 2nd version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html) compared to the 1st version, the major difference are: A. C FE updates based

[PATCH v2 2/3] C and C++ FE changes

2024-04-25 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or

[PATCH v2 1/3] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-25 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

Re: [RFC][PATCH v1 2/4] C and C++ FE changes to support flexible array members in unions and alone in structures.

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 15:51, Joseph Myers wrote: > > On Fri, 19 Apr 2024, Qing Zhao wrote: > >> gcc/c/ChangeLog: >> >> * c-decl.cc (finish_struct): Change errors to pedwarns for the cases >> flexible array members in union or alone in stru

Re: [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-04-23 Thread Qing Zhao
024, at 09:54, Qing Zhao wrote: > > Hi, > > This is the 9th version of the patch. > > Compare with the 8th version, the difference are: > > updates per Joseph's comments: > > 1. in C FE, add checking for counted_by attribute for the new multiple > definitions of

Re: [RFC][PATCH v1 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 14:53, Joseph Myers wrote: > > On Fri, 19 Apr 2024, Qing Zhao wrote: > >> gcc/testsuite/ChangeLog: >> >> * gcc.dg/flex-array-in-union-1.c: New test. >> * gcc.dg/flex-array-in-union-2.c: New test. > > Th

Re: [RFC][PATCH v1 1/4] Documentation change

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 15:03, Joseph Myers wrote: > > On Tue, 23 Apr 2024, Qing Zhao wrote: > >> However, I am not very confident on the wording of the doc, is the >> current wording good enough for this? Or do you have any suggestion on >> how to make it

Re: [RFC][PATCH v1 1/4] Documentation change

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 14:04, Joseph Myers wrote: > > On Fri, 19 Apr 2024, Qing Zhao wrote: > >> +The size of the union is as if the flexiable array member were omitted >> +except that it may have more trailing padding than the omission would imply. > > "

Re: [PATCH v9 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-22 Thread Qing Zhao
Thanks a lot. Qing > On Apr 22, 2024, at 16:38, Joseph Myers wrote: > > This version of patch 1/5 is OK for GCC 15. > > -- > Joseph S. Myers > josmy...@redhat.com >

Re: [RFC][PATCH v1 1/4] Documentation change

2024-04-22 Thread Qing Zhao
> On Apr 19, 2024, at 16:54, Tom Tromey wrote: > >>>>>> Qing Zhao writes: > >> +The size of the union is as if the flexiable array member were omitted >> +except that it may have more trailing padding than the omission would imply. >> + >>

[RFC][PATCH v1 4/4] Adjust testcases for flexible array member in union and alone in structure extension.

2024-04-19 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/builtin-clear-padding-3.c: Adjust testcase. * g++.dg/ext/flexary12.C: Likewise. * g++.dg/ext/flexary19.C: Likewise. * g++.dg/ext/flexary2.C: Likewise. * g++.dg/ext/flexary3.C: Likewise. *

[RFC][PATCH v1 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-04-19 Thread Qing Zhao
gcc/testsuite/ChangeLog: * gcc.dg/flex-array-in-union-1.c: New test. * gcc.dg/flex-array-in-union-2.c: New test. --- gcc/testsuite/gcc.dg/flex-array-in-union-1.c | 37 + gcc/testsuite/gcc.dg/flex-array-in-union-2.c | 42 2 files changed, 79

[RFC][PATCH v1 1/4] Documentation change

2024-04-19 Thread Qing Zhao
for allow flexible array members in unions and alone in structures [PR53548] The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has

[RFC][PATCH v1 2/4] C and C++ FE changes to support flexible array members in unions and alone in structures.

2024-04-19 Thread Qing Zhao
gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or alone in structures. gcc/cp/ChangeLog: * class.cc (diagnose_flexarrays): Change error to pdewarn for the case flexible array members alone in

[RFC][PATCH v1 0/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-19 Thread Qing Zhao
Hi, The request for GCC to accept that the C99 flexible array member can be in a union or alone in a struct has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

[PATCH v9 4/5] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-04-12 Thread Qing Zhao
gcc/c-family/ChangeLog: * c-ubsan.cc (get_bound_from_access_with_size): New function. (ubsan_instrument_bounds): Handle call to .ACCESS_WITH_SIZE. gcc/testsuite/ChangeLog: * gcc.dg/ubsan/flex-array-counted-by-bounds-2.c: New test. *

[PATCH v9 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-04-12 Thread Qing Zhao
gcc/ChangeLog: * tree-object-size.cc (access_with_size_object_size): New function. (call_object_size): Call the new function. gcc/testsuite/ChangeLog: * gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT. * gcc.dg/flex-array-counted-by-3.c: New test.

[PATCH v9 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-04-12 Thread Qing Zhao
to carry the TYPE of the flexible array. Such information is needed during tree-object-size.cc. We cannot use the result type or the type of the 1st argument of the routine .ACCESS_WITH_SIZE to decide the element type of the original array due to possible type casting in the source code.

[PATCH v9 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-04-12 Thread Qing Zhao
Including the following changes: * The definition of the new internal function .ACCESS_WITH_SIZE in internal-fn.def. * C FE converts every reference to a FAM with a "counted_by" attribute to a call to the internal function .ACCESS_WITH_SIZE. (build_component_ref in c_typeck.cc) This

[PATCH v9 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-12 Thread Qing Zhao
'counted_by (COUNT)' The 'counted_by' attribute may be attached to the C99 flexible array member of a structure. It indicates that the number of the elements of the array is given by the field "COUNT" in the same structure as the flexible array member. GCC may use this

[PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-04-12 Thread Qing Zhao
Hi, This is the 9th version of the patch. Compare with the 8th version, the difference are: updates per Joseph's comments: 1. in C FE, add checking for counted_by attribute for the new multiple definitions of the same tag for C23 in the routine "tagged_types_tu_compatible_p". Add a new

Re: [PATCH v8 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-04-11 Thread Qing Zhao
Sid and Richard, The C FE changes in this patch has been approved by Joseph. Could you please review the Middle-end change? thanks. Qing > On Apr 10, 2024, at 14:36, Joseph Myers wrote: > > On Fri, 29 Mar 2024, Qing Zhao wrote: > >> +/* For a SUBDATUM field of a struct

Re: [PATCH v8 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-04-11 Thread Qing Zhao
Sid, Thanks a lot for your review. Richard, Could you please comment on this patch? Is the middle-end part Okay for stage 1? Thanks. Qing On Apr 10, 2024, at 17:48, Siddhesh Poyarekar wrote: On 2024-03-29 12:07, Qing Zhao wrote: to carry the TYPE of the flexible array. Such information

Re: [PATCH v8 4/5] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-04-11 Thread Qing Zhao
Sid, Thanks a lot for the review. > On Apr 10, 2024, at 17:46, Siddhesh Poyarekar wrote: > > On 2024-03-29 12:07, Qing Zhao wrote: >> gcc/c-family/ChangeLog: >> * c-ubsan.cc (get_bound_from_access_with_size): New function. >> (ubsan_inst

Re: [PATCH v8 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-04-11 Thread Qing Zhao
Sid, Thanks a lot for your review! > On Apr 10, 2024, at 17:45, Siddhesh Poyarekar wrote: > > On 2024-03-29 12:07, Qing Zhao wrote: >> gcc/ChangeLog: >> * tree-object-size.cc (access_with_size_object_size): New function. >> (call_object_size): Call the new

Re: [PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-11 Thread Qing Zhao
> On Apr 10, 2024, at 17:56, Joseph Myers wrote: > > On Wed, 10 Apr 2024, Qing Zhao wrote: > >> Okay, the above is very clear, thanks a lot for the explanation. >> So, basically, for “counted-by” attribute: >> **The following is good: >> struc

Re: [PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-11 Thread Qing Zhao
> On Apr 11, 2024, at 02:02, Martin Uecker wrote: > > Am Mittwoch, dem 10.04.2024 um 19:35 + schrieb Qing Zhao: >> >>> On Apr 10, 2024, at 15:05, Martin Uecker wrote: >>> >>> Am Mittwoch, dem 10.04.2024 um 20:25 +0200 schrieb Martin Uecker:

Re: [PATCH v8 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-04-10 Thread Qing Zhao
Thanks a lot for your review. Will fix these typos before committing to GCC15. Qing > On Apr 10, 2024, at 14:36, Joseph Myers wrote: > > On Fri, 29 Mar 2024, Qing Zhao wrote: > >> +/* For a SUBDATUM field of a structure or union DATUM, generate a REF to >> + the ob

Re: [PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-10 Thread Qing Zhao
> On Apr 10, 2024, at 15:05, Martin Uecker wrote: > > Am Mittwoch, dem 10.04.2024 um 20:25 +0200 schrieb Martin Uecker: >> Am Mittwoch, dem 10.04.2024 um 17:35 + schrieb Joseph Myers: >>> On Fri, 29 Mar 2024, Qing Zhao wrote: >>> >>>> + /* Iss

Re: [PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-10 Thread Qing Zhao
> On Apr 10, 2024, at 14:44, Joseph Myers wrote: > > On Wed, 10 Apr 2024, Qing Zhao wrote: > >> A stupid question first, the same scope means the same file? (Or same >> function) > > struct X { int a; }; > struct X { int a; }; > > is an example of t

Re: [PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-10 Thread Qing Zhao
Thanks for the comments. > On Apr 10, 2024, at 13:35, Joseph Myers wrote: > > On Fri, 29 Mar 2024, Qing Zhao wrote: > >> + /* Issue error when there is a counted_by attribute with a different >> + field as the argument for the same flexible array member field.

Re: [PATCH][Backport][GCC10] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]

2024-04-02 Thread Qing Zhao
On Apr 2, 2024, at 03:06, Richard Biener wrote: On Mon, Apr 1, 2024 at 3:36 PM Qing Zhao mailto:qing.z...@oracle.com>> wrote: This is a bug in tree-ssa-math-opts.c, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if Y

[PATCH][Backport][GCC10] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]

2024-04-01 Thread Qing Zhao
This is a bug in tree-ssa-math-opts.c, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if YES, we should avoid the transformation. PR tree-optimization/111407 gcc/ChangeLog: * tree-ssa-math-opts.c

[PATCH][Backport][GCC11] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]

2024-04-01 Thread Qing Zhao
This is a bug in tree-ssa-math-opts.c, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if YES, we should avoid the transformation. PR tree-optimization/111407 gcc/ChangeLog: * tree-ssa-math-opts.c

[PATCH][Backport][GCC12] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]

2024-04-01 Thread Qing Zhao
This is a bug in tree-ssa-math-opts.cc, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if YES, we should avoid the transformation. PR tree-optimization/111407 gcc/ChangeLog: * tree-ssa-math-opts.cc

[PATCH][Backport][GCC13] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]

2024-04-01 Thread Qing Zhao
This is a bug in tree-ssa-math-opts.cc, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if YES, we should avoid the transformation. PR tree-optimization/111407 gcc/ChangeLog: * tree-ssa-math-opts.cc

Re: [PATCH v8 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-03-29 Thread Qing Zhao
bound sanitizer and dynamic object size, etc. So, let’s delay the possible support to gdb in a later patch. Does this sound reasonable to you? Qing > On Mar 29, 2024, at 15:16, Kees Cook wrote: > > On Fri, Mar 29, 2024 at 12:09:15PM -0600, Tom Tromey wrote: >>>>

[PATCH v8 4/5] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-03-29 Thread Qing Zhao
gcc/c-family/ChangeLog: * c-ubsan.cc (get_bound_from_access_with_size): New function. (ubsan_instrument_bounds): Handle call to .ACCESS_WITH_SIZE. gcc/testsuite/ChangeLog: * gcc.dg/ubsan/flex-array-counted-by-bounds-2.c: New test. *

[PATCH v8 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-03-29 Thread Qing Zhao
gcc/ChangeLog: * tree-object-size.cc (access_with_size_object_size): New function. (call_object_size): Call the new function. gcc/testsuite/ChangeLog: * gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT. * gcc.dg/flex-array-counted-by-3.c: New test.

[PATCH v8 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-03-29 Thread Qing Zhao
Including the following changes: * The definition of the new internal function .ACCESS_WITH_SIZE in internal-fn.def. * C FE converts every reference to a FAM with a "counted_by" attribute to a call to the internal function .ACCESS_WITH_SIZE. (build_component_ref in c_typeck.cc) This

[PATCH v8 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-03-29 Thread Qing Zhao
to carry the TYPE of the flexible array. Such information is needed during tree-object-size.cc. We cannot use the result type or the type of the 1st argument of the routine .ACCESS_WITH_SIZE to decide the element type of the original array due to possible type casting in the source code.

[PATCH v8 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-03-29 Thread Qing Zhao
Hi, This is the 8th version of the patch. compare with the 7th version, the difference are: updates per Joseph's comments: 1. Wording changes in diagnostics; "non flexible" to "non-flexible"; Diagnostics starts with a lowercase letter; 2. Documentation changes: "named ``@var{count}''

[PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-03-29 Thread Qing Zhao
'counted_by (COUNT)' The 'counted_by' attribute may be attached to the C99 flexible array member of a structure. It indicates that the number of the elements of the array is given by the field "COUNT" in the same structure as the flexible array member. GCC may use this

Re: [PATCH v7 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-03-27 Thread Qing Zhao
> On Mar 26, 2024, at 13:20, Joseph Myers wrote: > > On Tue, 26 Mar 2024, Qing Zhao wrote: > >>> What happens when there are multiple counted_by attributes on the same >>> field? As far as I can see, all but one end up being ignored (by the code >&g

Re: [PATCH v7 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-03-26 Thread Qing Zhao
> On Mar 26, 2024, at 11:21, Joseph Myers wrote: > > On Tue, 26 Mar 2024, Qing Zhao wrote: > >>>> +@cindex @code{counted_by} variable attribute >>>> +@item counted_by (@var{count}) >>>> +The @code{counted_by} attribute may be attached to th

Re: [PATCH v7 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-03-26 Thread Qing Zhao
Thanks, will update. Qing > On Mar 25, 2024, at 16:50, Joseph Myers wrote: > > On Wed, 20 Mar 2024, Qing Zhao wrote: > >> + the size of the element can be retrived from the result type of the call, >> + which is the pointer to the array type. */ >

Re: [PATCH v7 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-03-26 Thread Qing Zhao
> On Mar 25, 2024, at 16:48, Joseph Myers wrote: > > On Wed, 20 Mar 2024, Qing Zhao wrote: > >> + /* get the TYPE of the counted_by field. */ > > Start comments with an uppercase letter. Okay. > >> + The type of the first argument o

Re: [PATCH v7 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-03-26 Thread Qing Zhao
Hi, Joseph, Thanks a lot for the reviews. > On Mar 25, 2024, at 16:44, Joseph Myers wrote: > > On Wed, 20 Mar 2024, Qing Zhao wrote: > >> + /* This attribute only applies to a C99 flexible array member type. */ >> + else if (! c_flexible_array_member

[PATCH v7 4/5] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-03-20 Thread Qing Zhao
gcc/c-family/ChangeLog: * c-ubsan.cc (get_bound_from_access_with_size): New function. (ubsan_instrument_bounds): Handle call to .ACCESS_WITH_SIZE. gcc/testsuite/ChangeLog: * gcc.dg/ubsan/flex-array-counted-by-bounds-2.c: New test. *

[PATCH v7 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-03-20 Thread Qing Zhao
to carry the TYPE of the flexible array. Such information is needed during tree-object-size.cc. We cannot use the result type or the type of the 1st argument of the routine .ACCESS_WITH_SIZE to decide the element type of the original array due to possible type casting in the source code.

[PATCH v7 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-03-20 Thread Qing Zhao
gcc/ChangeLog: * tree-object-size.cc (access_with_size_object_size): New function. (call_object_size): Call the new function. gcc/testsuite/ChangeLog: * gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT. * gcc.dg/flex-array-counted-by-3.c: New test.

[PATCH v7 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-03-20 Thread Qing Zhao
Including the following changes: * The definition of the new internal function .ACCESS_WITH_SIZE in internal-fn.def. * C FE converts every reference to a FAM with a "counted_by" attribute to a call to the internal function .ACCESS_WITH_SIZE. (build_component_ref in c_typeck.cc) This

[PATCH v7 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-03-20 Thread Qing Zhao
'counted_by (COUNT)' The 'counted_by' attribute may be attached to the C99 flexible array member of a structure. It indicates that the number of the elements of the array is given by the field named "COUNT" in the same structure as the flexible array member. GCC may use

[PATCH v7 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-03-20 Thread Qing Zhao
Hi, This is the 7th version of the patch. compare with the 6th version, the difference are: updates per Siddhesh's comments: 1. update the error messages in "handle_counted_by_attribute" then update the testing case accordingly; 2. update the error messages in "verify_counted_by_attribute"

Re: [PATCH][tree-object-size]Pass OST_DYNAMIC information to early_object_size phase

2024-03-19 Thread Qing Zhao
On Mar 19, 2024, at 09:46, Jakub Jelinek wrote: On Tue, Mar 19, 2024 at 01:14:51PM +, Qing Zhao wrote: Currently, the OST_DYNAMIC information is not passed to early_object_sizes phase. Pass this information to it, and adjust the code and testing case accordingly. Can you explain why do

[PATCH][tree-object-size]Pass OST_DYNAMIC information to early_object_size phase

2024-03-19 Thread Qing Zhao
Currently, the OST_DYNAMIC information is not passed to early_object_sizes phase. Pass this information to it, and adjust the code and testing case accordingly. bootstrapped and regress tested on both x86 and aarch64. no issue. Okay for trunk? thanks. Qing gcc/ChangeLog: *

Re: [PATCH v6 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-03-18 Thread Qing Zhao
> On Mar 18, 2024, at 12:30, Siddhesh Poyarekar wrote: > > On 2024-03-18 12:28, Qing Zhao wrote: >>>> This should probably bail out if object_size_type & OST_DYNAMIC == 0. >>> Okay. Will add this. >> When add this into access_with

Re: [PATCH v6 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-03-18 Thread Qing Zhao
On Mar 13, 2024, at 15:17, Qing Zhao wrote: On Mar 11, 2024, at 13:11, Siddhesh Poyarekar wrote: On 2024-02-16 14:47, Qing Zhao wrote: gcc/ChangeLog: * tree-object-size.cc (access_with_size_object_size): New function. (call_object_size): Call the new function. gcc/testsuite/ChangeLog

  1   2   3   4   5   6   7   8   9   10   >