RE: [PATCH][GCC][front-end][opt-framework] Update options framework for parameters to properly handle and validate configure time params. [Patch (2/3)]

2018-10-02 Thread Tamar Christina
Hi Alexander,

> -Original Message-
> From: Alexander Monakov 
> Sent: Tuesday, October 2, 2018 08:01
> To: Tamar Christina 
> Cc: Jeff Law ; gcc-patches@gcc.gnu.org; nd
> ; jos...@codesourcery.com
> Subject: RE: [PATCH][GCC][front-end][opt-framework] Update options
> framework for parameters to properly handle and validate configure time
> params. [Patch (2/3)]
> 
> Hello,
> 
> On Tue, 24 Jul 2018, tamar.christ...@arm.com wrote:
> >
> > * params.c (validate_param): New.
> > (add_params): Use it.
> > (set_param_value): Refactor param validation into validate_param.
> > (diagnostic.h): Include.
> > * diagnostic.h (diagnostic_ready_p): New.
> 
> this patch was committed to trunk recently, and an automated email from
> Coverity static checker has pointed out a useless self-assignment in a new
> loop. It seems wrong indeed.
> 

It's not wrong it's just unneeded. I'll write a patch to remove the assignment.

Thanks,
Tamar

> @@ -68,12 +73,26 @@ add_params (const param_info params[], size_t n) [...]
> +
> +  /* Now perform some validation and set the value if it validates.  */
> +  for (size_t i = 0; i < n; i++)
> +{
> +   if (validate_param (dst_params[i].default_value, dst_params[i], 
> (int)i))
> +   dst_params[i].default_value = dst_params[i].default_value;
> +}
>  }
> 
> 
> Alexander


RE: [PATCH][GCC][front-end][opt-framework] Update options framework for parameters to properly handle and validate configure time params. [Patch (2/3)]

2018-10-02 Thread Alexander Monakov
Hello,

On Tue, 24 Jul 2018, tamar.christ...@arm.com wrote:
> 
>   * params.c (validate_param): New.
>   (add_params): Use it.
>   (set_param_value): Refactor param validation into validate_param.
>   (diagnostic.h): Include.
>   * diagnostic.h (diagnostic_ready_p): New.

this patch was committed to trunk recently, and an automated email from
Coverity static checker has pointed out a useless self-assignment in a new
loop. It seems wrong indeed.

@@ -68,12 +73,26 @@ add_params (const param_info params[], size_t n)
[...]
+
+  /* Now perform some validation and set the value if it validates.  */
+  for (size_t i = 0; i < n; i++)
+{
+   if (validate_param (dst_params[i].default_value, dst_params[i], (int)i))
+ dst_params[i].default_value = dst_params[i].default_value;
+}
 }
 

Alexander


Re: [PATCH][GCC][front-end][opt-framework] Update options framework for parameters to properly handle and validate configure time params. [Patch (2/3)]

