> -----Original Message-----
> From: [email protected] [mailto:gcc-patches-
> [email protected]] On Behalf Of H.J. Lu
> Sent: Tuesday, February 6, 2018 10:09 PM
> To: [email protected]
> Cc: Uros Bizjak <[email protected]>; Tsimbalist, Igor V
> <[email protected]>
> Subject: [PATCH] i386: Mask out the CF_SET bit for -fcf-protection check
>
> Since ix86_option_override_internal sets the CF_SET bit in
> flag_cf_protection and it can be called more than once via pragma,
> we need to mask out the CF_SET bit when checking flag_cf_protection.
>
> OK for trunk if there is no regression?
Ok from CET viewpoint.
Thanks,
Igor
> H.J.
> ---
> PR target/84248
> * config/i386/i386.c (ix86_option_override_internal): Mask out
> the CF_SET bit when checking -fcf-protection.
> ---
> gcc/config/i386/i386.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 6c612c77987..ef7ff89bcbb 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -4913,12 +4913,12 @@ ix86_option_override_internal (bool
> main_args_p,
> = build_target_option_node (opts);
>
> /* Do not support control flow instrumentation if CET is not enabled. */
> - if (opts->x_flag_cf_protection != CF_NONE)
> + cf_protection_level cf_protection
> + = (cf_protection_level) (opts->x_flag_cf_protection & ~CF_SET);
> + if (cf_protection != CF_NONE)
> {
> - switch (flag_cf_protection)
> + switch (cf_protection)
> {
> - case CF_NONE:
> - break;
> case CF_BRANCH:
> if (! TARGET_IBT_P (opts->x_ix86_isa_flags2))
> {
> @@ -4953,7 +4953,7 @@ ix86_option_override_internal (bool main_args_p,
> }
>
> opts->x_flag_cf_protection =
> - (cf_protection_level) (opts->x_flag_cf_protection | CF_SET);
> + (cf_protection_level) (cf_protection | CF_SET);
> }
>
> if (ix86_tune_features [X86_TUNE_AVOID_128FMA_CHAINS])
> --
> 2.14.3