[V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays.

2022-12-06 Thread Qing Zhao via Gcc-patches
'-Wstrict-flex-arrays' Warn about inproper usages of flexible array members according to the LEVEL of the 'strict_flex_array (LEVEL)' attribute attached to the trailing array field of a structure if it's available, otherwise according to the LEVEL of the option

[V3][PATCH 1/2] Update -Warray-bounds with -fstrict-flex-arrays.

2022-12-06 Thread Qing Zhao via Gcc-patches
A. add the following to clarify the relationship between -Warray-bounds and the LEVEL of -fstrict-flex-array: By default, the trailing array of a structure will be treated as a flexible array member by '-Warray-bounds' or '-Warray-bounds=N' if it is declared as either

[V3][PATCH 0/2]Update -Warray-bounds with -fstrict-flex-arrays

2022-12-06 Thread Qing Zhao via Gcc-patches
Hi, this is the 3rd version of the patch. Per Richard's request, I split the patch into two seperate patches: 1. Update -Warray-bounds with -fstrict-flex-arrays. 2. Add a new warning option -Wstrict-flex-arrays. I have bootstrapped and regression tested on both X86 and aarch64 without any

Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays.

2022-12-05 Thread Qing Zhao via Gcc-patches
> On Dec 5, 2022, at 10:16 AM, Richard Biener wrote: > > On Fri, 2 Dec 2022, Qing Zhao wrote: > >> >> >>> On Dec 2, 2022, at 2:20 AM, Richard Biener wrote: >>> >>> On Fri, 2 Dec 2022, Richard Biener wrote: >>> >>>>

Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays.

2022-12-02 Thread Qing Zhao via Gcc-patches
> On Dec 2, 2022, at 2:20 AM, Richard Biener wrote: > > On Fri, 2 Dec 2022, Richard Biener wrote: > >> On Thu, 1 Dec 2022, Siddhesh Poyarekar wrote: >> >>> On 2022-12-01 11:42, Kees Cook wrote: >>>> On Wed, Nov 30, 2022 at 02:25:56PM +,

Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays.

2022-12-02 Thread Qing Zhao via Gcc-patches
> On Dec 2, 2022, at 2:16 AM, Richard Biener wrote: > > On Thu, 1 Dec 2022, Siddhesh Poyarekar wrote: > >> On 2022-12-01 11:42, Kees Cook wrote: >>> On Wed, Nov 30, 2022 at 02:25:56PM +, Qing Zhao wrote: >>>> '-Wstrict-flex-arrays' >>>>

Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays.

2022-12-01 Thread Qing Zhao via Gcc-patches
esh Poyarekar wrote: > > On 2022-12-01 11:42, Kees Cook wrote: >> On Wed, Nov 30, 2022 at 02:25:56PM +, Qing Zhao wrote: >>> '-Wstrict-flex-arrays' >>> Warn about inproper usages of flexible array members according to >>> the LEVEL o

Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays.

2022-12-01 Thread Qing Zhao via Gcc-patches
ote: > > On Thu, Dec 01, 2022 at 05:04:02PM +0000, Qing Zhao wrote: >> >> >>> On Dec 1, 2022, at 11:42 AM, Kees Cook wrote: >>> >>> On Wed, Nov 30, 2022 at 02:25:56PM +, Qing Zhao wrote: >>>> '-Wstrict-flex-arrays' >>&g

Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays.

2022-12-01 Thread Qing Zhao via Gcc-patches
> On Dec 1, 2022, at 11:42 AM, Kees Cook wrote: > > On Wed, Nov 30, 2022 at 02:25:56PM +0000, Qing Zhao wrote: >> '-Wstrict-flex-arrays' >> Warn about inproper usages of flexible array members according to >> the LEVEL of the 'strict_flex_array

[V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays.

2022-11-30 Thread Qing Zhao via Gcc-patches
'-Wstrict-flex-arrays' Warn about inproper usages of flexible array members according to the LEVEL of the 'strict_flex_array (LEVEL)' attribute attached to the trailing array field of a structure if it's available, otherwise according to the LEVEL of the option

[V2][PATCH 0/1]Add a new warning option -Wstrict-flex-arrays

2022-11-30 Thread Qing Zhao via Gcc-patches
Hi, this is the 2nd version for this patch. Per our discussion, I made the following change compared to the first version: 1. The level of -Warray-bounds will NOT control how a trailing array is considered as a flex array member anymore. Only the level of -fstrict-flex-arrays will

Re: [PATCH 2/2] Add a new warning option -Wstrict-flex-arrays.

2022-11-22 Thread Qing Zhao via Gcc-patches
> On Nov 22, 2022, at 9:10 AM, Qing Zhao via Gcc-patches > wrote: > > > >> On Nov 22, 2022, at 3:16 AM, Richard Biener wrote: >> >> On Mon, 21 Nov 2022, Qing Zhao wrote: >> >>> >>> >>>> On Nov 18, 2022, at 11:31 AM,

Re: [PATCH 2/2] Add a new warning option -Wstrict-flex-arrays.

2022-11-22 Thread Qing Zhao via Gcc-patches
> On Nov 22, 2022, at 3:16 AM, Richard Biener wrote: > > On Mon, 21 Nov 2022, Qing Zhao wrote: > >> >> >>> On Nov 18, 2022, at 11:31 AM, Kees Cook wrote: >>> >>> On Fri, Nov 18, 2022 at 03:19:07PM +, Qing Zhao wrote: >>&

Re: [PATCH 2/2] Add a new warning option -Wstrict-flex-arrays.

2022-11-21 Thread Qing Zhao via Gcc-patches
> On Nov 18, 2022, at 11:31 AM, Kees Cook wrote: > > On Fri, Nov 18, 2022 at 03:19:07PM +0000, Qing Zhao wrote: >> Hi, Richard, >> >> Honestly, it’s very hard for me to decide what’s the best way to handle the >> interaction >> between -fs

Re: [PATCH 2/2] Add a new warning option -Wstrict-flex-arrays.

2022-11-18 Thread Qing Zhao via Gcc-patches
AM, Richard Biener wrote: > > On Tue, 8 Nov 2022, Qing Zhao wrote: > >> '-Wstrict-flex-arrays' >> Warn about inproper usages of flexible array members according to >> the LEVEL of the 'strict_flex_array (LEVEL)' attribute attached to >> the trailin

Re: [PATCH 2/2] Add a new warning option -Wstrict-flex-arrays.

2022-11-15 Thread Qing Zhao via Gcc-patches
Ping on this patch. thanks. Qing > On Nov 8, 2022, at 9:51 AM, Qing Zhao wrote: > > '-Wstrict-flex-arrays' > Warn about inproper usages of flexible array members according to > the LEVEL of the 'strict_flex_array (LEVEL)' attribute attached to > the tr

Re: [PATCH 1/2] Change the name of array_at_struct_end_p to array_ref_flexible_size_p

2022-11-09 Thread Qing Zhao via Gcc-patches
Thanks. Committed as: https://gcc.gnu.org/pipermail/gcc-cvs/2022-November/373830.html Qing > On Nov 9, 2022, at 2:57 AM, Richard Biener wrote: > > On Tue, 8 Nov 2022, Qing Zhao wrote: > >> The name of the utility routine "array_at_struct_end_p" is misleading >&

[PATCH 1/2] Change the name of array_at_struct_end_p to array_ref_flexible_size_p

2022-11-08 Thread Qing Zhao via Gcc-patches
The name of the utility routine "array_at_struct_end_p" is misleading and should be changed to a new name that more accurately reflects its real meaning. The routine "array_at_struct_end_p" is used to check whether an array reference is to an array whose actual size might be larger than its upper

[PATCH 0/2] Add a new warning option -Wstrict-flex-array

2022-11-08 Thread Qing Zhao via Gcc-patches
This patch serie include two changes: 1. Change the name of array_at_struct_end_p to array_ref_flexible_size_p. 2. Add a new warning option -Wstrict-flex-arrays and at the same time keep -Warray-bounds unchanged from -fstrict-flex-arrays. The new warning -Wstrict-flex-arrays is implemented

[PATCH 2/2] Add a new warning option -Wstrict-flex-arrays.

2022-11-08 Thread Qing Zhao via Gcc-patches
'-Wstrict-flex-arrays' Warn about inproper usages of flexible array members according to the LEVEL of the 'strict_flex_array (LEVEL)' attribute attached to the trailing array field of a structure if it's available, otherwise according to the LEVEL of the option

Re: [PATCH zero-call-used-regs] Add leafy mode for zero-call-used-regs

2022-10-27 Thread Qing Zhao via Gcc-patches
> On Oct 26, 2022, at 5:29 PM, Alexandre Oliva wrote: > > On Oct 25, 2022, Qing Zhao wrote: > >>> 'all' for leaf functions is likely wasteful. If no other functions are >>> called, one can determine exactly which registers might carry >>> informati

Re: [PATCH zero-call-used-regs] Add leafy mode for zero-call-used-regs

2022-10-25 Thread Qing Zhao via Gcc-patches
Hi, Alexandre, > On Oct 24, 2022, at 10:48 PM, Alexandre Oliva wrote: > > Hello, Qing, > > It was a pleasure to meet you at the Cauldron. Me too! > > > On Oct 21, 2022, Qing Zhao wrote: > >> Hi, Alexandre, >> Could you please explain a little bi

Re: [RFC] how to handle the combination of -fstrict-flex-arrays + -Warray-bounds

2022-10-24 Thread Qing Zhao via Gcc-patches
> On Oct 24, 2022, at 3:30 AM, Richard Biener wrote: > > On Sat, 22 Oct 2022, Martin Sebor wrote: > >> On 10/21/22 09:29, Qing Zhao wrote: >>> Hi, >>> >>> (FAM below refers to Flexible Array Members): >>> >>> I need i

Re: [RFC] how to handle the combination of -fstrict-flex-arrays + -Warray-bounds

2022-10-24 Thread Qing Zhao via Gcc-patches
> On Oct 22, 2022, at 12:54 PM, Martin Sebor wrote: > > On 10/21/22 09:29, Qing Zhao wrote: >> Hi, >> (FAM below refers to Flexible Array Members): >> I need inputs on how to handle the combination of -fstrict-flex-arrays + >> -Warray-bounds. >> Our i

[RFC] how to handle the combination of -fstrict-flex-arrays + -Warray-bounds

2022-10-21 Thread Qing Zhao via Gcc-patches
Hi, (FAM below refers to Flexible Array Members): I need inputs on how to handle the combination of -fstrict-flex-arrays + -Warray-bounds. Our initial goal is to update -Warray-bounds with multiple levels of -fstrict-flex-arrays=N to issue warnings according to the different levels of “N”.

Re: [PATCH zero-call-used-regs] Add leafy mode for zero-call-used-regs

2022-10-21 Thread Qing Zhao via Gcc-patches
Hi, Alexandre, Could you please explain a little bit on the motivation of this patch first? thanks. Qing > On Oct 21, 2022, at 3:31 AM, Alexandre Oliva wrote: > > Introduce 'leafy' to auto-select between 'used' and 'all' for leaf and > nonleaf functions, respectively. > > Regstrapped on

Re: [GCC13][Patch][V6][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array

2022-10-07 Thread Qing Zhao via Gcc-patches
FYI. I just committed the patches to gcc13: https://gcc.gnu.org/pipermail/gcc-cvs/2022-October/372114.html https://gcc.gnu.org/pipermail/gcc-cvs/2022-October/372115.html thanks. Qing > On Oct 6, 2022, at 8:49 AM, Qing Zhao via Gcc-patches > wrote: > > > >> On Oc

Re: [PATCH] IPA: support -flto + -flive-patching=inline-clone

2022-10-07 Thread Qing Zhao via Gcc-patches
> On Oct 7, 2022, at 10:43 AM, Jan Hubicka wrote: > Probably not hard, and the IPA pass adjusting visbility could as well mark the functions as not to be inlined with -flive-patching=inline-only-static. >> >> OTOH inline-only-static could disable WPA inlining and

Re: [PATCH] IPA: support -flto + -flive-patching=inline-clone

2022-10-07 Thread Qing Zhao via Gcc-patches
> On Oct 7, 2022, at 9:03 AM, Jan Hubicka wrote: > >>> WPA is Whole Program Analysis? >> >> Yes. >> >>> Okay, then It will promote all static function to extern functions. That’s >>> reasonable. >> >> No, all extern functions to static functions. >> >>> Is it hard to preserve the

Re: [PATCH] IPA: support -flto + -flive-patching=inline-clone

2022-10-07 Thread Qing Zhao via Gcc-patches
> On Oct 7, 2022, at 2:34 AM, Richard Biener wrote: > > On Thu, Oct 6, 2022 at 3:18 PM Qing Zhao wrote: >> >> >> >>> On Oct 6, 2022, at 4:29 AM, Richard Biener >>> wrote: >>> >>> On Wed, Oct 5, 2022 at 8:18 PM Qing Zhao via

Re: [PATCH] IPA: support -flto + -flive-patching=inline-clone

2022-10-06 Thread Qing Zhao via Gcc-patches
> On Oct 6, 2022, at 4:29 AM, Richard Biener wrote: > > On Wed, Oct 5, 2022 at 8:18 PM Qing Zhao via Gcc-patches > wrote: >> >> >> >>> On Oct 5, 2022, at 1:36 PM, Martin Liška wrote: >>> >>> On 10/5/22 16:50, Qing Zhao

Re: [GCC13][Patch][V6][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array

2022-10-06 Thread Qing Zhao via Gcc-patches
> On Oct 5, 2022, at 4:25 PM, Joseph Myers wrote: > > On Wed, 5 Oct 2022, Qing Zhao via Gcc-patches wrote: > >> + /* if not the last field, return false. */ > > Comments should start with an uppercase letter. > >> + /* if

[GCC13][Patch][V6][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array

2022-10-05 Thread Qing Zhao via Gcc-patches
Add the following new option -fstrict-flex-arrays[=n] and a corresponding attribute strict_flex_array to GCC: '-fstrict-flex-arrays' Control when to treat the trailing array of a structure as a flexible array member for the purpose of accessing the elements of such an array. The

[GCC13][Patch][V6][PATCH 2/2] Use array_at_struct_end_p in __builtin_object_size [PR101836]

2022-10-05 Thread Qing Zhao via Gcc-patches
Use array_at_struct_end_p to determine whether the trailing array of a structure is flexible array member in __builtin_object_size. gcc/ChangeLog: PR tree-optimization/101836 * tree-object-size.cc (addr_object_size): Use array_at_struct_end_p to determine a flexible array

[GCC13][Patch][V6][PATCH 0/2] Add a new option -fstrict-flex-arrays[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-10-05 Thread Qing Zhao via Gcc-patches
the V3 of the patch review. So, Joseph, could you please take a look at the FE and doc changes and let me know whether they are good to commit? thanks a lot. Qing Qing Zhao (2): Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array Use array_at_struct_end_p in __builtin_object_size [PR101836]

Re: [PATCH] IPA: support -flto + -flive-patching=inline-clone

2022-10-05 Thread Qing Zhao via Gcc-patches
> On Oct 5, 2022, at 1:36 PM, Martin Liška wrote: > > On 10/5/22 16:50, Qing Zhao wrote: >> I have two questions on this: > > Hello. > >> >> 1. What’s the motivation to enable -flive-patching with -flto? Is there any >> application that will try

Re: [PATCH] IPA: support -flto + -flive-patching=inline-clone

2022-10-05 Thread Qing Zhao via Gcc-patches
Hi, Martin: I have two questions on this: 1. What’s the motivation to enable -flive-patching with -flto? Is there any application that will try -flive-patching with -flto now? 2. Why only enable -flive-patching=inline-clone with -flto? thanks. Qing > On Oct 5, 2022, at 7:41 AM, Martin

Re: [GCC13][Patch][V5][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array

2022-10-05 Thread Qing Zhao via Gcc-patches
> On Oct 4, 2022, at 1:37 PM, Joseph Myers wrote: > > On Tue, 4 Oct 2022, Qing Zhao via Gcc-patches wrote: > >> + { "strict_flex_array", 1, 1, false, false, false, false, >> + handle_strict_flex_array_attribute,

[GCC13][Patch][V5][PATCH 2/2] Use array_at_struct_end_p in __builtin_object_size [PR101836]

2022-10-04 Thread Qing Zhao via Gcc-patches
Use array_at_struct_end_p to determine whether the trailing array of a structure is flexible array member in __builtin_object_size. gcc/ChangeLog: PR tree-optimization/101836 * tree-object-size.cc (addr_object_size): Use array_at_struct_end_p to determine a flexible array

[PATCH 0/2] [GCC13][Patch][V5][PATCH 0/2] Add a new option -fstrict-flex-arrays[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-10-04 Thread Qing Zhao via Gcc-patches
nge has been Okayed by Bichard in the V3 of the patch review. So, Joseph, could you please take a look at the FE and doc changes and let me know whether they are good to commit? thanks a lot. Qing Qing Zhao (2): Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_arr

[GCC13][Patch][V5][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array

2022-10-04 Thread Qing Zhao via Gcc-patches
Add the following new option -fstrict-flex-arrays[=n] and a corresponding attribute strict_flex_array to GCC: '-fstrict-flex-arrays' Control when to treat the trailing array of a structure as a flexible array member for the purpose of accessing the elements of such an array. The

Re: [GCC13][Patch][V4][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_arrays

2022-10-03 Thread Qing Zhao via Gcc-patches
> On Sep 30, 2022, at 1:39 PM, Martin Sebor wrote: > > On 9/28/22 13:17, Qing Zhao wrote: >> Hi, Martin, >> Thanks for the comments. And sorry for my late reply till now (I just came >> back home from LPC, GNU Cauldron and then a one-week vacation after that…) >&

Re: [GCC13][Patch][V4][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_arrays

2022-09-28 Thread Qing Zhao via Gcc-patches
Hi, Martin, Thanks for the comments. And sorry for my late reply till now (I just came back home from LPC, GNU Cauldron and then a one-week vacation after that…) > On Sep 12, 2022, at 12:42 PM, Martin Sebor wrote: > > On 9/6/22 18:28, Qing Zhao wrote: >> Add the following new

[GCC13][Patch][V4][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_arrays

2022-09-06 Thread Qing Zhao via Gcc-patches
Add the following new option -fstrict-flex-arrays[=n] and a corresponding attribute strict_flex_arrays to GCC: '-fstrict-flex-arrays' Treat the trailing array of a structure as a flexible array member in a stricter way. The positive form is equivalent to '-fstrict-flex-arrays=3',

[GCC13][Patch][V4][PATCH 2/2] Use array_at_struct_end_p in __builtin_object_size [PR101836]

2022-09-06 Thread Qing Zhao via Gcc-patches
Use array_at_struct_end_p to determine whether the trailing array of a structure is flexible array member in __builtin_object_size. gcc/ChangeLog: PR tree-optimization/101836 * tree-object-size.cc (addr_object_size): Use array_at_struct_end_p to determine a flexible array

[GCC13][Patch][V4][PATCH 0/2] Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-09-06 Thread Qing Zhao via Gcc-patches
changes, and documentation format changes recommanded by Joseph. I have bootstrapped and regression tested on both aarch64 and x86, no issues. Let me know if you have any comments on the patches. thanks. Qing Zhao (2): Add a new option -fstrict-flex-arrays[=n] and new attribute

Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-09-04 Thread Qing Zhao via Gcc-patches
Okay, then I will delete those new warnings I added in the version 3 of the patch. Thanks. Qing > On Sep 1, 2022, at 2:11 AM, Richard Biener wrote: > > On Wed, 31 Aug 2022, Kees Cook wrote: > >> On Wed, Aug 31, 2022 at 08:35:12PM +, Qing Zhao wrote: >>>

Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-31 Thread Qing Zhao via Gcc-patches
> On Aug 31, 2022, at 4:16 PM, Qing Zhao via Gcc-patches > wrote: > > Okay, I am fine with this. Another thought on this is: One of the major purposes of the new option -fstrict-flex-array is to encourage standard conforming programming style. So, it might be reasonable to tr

Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-31 Thread Qing Zhao via Gcc-patches
Okay, I am fine with this. Richard and Kees, what’s your opinion on this? thanks. Qing > On Aug 31, 2022, at 4:09 PM, Joseph Myers wrote: > > On Wed, 31 Aug 2022, Qing Zhao wrote: > >>>> When -std=gnu89 + -fstrict-flex-array=3 (ONLY C99 flexible array member >&

Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-31 Thread Qing Zhao via Gcc-patches
> On Aug 31, 2022, at 3:52 PM, Joseph Myers wrote: > > On Wed, 31 Aug 2022, Qing Zhao wrote: > >> Does the above mean that -std=gnu89 does not support C99 flexible array >> member, then > > No. > > Flexible array members are supported by GCC in all C s

Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-31 Thread Qing Zhao via Gcc-patches
> On Aug 31, 2022, at 3:29 PM, Joseph Myers wrote: > > On Wed, 31 Aug 2022, Qing Zhao via Gcc-patches wrote: > >>> How is level 3 (thus -fstrict-flex-array) interpreted when you specify >>> -std=c89? How for -std=gnu89? >> >> 1. what’s the major

Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-31 Thread Qing Zhao via Gcc-patches
> On Aug 31, 2022, at 2:55 PM, Qing Zhao via Gcc-patches > wrote: > > > >> On Aug 31, 2022, at 1:21 PM, Joseph Myers wrote: >> >> On Wed, 31 Aug 2022, Qing Zhao via Gcc-patches wrote: >> >>>> "a GNU extension" suggests a p

Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-31 Thread Qing Zhao via Gcc-patches
> On Aug 31, 2022, at 1:21 PM, Joseph Myers wrote: > > On Wed, 31 Aug 2022, Qing Zhao via Gcc-patches wrote: > >>> "a GNU extension" suggests a particular language feature, but I think >>> you're actually referring here to a whole language versio

Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-31 Thread Qing Zhao via Gcc-patches
Hi, Joseph, Thanks a lot for your comment. > On Aug 30, 2022, at 6:53 PM, Joseph Myers wrote: > > On Tue, 30 Aug 2022, Qing Zhao via Gcc-patches wrote: > >> Hi, Joseph and Nathan, >> >> Could you please review the C and C++ FE parts of the patch? >>

Fwd: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-30 Thread Qing Zhao via Gcc-patches
. Begin forwarded message: From: Qing Zhao mailto:qing.z...@oracle.com>> Subject: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array Date: August 17, 2022 at 10:40:41 AM EDT To: gcc-patches@gcc.gnu.org<mailto:gcc-patches@gcc.gnu.org>

Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-26 Thread Qing Zhao via Gcc-patches
> On Aug 26, 2022, at 4:48 AM, Richard Biener wrote: > > On Wed, 17 Aug 2022, Qing Zhao wrote: > >> Add the following new option -fstrict-flex-array[=n] and a corresponding >> attribute strict_flex_array to GCC: >> >> '-fstrict-flex-array' >>

Re: [[GCC13][Patch][V3] 2/2] Use array_at_struct_end_p in __builtin_object_size [PR101836]

2022-08-26 Thread Qing Zhao via Gcc-patches
> On Aug 26, 2022, at 4:49 AM, Richard Biener wrote: > > On Wed, 17 Aug 2022, Qing Zhao wrote: > >> Use array_at_struct_end_p to determine whether the trailing array >> of a structure is flexible array member in __builtin_object_size. > > With the discussion ab

[[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array

2022-08-17 Thread Qing Zhao via Gcc-patches
Add the following new option -fstrict-flex-array[=n] and a corresponding attribute strict_flex_array to GCC: '-fstrict-flex-array' Treat the trailing array of a structure as a flexible array member in a stricter way. The positive form is equivalent to '-fstrict-flex-array=3',

[[GCC13][Patch][V3] 2/2] Use array_at_struct_end_p in __builtin_object_size [PR101836]

2022-08-17 Thread Qing Zhao via Gcc-patches
Use array_at_struct_end_p to determine whether the trailing array of a structure is flexible array member in __builtin_object_size. gcc/ChangeLog: PR tree-optimization/101836 * tree-object-size.cc (addr_object_size): Use array_at_struct_end_p to determine a flexible array

[GCC13][Patch][V3][0/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-08-17 Thread Qing Zhao via Gcc-patches
Hi, This is the 3rd version of the patch set. Compare to the 2nd version, the following are the major change: 1. change the name of the option from -fstrict-flex-array to -fstrict-flex-arrays (per Kees' suggestion, this will be consistent with LLVM's option); 2. -std=c89 and ISO C++ will

Re: Where in C++ module streaming to handle a new bitfield added in "tree_decl_common"

2022-08-16 Thread Qing Zhao via Gcc-patches
> On Aug 16, 2022, at 8:37 AM, Richard Biener > wrote: > > On Tue, Aug 16, 2022 at 2:16 PM Nathan Sidwell wrote: >> >> On 8/15/22 10:03, Richard Biener wrote: >>> On Mon, Aug 15, 2022 at 3:29 PM Nathan Sidwell via Gcc-patches >>> wrote: >>>

Re: Where in C++ module streaming to handle a new bitfield added in "tree_decl_common"

2022-08-16 Thread Qing Zhao via Gcc-patches
> On Aug 15, 2022, at 9:28 AM, Nathan Sidwell wrote: > > On 8/2/22 10:44, Qing Zhao wrote: >> Hi, Nathan, >> I am adding a new bitfield “decl_not_flexarray” in “tree_decl_common” >> (gcc/tree-core.h) for the new gcc feature -fstrict-flex-arrays. >> >

Re: [GCC13][Patch][PR106457]improve array_at_struct_end_p for array objects (PR106457)

2022-08-11 Thread Qing Zhao via Gcc-patches
> On Aug 11, 2022, at 3:40 AM, Richard Biener wrote: > > On Wed, 10 Aug 2022, Qing Zhao wrote: > >> Hi, >> >> As mentioned in the bug report, I reopened this bug since the previous patch: >> >> commit r13-1875-gff26f0ba68fe6e870f315d0601b596f88

[GCC13][Patch][PR106457]improve array_at_struct_end_p for array objects (PR106457)

2022-08-10 Thread Qing Zhao via Gcc-patches
Hi, As mentioned in the bug report, I reopened this bug since the previous patch: commit r13-1875-gff26f0ba68fe6e870f315d0601b596f889b89680 Author: Richard Biener Date: Thu Jul 28 10:07:32 2022 +0200 middle-end/106457 - improve array_at_struct_end_p for array objects Array references

Re: HELP!!How to add a testing case to check a compilation time warning for "cc1"

2022-08-03 Thread Qing Zhao via Gcc-patches
Never mind, just found how to do this: /* { dg-warning "'-fstrict-flex-arrays' is not supported with a ISO C before C99, ignored" "" { target *-*-* } 0 } */ And worked. thanks. Qing > On Aug 3, 2022, at 2:52 PM, Qing Zhao via Gcc-patches > wrote: > >

HELP!!How to add a testing case to check a compilation time warning for "cc1"

2022-08-03 Thread Qing Zhao via Gcc-patches
Hi, My private cc1 issued the following warning: [opc@qinzhao-ol8u3-x86 gcc]$ sh t cc1: warning: ‘-fstrict-flex-arrays’ is not supported with a ISO C before C99, ignored I’d like to add a testing case for this warning into gcc.dg directory, however, I cannot find a proper testing directive

Re: How to check -std=c89 or -std=gnu89 is set in C FE?

2022-08-02 Thread Qing Zhao via Gcc-patches
> On Aug 2, 2022, at 12:34 PM, Marek Polacek wrote: > > On Tue, Aug 02, 2022 at 04:19:56PM +0000, Qing Zhao via Gcc-patches wrote: >> Hi, Joseph, >> >> When -std=c89 or -std=gnu89 present in the command line, in C FE, which >> flags should be >> checke

How to check -std=c89 or -std=gnu89 is set in C FE?

2022-08-02 Thread Qing Zhao via Gcc-patches
Hi, Joseph, When -std=c89 or -std=gnu89 present in the command line, in C FE, which flags should be checked to decide it’s -std=c89 or -std=gnu89? Thanks a lot for your help. Qing

Re: [GCC13][Patch][V2][2/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-08-02 Thread Qing Zhao via Gcc-patches
Thanks a lot for your testing on Linux Kernel. Will work on the version 3 of this patch soon. Qing > On Aug 2, 2022, at 11:30 AM, Kees Cook wrote: > > On Tue, Jul 19, 2022 at 02:11:19PM +0000, Qing Zhao wrote: >> From a09f39ded462611286a44d9e8273de8342673ba2 Mon Sep 17 00:00:

Where in C++ module streaming to handle a new bitfield added in "tree_decl_common"

2022-08-02 Thread Qing Zhao via Gcc-patches
Hi, Nathan, I am adding a new bitfield “decl_not_flexarray” in “tree_decl_common” (gcc/tree-core.h) for the new gcc feature -fstrict-flex-arrays. diff --git a/gcc/tree-core.h b/gcc/tree-core.h index ea9f281f1cc..458c6e6ceea 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1813,7

Re: [GCC13][Patch][V2][1/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-08-02 Thread Qing Zhao via Gcc-patches
> On Aug 2, 2022, at 3:03 AM, Richard Biener wrote: > > On Mon, 1 Aug 2022, Qing Zhao wrote: > >> >> >>> On Aug 1, 2022, at 3:38 AM, Richard Biener wrote: >>> >>> On Fri, 29 Jul 2022, Qing Zhao wrote: >>> >>>>

Re: [GCC13][Patch][V2][1/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-08-01 Thread Qing Zhao via Gcc-patches
> On Aug 1, 2022, at 3:38 AM, Richard Biener wrote: > > On Fri, 29 Jul 2022, Qing Zhao wrote: > >> Hi, Richard, >> >> Thanks a lot for your comments and suggestions. (And sorry for my late >> reply). >> >>> On Jul 28, 2022, at 3:26 AM,

Re: [GCC13][Patch][V2][2/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-08-01 Thread Qing Zhao via Gcc-patches
> On Aug 1, 2022, at 3:13 AM, Richard Biener wrote: > > On Fri, 29 Jul 2022, Qing Zhao wrote: > >> >> >>> On Jul 28, 2022, at 3:28 AM, Richard Biener wrote: >>> >>> On Tue, 19 Jul 2022, Qing Zhao wrote: >>> >>>>

Re: [GCC13][Patch][V2][1/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-07-29 Thread Qing Zhao via Gcc-patches
Hi, Richard, Thanks a lot for your comments and suggestions. (And sorry for my late reply). > On Jul 28, 2022, at 3:26 AM, Richard Biener wrote: > > On Tue, 19 Jul 2022, Qing Zhao wrote: > >> From 3854004802b8e2f132ebf218fc35a632f5e80c6a Mon Sep 17 00:00:00 2001 >>

Re: [GCC13][Patch][V2][2/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-07-29 Thread Qing Zhao via Gcc-patches
> On Jul 28, 2022, at 3:28 AM, Richard Biener wrote: > > On Tue, 19 Jul 2022, Qing Zhao wrote: > >> From a09f39ded462611286a44d9e8273de8342673ba2 Mon Sep 17 00:00:00 2001 >> From: Qing Zhao >> Date: Mon, 18 Jul 2022 18:12:26 + >> Subject: [PATCH

[GCC13][Patch][V2][2/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-07-19 Thread Qing Zhao via Gcc-patches
>From a09f39ded462611286a44d9e8273de8342673ba2 Mon Sep 17 00:00:00 2001 From: Qing Zhao Date: Mon, 18 Jul 2022 18:12:26 + Subject: [PATCH 2/2] Use new flag DECL_NOT_FLEXARRAY in __builtin_object_size [PR101836] Use new flag DECL_NOT_FLEXARRAY to determine whether the trailing ar

[GCC13][Patch][V2][1/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-07-19 Thread Qing Zhao via Gcc-patches
>From 3854004802b8e2f132ebf218fc35a632f5e80c6a Mon Sep 17 00:00:00 2001 From: Qing Zhao Date: Mon, 18 Jul 2022 17:04:12 + Subject: [PATCH 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array Add the following new option -fstrict-flex-array[=n] and a correspond

[GCC13][Patch][V2][0/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

2022-07-19 Thread Qing Zhao via Gcc-patches
Hi, Based on the previous discussion on the Version 1 of the patch: https://gcc.gnu.org/pipermail/gcc-patches/2022-June/597350.html https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598010.html We decided: *User interface: . command line option in C/C++: -fstrict-flex-array[=N]

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-07 Thread Qing Zhao via Gcc-patches
> On Jul 7, 2022, at 4:02 AM, Richard Biener wrote: > > On Wed, Jul 6, 2022 at 4:20 PM Qing Zhao wrote: >> >> (Sorry for the late reply, just came back from a short vacation.) >> >>> On Jul 4, 2022, at 2:49 AM, Richard Biener >>> wrote: >>

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-06 Thread Qing Zhao via Gcc-patches
(Sorry for the late reply, just came back from a short vacation.) > On Jul 4, 2022, at 2:49 AM, Richard Biener wrote: > > On Fri, Jul 1, 2022 at 5:32 PM Martin Sebor wrote: >> >> On 7/1/22 08:01, Qing Zhao wrote: >>> >>> >>>&g

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Qing Zhao via Gcc-patches
> On Jul 1, 2022, at 8:59 AM, Jakub Jelinek wrote: > > On Fri, Jul 01, 2022 at 12:55:08PM +0000, Qing Zhao wrote: >> If so, comparing to the current implemenation to have all the checking in >> middle-end, what’s the >> major benefit of moving part of the ch

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Qing Zhao via Gcc-patches
> On Jul 1, 2022, at 8:58 AM, Richard Biener wrote: > > On Fri, Jul 1, 2022 at 2:55 PM Qing Zhao wrote: >> >> >> >>> On Jul 1, 2022, at 2:49 AM, Richard Biener >>> wrote: >>> >>> On Thu, Jun 30, 2022 at 9:30 PM Qing Zhao wr

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Qing Zhao via Gcc-patches
> On Jul 1, 2022, at 2:49 AM, Richard Biener wrote: > > On Thu, Jun 30, 2022 at 9:30 PM Qing Zhao wrote: >> >> >> >>> On Jun 30, 2022, at 1:03 PM, Jakub Jelinek wrote: >>> >>> On Thu, Jun 30, 2022 at 03:31:00PM +, Qing Zhao w

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-30 Thread Qing Zhao via Gcc-patches
> On Jun 30, 2022, at 1:03 PM, Jakub Jelinek wrote: > > On Thu, Jun 30, 2022 at 03:31:00PM +0000, Qing Zhao wrote: >>> No, that’s not true. A FIELD_DELC is only shared for cv variants of a >>> structure. >> >> Sorry for my dump questions: >

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-30 Thread Qing Zhao via Gcc-patches
> On Jun 30, 2022, at 10:24 AM, Richard Biener > wrote: > > > >> Am 30.06.2022 um 16:08 schrieb Qing Zhao via Gcc-patches >> : >> >>  >> >>> On Jun 29, 2022, at 5:14 PM, Martin Sebor wrote: >>> >>> On 6/28/22

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-30 Thread Qing Zhao via Gcc-patches
> On Jun 29, 2022, at 5:14 PM, Martin Sebor wrote: > > On 6/28/22 13:01, Qing Zhao wrote: >>> On Jun 28, 2022, at 2:49 PM, Jakub Jelinek wrote: >>> >>> On Tue, Jun 28, 2022 at 06:29:01PM +, Qing Zhao wrote: >>>> >>>&

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-29 Thread Qing Zhao via Gcc-patches
Hi, Jakub and Joseph: > On Jun 28, 2022, at 12:43 PM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 03:59:22PM +0000, Qing Zhao via Gcc-patches wrote: >>> On Jun 28, 2022, at 11:08 AM, Jakub Jelinek wrote: >>> >>> On Tue, Jun 28, 2022 at 03:03

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
> On Jun 28, 2022, at 2:49 PM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 06:29:01PM +0000, Qing Zhao wrote: >> >> >>> On Jun 28, 2022, at 2:22 PM, Jakub Jelinek wrote: >>> >>> On Tue, Jun 28, 2022 at 06:15:58PM +, Qing Zhao wrote

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
> On Jun 28, 2022, at 2:22 PM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 06:15:58PM +0000, Qing Zhao wrote: >>> Because the flag just tells whether some array shouldn't be treated as >>> (poor man's) >>> flexible array member. We still

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
> On Jun 28, 2022, at 12:43 PM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 03:59:22PM +0000, Qing Zhao via Gcc-patches wrote: >>> On Jun 28, 2022, at 11:08 AM, Jakub Jelinek wrote: >>> >>> On Tue, Jun 28, 2022 at 03:03:12PM +, Qing

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
> On Jun 28, 2022, at 11:08 AM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 03:03:12PM +0000, Qing Zhao wrote: >> 2. Then replace all “array_at_struct_end_p” with using DECL_NOT_FLEXARRAY in >> GCC, adding new testing cases > > No, IMHO array_at_struct_end_p s

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
Hi, Richard, > On Jun 28, 2022, at 3:16 AM, Richard Biener > wrote: > > On Mon, Jun 27, 2022 at 4:20 PM Qing Zhao via Gcc-patches > wrote: >> >> Hi, >> >> Per our discussion in the bug report, I came up with the following patch: >> >>

[GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-27 Thread Qing Zhao via Gcc-patches
Hi, Per our discussion in the bug report, I came up with the following patch: === PR101836: Add a new option -fstrict-flex-array[=n] Add the new option and use it in __builtin_object_size. Treat the trailing array of a structure as a flexible array member in a stricter way. The value of

Re: Back porting to GCC11/GCC12: Re: [patch][gcc13][i386][pr101891]Adjust -fzero-call-used-regs to always use XOR

2022-05-24 Thread Qing Zhao via Gcc-patches
Pushed to both gcc11 and gcc12. thanks. Qing > On May 24, 2022, at 1:19 AM, Richard Biener wrote: > > On Mon, 23 May 2022, Qing Zhao wrote: > >> Hi, >> >> I have added the patch to GCC11 and GCC12 in my local area and bootstrapped >> and regress te

Back porting to GCC11/GCC12: Re: [patch][gcc13][i386][pr101891]Adjust -fzero-call-used-regs to always use XOR

2022-05-23 Thread Qing Zhao via Gcc-patches
Hi, I have added the patch to GCC11 and GCC12 in my local area and bootstrapped and regress tested on both x86 and aarch64, no any issues. Can I committed them to both GCC11 and GCC12 branches? Thanks. > On May 10, 2022, at 8:38 AM, Qing Zhao via Gcc-patches > wrote: > > &g

Re: [patch][gcc13][i386][pr101891]Adjust -fzero-call-used-regs to always use XOR

2022-05-10 Thread Qing Zhao via Gcc-patches
> On May 10, 2022, at 1:12 AM, Richard Biener wrote: > > On Mon, 9 May 2022, Uros Bizjak wrote: > >> On Mon, May 9, 2022 at 5:44 PM Qing Zhao wrote: >>> >>> Another question: >>> >>> I think that this patch might need to be back p

Re: [patch][gcc13][i386][pr101891]Adjust -fzero-call-used-regs to always use XOR

2022-05-09 Thread Qing Zhao via Gcc-patches
Another question: I think that this patch might need to be back ported to Gcc12 and GCC11. What’s your opinion on this? If so, when can I backport it? thanks. Qing > On May 7, 2022, at 4:06 AM, Uros Bizjak wrote: > > On Fri, May 6, 2022 at 6:42 PM Qing Zhao wrote: >> >&

Re: [patch][gcc13][i386][pr101891]Adjust -fzero-call-used-regs to always use XOR

2022-05-09 Thread Qing Zhao via Gcc-patches
> On May 7, 2022, at 4:06 AM, Uros Bizjak wrote: > > On Fri, May 6, 2022 at 6:42 PM Qing Zhao wrote: >> >> >> >>> On May 6, 2022, at 10:58 AM, Uros Bizjak wrote: >>> >>> On Fri, May 6, 2022 at 4:29 PM Qing Zhao wrote: >>>&g

Re: [patch][gcc13][i386][pr101891]Adjust -fzero-call-used-regs to always use XOR

2022-05-06 Thread Qing Zhao via Gcc-patches
> On May 6, 2022, at 10:58 AM, Uros Bizjak wrote: > > On Fri, May 6, 2022 at 4:29 PM Qing Zhao wrote: >> >> Hi, >> >> As Kee’s requested in this PR: >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101891 >> >> = >> >> Cu

[patch][gcc13][i386][pr101891]Adjust -fzero-call-used-regs to always use XOR

2022-05-06 Thread Qing Zhao via Gcc-patches
Hi, As Kee’s requested in this PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101891 = Currently -fzero-call-used-regs will use a pattern of: XOR regA,regA MOV regA,regB MOV regA,regC ... RET However, this introduces both a register ordering dependency (e.g. the CPU cannot clear regB

<    1   2   3   4   5   6   7   8   9   10   >