2018-08-03 Thread Jeff Law
On 07/24/2018 04:29 AM, tamar.christ...@arm.com wrote:
> Hi All,
> 
> This patch is re-spun to handle the configure changes in patch 4 / 6 of the 
> previous series.
> 
> This patch now changes it so that default parameters are validated during
> initialization. This change is needed to ensure parameters set via by the
> target specific common initialization routines still keep the parameters 
> within
> the valid range.
> 
> Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu and no 
> issues.
> Both targets were tested with stack clash on and off by default.
> 
> Ok for trunk?
> 
> Thanks,
> Tamar
> 
> gcc/
> 2018-07-24  Tamar Christina  
> 
>   * params.c (validate_param): New.
>   (add_params): Use it.
>   (set_param_value): Refactor param validation into validate_param.
>   (diagnostic.h): Include.
>   * diagnostic.h (diagnostic_ready_p): New.
> 
>> -Original Message-
>> From: Jeff Law 
>> Sent: Wednesday, July 11, 2018 20:24
>> To: Tamar Christina ; gcc-patches@gcc.gnu.org
>> Cc: nd ; jos...@codesourcery.com
>> Subject: Re: [PATCH][GCC][front-end][opt-framework] Update options
>> framework for parameters to properly handle and validate configure time
>> params. [Patch (2/3)]
>>
>> On 07/11/2018 05:24 AM, Tamar Christina wrote:
>>> Hi All,
>>>
>>> This patch builds on a previous patch to pass param options down from
>>> configure by adding more expansive validation and correctness checks.
>>>
>>> These are set very early on and allow the target to validate or reject
>>> the values as they see fit.
>>>
>>> To do this compiler_param has been extended to hold a value set at
>>> configure time, this value is used to be able to distinguish between
>>>
>>> 1) default value
>>> 2) configure value
>>> 3) back-end default
>>> 4) user specific value.
>>>
>>> The priority of the values should be 4 > 2 > 3 > 1.  The compiler will
>>> now also validate the values in params.def after setting them.  This
>>> means invalid values will no longer be accepted.
>>>
>>> This also changes it so that default parameters are validated during
>>> initialization. This change is needed to ensure parameters set via
>>> configure or by the target specific common initialization routines
>>> still keep the parameters within the valid range.
>>>
>>> Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
>> and no issues.
>>> Both targets were tested with stack clash on and off by default.
>>>
>>> Ok for trunk?
>>>
>>> Thanks,
>>> Tamar
>>>
>>> gcc/
>>> 2018-07-11  Tamar Christina  
>>>
>>> * params.h (struct param_info): Add configure_value.
>>> * params.c (DEFPARAMCONF): New.
>>> (DEFPARAM, DEFPARAMENUM5): Set configure_value.
>>> (validate_param): New.
>>> (add_params): Use it.
>>> (set_param_value): Refactor param validation into validate_param.
>>> (maybe_set_param_value): Don't override value from configure.
>>> (diagnostic.h): Include.
>>> * params-enum.h (DEFPARAMCONF): New.
>>> * params-list.h: Likewise.
>>> * params-options.h: Likewise.
>>> * params.def (PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE):
>> Use it.
>>> * diagnostic.h (diagnostic_ready_p): New.
>> Generally OK, though probably should depend on what we decide WRT
>> configurability.  ie, I'm not convinced we need to be able to set the default
>> via a configure time option.  And if we don't support that this patch gets
>> somewhat simpler.
>>
>> jeff
> 
> 
> rb9153-2.patch
[ ... ]
I think this is fine now.

jeff


RE: [PATCH][GCC][front-end][opt-framework] Update options framework for parameters to properly handle and validate configure time params. [Patch (2/3)]

2018-07-24 Thread tamar . christina
Hi All,

This patch is re-spun to handle the configure changes in patch 4 / 6 of the 
previous series.

This patch now changes it so that default parameters are validated during
initialization. This change is needed to ensure parameters set via by the
target specific common initialization routines still keep the parameters within
the valid range.

Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu and no 
issues.
Both targets were tested with stack clash on and off by default.

Ok for trunk?

Thanks,
Tamar

gcc/
2018-07-24  Tamar Christina  

* params.c (validate_param): New.
(add_params): Use it.
(set_param_value): Refactor param validation into validate_param.
(diagnostic.h): Include.
* diagnostic.h (diagnostic_ready_p): New.

> -Original Message-
> From: Jeff Law 
> Sent: Wednesday, July 11, 2018 20:24
> To: Tamar Christina ; gcc-patches@gcc.gnu.org
> Cc: nd ; jos...@codesourcery.com
> Subject: Re: [PATCH][GCC][front-end][opt-framework] Update options
> framework for parameters to properly handle and validate configure time
> params. [Patch (2/3)]
> 
> On 07/11/2018 05:24 AM, Tamar Christina wrote:
> > Hi All,
> >
> > This patch builds on a previous patch to pass param options down from
> > configure by adding more expansive validation and correctness checks.
> >
> > These are set very early on and allow the target to validate or reject
> > the values as they see fit.
> >
> > To do this compiler_param has been extended to hold a value set at
> > configure time, this value is used to be able to distinguish between
> >
> > 1) default value
> > 2) configure value
> > 3) back-end default
> > 4) user specific value.
> >
> > The priority of the values should be 4 > 2 > 3 > 1.  The compiler will
> > now also validate the values in params.def after setting them.  This
> > means invalid values will no longer be accepted.
> >
> > This also changes it so that default parameters are validated during
> > initialization. This change is needed to ensure parameters set via
> > configure or by the target specific common initialization routines
> > still keep the parameters within the valid range.
> >
> > Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
> and no issues.
> > Both targets were tested with stack clash on and off by default.
> >
> > Ok for trunk?
> >
> > Thanks,
> > Tamar
> >
> > gcc/
> > 2018-07-11  Tamar Christina  
> >
> > * params.h (struct param_info): Add configure_value.
> > * params.c (DEFPARAMCONF): New.
> > (DEFPARAM, DEFPARAMENUM5): Set configure_value.
> > (validate_param): New.
> > (add_params): Use it.
> > (set_param_value): Refactor param validation into validate_param.
> > (maybe_set_param_value): Don't override value from configure.
> > (diagnostic.h): Include.
> > * params-enum.h (DEFPARAMCONF): New.
> > * params-list.h: Likewise.
> > * params-options.h: Likewise.
> > * params.def (PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE):
> Use it.
> > * diagnostic.h (diagnostic_ready_p): New.
> Generally OK, though probably should depend on what we decide WRT
> configurability.  ie, I'm not convinced we need to be able to set the default
> via a configure time option.  And if we don't support that this patch gets
> somewhat simpler.
> 
> jeff
> >

diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index cf3a610f3d945f2dbbfde7d9cf7a66f46ad6f0b1..584b5877b489d3cce5c18da2db5f73b7b41a72a4 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -250,6 +250,10 @@ diagnostic_inhibit_notes (diagnostic_context * context)
and similar functions.  */
 extern diagnostic_context *global_dc;
 
+/* Returns whether the diagnostic framework has been intialized already and is
+   ready for use.  */
+#define diagnostic_ready_p() (global_dc->printer != NULL)
+
 /* The total count of a KIND of diagnostics emitted so far.  */
 #define diagnostic_kind_count(DC, DK) (DC)->diagnostic_count[(int) (DK)]
 
diff --git a/gcc/params.c b/gcc/params.c
index eb663be880a91dc0adce2a84c6bad7e06b4c72c3..b6a33dfd6bf8c4df43fdac91e30ac6d082f39071 100644
--- a/gcc/params.c
+++ b/gcc/params.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "params-enum.h"
 #include "diagnostic-core.h"
+#include "diagnostic.h"
 #include "spellcheck.h"
 
 /* An array containing the compiler parameters and their current
@@ -58,6 +59,10 @@ static const param_info lang_independent_params[] = {
   { NULL, 0, 0, 0, NULL, NULL }
 };
 
+static bool
+valid

Re: [PATCH][GCC][front-end][opt-framework] Update options framework for parameters to properly handle and validate configure time params. [Patch (2/3)]

2018-07-11 Thread Jeff Law
On 07/11/2018 05:24 AM, Tamar Christina wrote:
> Hi All,
> 
> This patch builds on a previous patch to pass param options down from 
> configure
> by adding more expansive validation and correctness checks.
> 
> These are set very early on and allow the target to validate or reject the
> values as they see fit.
> 
> To do this compiler_param has been extended to hold a value set at configure
> time, this value is used to be able to distinguish between
> 
> 1) default value
> 2) configure value
> 3) back-end default
> 4) user specific value.
> 
> The priority of the values should be 4 > 2 > 3 > 1.  The compiler will now 
> also
> validate the values in params.def after setting them.  This means invalid 
> values
> will no longer be accepted.
> 
> This also changes it so that default parameters are validated during
> initialization. This change is needed to ensure parameters set via configure
> or by the target specific common initialization routines still keep the
> parameters within the valid range.
> 
> Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu and no 
> issues.
> Both targets were tested with stack clash on and off by default.
> 
> Ok for trunk?
> 
> Thanks,
> Tamar
> 
> gcc/
> 2018-07-11  Tamar Christina  
> 
>   * params.h (struct param_info): Add configure_value.
>   * params.c (DEFPARAMCONF): New.
>   (DEFPARAM, DEFPARAMENUM5): Set configure_value.
>   (validate_param): New.
>   (add_params): Use it.
>   (set_param_value): Refactor param validation into validate_param.
>   (maybe_set_param_value): Don't override value from configure.
>   (diagnostic.h): Include.
>   * params-enum.h (DEFPARAMCONF): New.
>   * params-list.h: Likewise.
>   * params-options.h: Likewise.
>   * params.def (PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE): Use it.
>   * diagnostic.h (diagnostic_ready_p): New.
Generally OK, though probably should depend on what we decide WRT
configurability.  ie, I'm not convinced we need to be able to set the
default via a configure time option.  And if we don't support that this
patch gets somewhat simpler.

jeff
>