i386: Check error_mark_node in multiversioning
authorH.J. Lu <hongjiu.lu@intel.com>
Mon, 16 Apr 2018 11:31:22 +0000 (11:31 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Mon, 16 Apr 2018 11:31:22 +0000 (04:31 -0700)
Since CET is applied to the whole program, it is correct to disallow
-fcf-protection=full without -mcet.  But compiler shouldn't crash.

gcc/

PR target/85403
* config/i386/i386.c (get_builtin_code_for_version): Check
error_mark_node.

gcc/testsuite/

PR target/85403
* gcc.target/i386/pr85403.c: New test.
---
 gcc/config/i386/i386.c                            |  2 ++
 gcc/testsuite/g++.dg/ext/mv1.C                    |  2 +-
 gcc/testsuite/g++.dg/ext/mv14.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv15.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv16.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv17.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv18.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv19.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv20.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv21.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv22.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv23.C                   |  2 +-
 gcc/testsuite/g++.dg/ext/mv26.C                   |  1 +
 gcc/testsuite/g++.dg/ext/mv6.C                    |  2 +-
 gcc/testsuite/g++.dg/ext/mvc1.C                   |  1 +
 gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c |  2 +-
 gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c |  2 +-
 gcc/testsuite/gcc.target/i386/cet-property-2.c    |  2 +-
 gcc/testsuite/gcc.target/i386/mvc1.c              |  1 +
 gcc/testsuite/gcc.target/i386/mvc10.c             |  1 +
 gcc/testsuite/gcc.target/i386/mvc11.c             |  2 +-
 gcc/testsuite/gcc.target/i386/mvc6.c              |  2 +-
 gcc/testsuite/gcc.target/i386/mvc7.c              |  1 +
 gcc/testsuite/gcc.target/i386/mvc8.c              |  2 +-
 gcc/testsuite/gcc.target/i386/mvc9.c              |  2 +-
 gcc/testsuite/gcc.target/i386/pr81213.c           |  1 +
 gcc/testsuite/gcc.target/i386/pr81214.c           |  1 +
 gcc/testsuite/gcc.target/i386/pr85403.c           | 10 ++++++++++
 gcc/testsuite/gcc.target/i386/sse-26.c            |  2 +-
 29 files changed, 39 insertions(+), 20 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr85403.c

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6fa5b0add02..8a73fc0d316 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -32344,6 +32344,8 @@ get_builtin_code_for_version (tree decl, tree *predicate_list)
        &global_options_set);

       gcc_assert (target_node);
+      if (target_node == error_mark_node)
+ return 0;
       new_target = TREE_TARGET_OPTION (target_node);
       gcc_assert (new_target);

diff --git a/gcc/testsuite/gcc.target/i386/pr85403.c b/gcc/testsuite/gcc.target/i386/pr85403.c
new file mode 100644
index 00000000000..f4fb12dd4e2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr85403.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-fcf-protection -mcet" } */
+/* { dg-require-ifunc "" } */
+
+__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
+int
+foo ()
+{
+  return -2;
+} /* { dg-error "requires Intel CET support" } */

From-SVN: r259400

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr85403.c [new file with mode: 0644]

index 8cc7a6b8167e812465a595ecc2ba3507cb004994..b53fda60c3c505cfe2c63d6d7de608a35cc472cd 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-16  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/85403
+       * config/i386/i386.c (get_builtin_code_for_version): Check
+       error_mark_node.
+
 2018-04-16  Olga Makhotina  <olga.makhotina@intel.com>
 
        PR target/84331
index b62fdad992794584926548f8f11d5cd2c1a2500d..9074526b8a1ae0f7e68a78ac170b93dc3d889b41 100644 (file)
@@ -32337,6 +32337,8 @@ get_builtin_code_for_version (tree decl, tree *predicate_list)
                                                      &global_options_set);
     
       gcc_assert (target_node);
+      if (target_node == error_mark_node)
+       return 0;
       new_target = TREE_TARGET_OPTION (target_node);
       gcc_assert (new_target);
       
index 1aa8476339e3420596005db9b6fd58fc0549614e..415994e6091cac9cdd5da54cc7397c98312f297f 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-16  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/85403
+       * gcc.target/i386/pr85403.c: New test.
+
 2018-04-16  Olga Makhotina  <olga.makhotina@intel.com>
 
        PR target/84331
diff --git a/gcc/testsuite/gcc.target/i386/pr85403.c b/gcc/testsuite/gcc.target/i386/pr85403.c
new file mode 100644 (file)
index 0000000..f4fb12d
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-fcf-protection -mcet" } */
+/* { dg-require-ifunc "" } */
+
+__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
+int
+foo ()
+{
+  return -2;
+} /* { dg-error "requires Intel CET support" } */