i386: Mask out the CF_SET bit for -fcf-protection check
authorH.J. Lu <hongjiu.lu@intel.com>
Wed, 7 Feb 2018 10:48:39 +0000 (10:48 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Wed, 7 Feb 2018 10:48:39 +0000 (02:48 -0800)
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.

PR target/84248
* config/i386/i386.c (ix86_option_override_internal): Mask out
the CF_SET bit when checking -fcf-protection.

From-SVN: r257444

gcc/ChangeLog
gcc/config/i386/i386.c

index 1caefb6..51c45c0 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/84248
+       * config/i386/i386.c (ix86_option_override_internal): Mask out
+       the CF_SET bit when checking -fcf-protection.
+
 2018-02-07  Tom de Vries  <tom@codesourcery.com>
 
        PR libgomp/84217
        %1, %0<mask_scalar_operand4>|%0<mask_scalar_operand4>, %1,
        %2<round_saeonly_scalar_mask_op4>, %3}"): ... this.
 
->>>>>>> .r257416
 2018-02-02  Andrew Jenner  <andrew@codesourcery.com>
 
        * config/powerpcspe/powerpcspe.opt: Add Undocumented to irrelevant
index faa9d94..fc3d6f0 100644 (file)
@@ -4909,12 +4909,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))
            {
@@ -4949,7 +4949,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])