[PATCH i386: Check error_mark_node in multiversioning

Message ID 20180415105503.GA26530@intel.com
State New
Headers show
Series
  • [PATCH i386: Check error_mark_node in multiversioning
Related show

Commit Message

H.J. Lu April 15, 2018, 10:55 a.m.
Since CET is applied to the whole program, it is correct to disallow
-fcf-protection=full without -mcet.  But compiler shouldn't crash.

OK for trunk?

H.J.
----
gcc/

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

gcc/testsuite/

	PR target/85403
	* g++.dg/ext/mv1.C: Compile with -fcf-protection=none.
	* g++.dg/ext/mv14.C: Likewise.
	* g++.dg/ext/mv15.C: Likewise.
	* g++.dg/ext/mv16.C: Likewise.
	* g++.dg/ext/mv17.C: Likewise.
	* g++.dg/ext/mv18.C: Likewise.
	* g++.dg/ext/mv19.C: Likewise.
	* g++.dg/ext/mv20.C: Likewise.
	* g++.dg/ext/mv21.C: Likewise.
	* g++.dg/ext/mv22.C: Likewise.
	* g++.dg/ext/mv23.C: Likewise.
	* g++.dg/ext/mv26.C: Likewise.
	* g++.dg/ext/mv6.C: Likewise.
	* g++.dg/ext/mvc1.C: Likewise.
	* gcc.target/i386/cet-notrack-icf-1.c: Likewise.
	* gcc.target/i386/cet-notrack-icf-3.c: Likewise.
	* gcc.target/i386/cet-property-2.c: Likewise.
	* gcc.target/i386/mvc1.c: Likewise.
	* gcc.target/i386/mvc10.c: Likewise.
	* gcc.target/i386/mvc11.c: Likewise.
	* gcc.target/i386/mvc6.c: Likewise.
	* gcc.target/i386/mvc7.c: Likewise.
	* gcc.target/i386/mvc8.c: Likewise.
	* gcc.target/i386/mvc9.c: Likewise.
	* gcc.target/i386/pr81213.c: Likewise.
	* gcc.target/i386/pr81214.c: Likewise.
	* gcc.target/i386/sse-26.c: Likewise.
	* 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

Comments

Uros Bizjak April 16, 2018, 8:41 a.m. | #1
On Sun, Apr 15, 2018 at 12:55 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Since CET is applied to the whole program, it is correct to disallow
> -fcf-protection=full without -mcet.  But compiler shouldn't crash.

I don't think this is correct approach. If CET appleis to the whole
program, then it shouldn't be affected by target attributes (similar
how -m64 can't be switched by a target attribute).

Uros.

> OK for trunk?
>
> H.J.
> ----
> gcc/
>
>         PR target/85403
>         * config/i386/i386.c (get_builtin_code_for_version): Check
>         error_mark_node.
>
> gcc/testsuite/
>
>         PR target/85403
>         * g++.dg/ext/mv1.C: Compile with -fcf-protection=none.
>         * g++.dg/ext/mv14.C: Likewise.
>         * g++.dg/ext/mv15.C: Likewise.
>         * g++.dg/ext/mv16.C: Likewise.
>         * g++.dg/ext/mv17.C: Likewise.
>         * g++.dg/ext/mv18.C: Likewise.
>         * g++.dg/ext/mv19.C: Likewise.
>         * g++.dg/ext/mv20.C: Likewise.
>         * g++.dg/ext/mv21.C: Likewise.
>         * g++.dg/ext/mv22.C: Likewise.
>         * g++.dg/ext/mv23.C: Likewise.
>         * g++.dg/ext/mv26.C: Likewise.
>         * g++.dg/ext/mv6.C: Likewise.
>         * g++.dg/ext/mvc1.C: Likewise.
>         * gcc.target/i386/cet-notrack-icf-1.c: Likewise.
>         * gcc.target/i386/cet-notrack-icf-3.c: Likewise.
>         * gcc.target/i386/cet-property-2.c: Likewise.
>         * gcc.target/i386/mvc1.c: Likewise.
>         * gcc.target/i386/mvc10.c: Likewise.
>         * gcc.target/i386/mvc11.c: Likewise.
>         * gcc.target/i386/mvc6.c: Likewise.
>         * gcc.target/i386/mvc7.c: Likewise.
>         * gcc.target/i386/mvc8.c: Likewise.
>         * gcc.target/i386/mvc9.c: Likewise.
>         * gcc.target/i386/pr81213.c: Likewise.
>         * gcc.target/i386/pr81214.c: Likewise.
>         * gcc.target/i386/sse-26.c: Likewise.
>         * 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/g++.dg/ext/mv1.C b/gcc/testsuite/g++.dg/ext/mv1.C
> index 4eedbff7b23..af81f3aa056 100644
> --- a/gcc/testsuite/g++.dg/ext/mv1.C
> +++ b/gcc/testsuite/g++.dg/ext/mv1.C
> @@ -1,7 +1,7 @@
>  /* Test case to check if Multiversioning works.  */
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
> -/* { dg-options "-O2 -fPIC" } */
> +/* { dg-options "-O2 -fPIC -fcf-protection=none" } */
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv14.C b/gcc/testsuite/g++.dg/ext/mv14.C
> index 1e7a1619698..82b153b7ebb 100644
> --- a/gcc/testsuite/g++.dg/ext/mv14.C
> +++ b/gcc/testsuite/g++.dg/ext/mv14.C
> @@ -1,7 +1,7 @@
>  /* Test case to check if Multiversioning works.  */
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
> -/* { dg-options "-O2 -fPIC -march=x86-64" } */
> +/* { dg-options "-O2 -fPIC -march=x86-64 -fcf-protection=none" } */
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv15.C b/gcc/testsuite/g++.dg/ext/mv15.C
> index c0beadf16ea..3d1bf9934dd 100644
> --- a/gcc/testsuite/g++.dg/ext/mv15.C
> +++ b/gcc/testsuite/g++.dg/ext/mv15.C
> @@ -1,7 +1,7 @@
>  /* Test case to check if Multiversioning works.  */
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
> -/* { dg-options "-O2 -fPIC -march=x86-64" } */
> +/* { dg-options "-O2 -fPIC -march=x86-64 -fcf-protection=none" } */
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv16.C b/gcc/testsuite/g++.dg/ext/mv16.C
> index 3e7c228a7f1..6e1d7a2aad6 100644
> --- a/gcc/testsuite/g++.dg/ext/mv16.C
> +++ b/gcc/testsuite/g++.dg/ext/mv16.C
> @@ -4,7 +4,7 @@
>
>  // { dg-do run { target i?86-*-* x86_64-*-* } }
>  // { dg-require-ifunc "" }
> -// { dg-options "-O2" }
> +// { dg-options "-O2 -fcf-protection=none" }
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv17.C b/gcc/testsuite/g++.dg/ext/mv17.C
> index 87c13246ed2..8c1fcac47f5 100644
> --- a/gcc/testsuite/g++.dg/ext/mv17.C
> +++ b/gcc/testsuite/g++.dg/ext/mv17.C
> @@ -2,7 +2,7 @@
>
>  // { dg-do run { target i?86-*-* x86_64-*-* } }
>  // { dg-require-ifunc "" }
> -// { dg-options "-O2" }
> +// { dg-options "-O2 -fcf-protection=none" }
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv18.C b/gcc/testsuite/g++.dg/ext/mv18.C
> index 1f024de9b95..3e64a26a31e 100644
> --- a/gcc/testsuite/g++.dg/ext/mv18.C
> +++ b/gcc/testsuite/g++.dg/ext/mv18.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target pie } */
> -/* { dg-options "-O2 -fPIE -pie" } */
> +/* { dg-options "-O2 -fPIE -pie -fcf-protection=none" } */
>
>  #include "mv1.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv19.C b/gcc/testsuite/g++.dg/ext/mv19.C
> index d1ea788745f..6a5c4190056 100644
> --- a/gcc/testsuite/g++.dg/ext/mv19.C
> +++ b/gcc/testsuite/g++.dg/ext/mv19.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target pie } */
> -/* { dg-options "-O2 -fPIE -pie -march=x86-64" } */
> +/* { dg-options "-O2 -fPIE -pie -march=x86-64 -fcf-protection=none" } */
>
>  #include "mv14.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv20.C b/gcc/testsuite/g++.dg/ext/mv20.C
> index 98f7408e1fc..302c1070201 100644
> --- a/gcc/testsuite/g++.dg/ext/mv20.C
> +++ b/gcc/testsuite/g++.dg/ext/mv20.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target pie } */
> -/* { dg-options "-O2 -fPIE -pie -march=x86-64" } */
> +/* { dg-options "-O2 -fPIE -pie -march=x86-64 -fcf-protection=none" } */
>
>  #include "mv15.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv21.C b/gcc/testsuite/g++.dg/ext/mv21.C
> index 9708ad95019..dfece312e97 100644
> --- a/gcc/testsuite/g++.dg/ext/mv21.C
> +++ b/gcc/testsuite/g++.dg/ext/mv21.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target static } */
> -/* { dg-options "-O2 -static" } */
> +/* { dg-options "-O2 -static -fcf-protection=none" } */
>
>  #include "mv1.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv22.C b/gcc/testsuite/g++.dg/ext/mv22.C
> index 2550136fdac..199f06037c7 100644
> --- a/gcc/testsuite/g++.dg/ext/mv22.C
> +++ b/gcc/testsuite/g++.dg/ext/mv22.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target static } */
> -/* { dg-options "-O2 -static -march=x86-64" } */
> +/* { dg-options "-O2 -static -march=x86-64 -fcf-protection=none" } */
>
>  #include "mv14.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv23.C b/gcc/testsuite/g++.dg/ext/mv23.C
> index f00afb01f15..946d8d95085 100644
> --- a/gcc/testsuite/g++.dg/ext/mv23.C
> +++ b/gcc/testsuite/g++.dg/ext/mv23.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target static } */
> -/* { dg-options "-O2 -static -march=x86-64" } */
> +/* { dg-options "-O2 -static -march=x86-64 -fcf-protection=none" } */
>
>  #include "mv15.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv26.C b/gcc/testsuite/g++.dg/ext/mv26.C
> index 1b455130e46..6c883e1830a 100644
> --- a/gcc/testsuite/g++.dg/ext/mv26.C
> +++ b/gcc/testsuite/g++.dg/ext/mv26.C
> @@ -1,6 +1,7 @@
>  // PR c++/84059
>  // { dg-do compile { target i?86-*-* x86_64-*-* } }
>  // { dg-require-ifunc "" }
> +/* { dg-options "-fcf-protection=none" } */
>
>  template <typename> struct a
>  {
> diff --git a/gcc/testsuite/g++.dg/ext/mv6.C b/gcc/testsuite/g++.dg/ext/mv6.C
> index 2273065996b..056ca55b911 100644
> --- a/gcc/testsuite/g++.dg/ext/mv6.C
> +++ b/gcc/testsuite/g++.dg/ext/mv6.C
> @@ -2,7 +2,7 @@
>
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
> -/* { dg-options "-march=x86-64" } */
> +/* { dg-options "-march=x86-64 -fcf-protection=none" } */
>
>  class Foo
>  {
> diff --git a/gcc/testsuite/g++.dg/ext/mvc1.C b/gcc/testsuite/g++.dg/ext/mvc1.C
> index ff37238a4e0..c3930ed0d2c 100644
> --- a/gcc/testsuite/g++.dg/ext/mvc1.C
> +++ b/gcc/testsuite/g++.dg/ext/mvc1.C
> @@ -1,5 +1,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" } */
> +/* { dg-options "-fcf-protection=none" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
>  int
> diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
> index 7987d53d305..00a3f3e5d5f 100644
> --- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
> +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
> @@ -1,6 +1,6 @@
>  /* Verify nocf_check functions are not ICF optimized.  */
>  /* { dg-do compile } */
> -/* { dg-options "-O2" } */
> +/* { dg-options "-O2 -fcf-protection=none -mno-cet" } */
>  /* { dg-final { scan-assembler-not "endbr" } } */
>  /* { dg-final { scan-assembler-not "fn3:" } } */
>  /* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */
> diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c
> index 07c4a6b61ef..c8b26f947d3 100644
> --- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c
> +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c
> @@ -1,6 +1,6 @@
>  /* Verify nocf_check function calls are not ICF optimized.  */
>  /* { dg-do compile } */
> -/* { dg-options "-O2" } */
> +/* { dg-options "-O2 -fcf-protection=none -mno-cet" } */
>  /* { dg-final { scan-assembler-not "endbr" } } */
>  /* { dg-final { scan-assembler-not "fn2:" } } */
>  /* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */
> diff --git a/gcc/testsuite/gcc.target/i386/cet-property-2.c b/gcc/testsuite/gcc.target/i386/cet-property-2.c
> index 5a87dab92f1..bca6f6cdeb7 100644
> --- a/gcc/testsuite/gcc.target/i386/cet-property-2.c
> +++ b/gcc/testsuite/gcc.target/i386/cet-property-2.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options "-mcet" } */
> +/* { dg-options "-mcet -fcf-protection=none" } */
>  /* { dg-final { scan-assembler-not ".note.gnu.property" } } */
>
>  extern void foo (void);
> diff --git a/gcc/testsuite/gcc.target/i386/mvc1.c b/gcc/testsuite/gcc.target/i386/mvc1.c
> index 752b3af7469..995056f850f 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc1.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc1.c
> @@ -1,4 +1,5 @@
>  /* { dg-do run } */
> +/* { dg-options "-fcf-protection=none" } */
>  /* { dg-require-ifunc "" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
> diff --git a/gcc/testsuite/gcc.target/i386/mvc10.c b/gcc/testsuite/gcc.target/i386/mvc10.c
> index 9a7b609c0b3..7452a33659f 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc10.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc10.c
> @@ -1,5 +1,6 @@
>  /* PR ipa/84722.  */
>  /* { dg-do run } */
> +/* { dg-options "-fcf-protection=none" } */
>  /* { dg-require-ifunc "" } */
>
>  __attribute__ ((target_clones ("avx", "arch=core-avx2", "default"))) int
> diff --git a/gcc/testsuite/gcc.target/i386/mvc11.c b/gcc/testsuite/gcc.target/i386/mvc11.c
> index 5bd10f4651d..c91ba635559 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc11.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc11.c
> @@ -1,6 +1,6 @@
>  /* { dg-do run } */
>  /* { dg-require-ifunc "" } */
> -/* { dg-options "-std=gnu99" } */
> +/* { dg-options "-std=gnu99 -fcf-protection=none" } */
>
>  __attribute__((noipa)) int
>  baz (int (*fn) (void))
> diff --git a/gcc/testsuite/gcc.target/i386/mvc6.c b/gcc/testsuite/gcc.target/i386/mvc6.c
> index af631394980..f14f575ba96 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc6.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc6.c
> @@ -1,6 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> -/* { dg-options "-O3" } */
> +/* { dg-options "-O3 -fcf-protection=none" } */
>  /* { dg-final { scan-assembler "vpshufb" } } */
>  /* { dg-final { scan-assembler "punpcklbw" } } */
>
> diff --git a/gcc/testsuite/gcc.target/i386/mvc7.c b/gcc/testsuite/gcc.target/i386/mvc7.c
> index a3697ba9b75..1a8226b65c6 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc7.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc7.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> +/* { dg-options "-fcf-protection=none" } */
>  /* { dg-final { scan-assembler "foo.resolver" } } */
>  /* { dg-final { scan-assembler "avx" } } */
>  /* { dg-final { scan-assembler "slm" } } */
> diff --git a/gcc/testsuite/gcc.target/i386/mvc8.c b/gcc/testsuite/gcc.target/i386/mvc8.c
> index 97d7941a5ab..cf3b4e12bec 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc8.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc8.c
> @@ -1,6 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> -/* { dg-options "-O3 -fno-inline" } */
> +/* { dg-options "-O3 -fno-inline -fcf-protection=none" } */
>  /* { dg-final { scan-assembler-not "constprop" } } */
>  __attribute__((target_clones("arch=core-avx2","arch=slm","default")))
>  void foo (float *a, int b) {
> diff --git a/gcc/testsuite/gcc.target/i386/mvc9.c b/gcc/testsuite/gcc.target/i386/mvc9.c
> index 4052f2afb54..5d140f2526b 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc9.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc9.c
> @@ -1,6 +1,6 @@
>  /* { dg-do run { target lto } } */
>  /* { dg-require-ifunc "" } */
> -/* { dg-options "-O2 -flto" } */
> +/* { dg-options "-O2 -flto -fcf-protection=none" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
>  int
> diff --git a/gcc/testsuite/gcc.target/i386/pr81213.c b/gcc/testsuite/gcc.target/i386/pr81213.c
> index 13e15d5fef0..52bdc1bda94 100644
> --- a/gcc/testsuite/gcc.target/i386/pr81213.c
> +++ b/gcc/testsuite/gcc.target/i386/pr81213.c
> @@ -1,6 +1,7 @@
>  /* PR ipa/81214.  */
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> +/* { dg-options "-fcf-protection=none" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
>  static int
> diff --git a/gcc/testsuite/gcc.target/i386/pr81214.c b/gcc/testsuite/gcc.target/i386/pr81214.c
> index 2584decdb3c..15db31da140 100644
> --- a/gcc/testsuite/gcc.target/i386/pr81214.c
> +++ b/gcc/testsuite/gcc.target/i386/pr81214.c
> @@ -1,6 +1,7 @@
>  /* PR ipa/81214.  */
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> +/* { dg-options "-fcf-protection=none" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
>  int
> 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" } */
> diff --git a/gcc/testsuite/gcc.target/i386/sse-26.c b/gcc/testsuite/gcc.target/i386/sse-26.c
> index f2607e64b59..0d786b2e37f 100644
> --- a/gcc/testsuite/gcc.target/i386/sse-26.c
> +++ b/gcc/testsuite/gcc.target/i386/sse-26.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -msse2 -mmmx -mno-sse3 -mno-3dnow -mno-fma -mno-fxsr -mno-xsave -mno-rtm -mno-prfchw -mno-rdseed -mno-adx -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-ibt -mno-shstk -mno-vaes -mno-vpclmulqdq" } */
> +/* { dg-options "-fcf-protection=none -O2 -Werror-implicit-function-declaration -march=k8 -msse2 -mmmx -mno-sse3 -mno-3dnow -mno-fma -mno-fxsr -mno-xsave -mno-rtm -mno-prfchw -mno-rdseed -mno-adx -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-ibt -mno-shstk -mno-vaes -mno-vpclmulqdq" } */
>  /* { dg-add-options bind_pic_locally } */
>
>  #include "sse-13.c"
> --
> 2.14.3
>
Uros Bizjak April 16, 2018, 8:45 a.m. | #2
On Sun, Apr 15, 2018 at 12:55 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Since CET is applied to the whole program, it is correct to disallow
> -fcf-protection=full without -mcet.  But compiler shouldn't crash.
>
> OK for trunk?
>
> H.J.
> ----
> gcc/
>
>         PR target/85403
>         * config/i386/i386.c (get_builtin_code_for_version): Check
>         error_mark_node.
>
> gcc/testsuite/
>
>         PR target/85403
>         * g++.dg/ext/mv1.C: Compile with -fcf-protection=none.
>         * g++.dg/ext/mv14.C: Likewise.
>         * g++.dg/ext/mv15.C: Likewise.
>         * g++.dg/ext/mv16.C: Likewise.
>         * g++.dg/ext/mv17.C: Likewise.
>         * g++.dg/ext/mv18.C: Likewise.
>         * g++.dg/ext/mv19.C: Likewise.
>         * g++.dg/ext/mv20.C: Likewise.
>         * g++.dg/ext/mv21.C: Likewise.
>         * g++.dg/ext/mv22.C: Likewise.
>         * g++.dg/ext/mv23.C: Likewise.
>         * g++.dg/ext/mv26.C: Likewise.
>         * g++.dg/ext/mv6.C: Likewise.
>         * g++.dg/ext/mvc1.C: Likewise.
>         * gcc.target/i386/cet-notrack-icf-1.c: Likewise.
>         * gcc.target/i386/cet-notrack-icf-3.c: Likewise.
>         * gcc.target/i386/cet-property-2.c: Likewise.
>         * gcc.target/i386/mvc1.c: Likewise.
>         * gcc.target/i386/mvc10.c: Likewise.
>         * gcc.target/i386/mvc11.c: Likewise.
>         * gcc.target/i386/mvc6.c: Likewise.
>         * gcc.target/i386/mvc7.c: Likewise.
>         * gcc.target/i386/mvc8.c: Likewise.
>         * gcc.target/i386/mvc9.c: Likewise.
>         * gcc.target/i386/pr81213.c: Likewise.
>         * gcc.target/i386/pr81214.c: Likewise.
>         * gcc.target/i386/sse-26.c: Likewise.
>         * gcc.target/i386/pr85403.c: New test.

i386.c error-recovery change and pr85403.c testcase are OK. Please do
not change other tests.

Thanks,
Uros.

> ---
>  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/g++.dg/ext/mv1.C b/gcc/testsuite/g++.dg/ext/mv1.C
> index 4eedbff7b23..af81f3aa056 100644
> --- a/gcc/testsuite/g++.dg/ext/mv1.C
> +++ b/gcc/testsuite/g++.dg/ext/mv1.C
> @@ -1,7 +1,7 @@
>  /* Test case to check if Multiversioning works.  */
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
> -/* { dg-options "-O2 -fPIC" } */
> +/* { dg-options "-O2 -fPIC -fcf-protection=none" } */
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv14.C b/gcc/testsuite/g++.dg/ext/mv14.C
> index 1e7a1619698..82b153b7ebb 100644
> --- a/gcc/testsuite/g++.dg/ext/mv14.C
> +++ b/gcc/testsuite/g++.dg/ext/mv14.C
> @@ -1,7 +1,7 @@
>  /* Test case to check if Multiversioning works.  */
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
> -/* { dg-options "-O2 -fPIC -march=x86-64" } */
> +/* { dg-options "-O2 -fPIC -march=x86-64 -fcf-protection=none" } */
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv15.C b/gcc/testsuite/g++.dg/ext/mv15.C
> index c0beadf16ea..3d1bf9934dd 100644
> --- a/gcc/testsuite/g++.dg/ext/mv15.C
> +++ b/gcc/testsuite/g++.dg/ext/mv15.C
> @@ -1,7 +1,7 @@
>  /* Test case to check if Multiversioning works.  */
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
> -/* { dg-options "-O2 -fPIC -march=x86-64" } */
> +/* { dg-options "-O2 -fPIC -march=x86-64 -fcf-protection=none" } */
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv16.C b/gcc/testsuite/g++.dg/ext/mv16.C
> index 3e7c228a7f1..6e1d7a2aad6 100644
> --- a/gcc/testsuite/g++.dg/ext/mv16.C
> +++ b/gcc/testsuite/g++.dg/ext/mv16.C
> @@ -4,7 +4,7 @@
>
>  // { dg-do run { target i?86-*-* x86_64-*-* } }
>  // { dg-require-ifunc "" }
> -// { dg-options "-O2" }
> +// { dg-options "-O2 -fcf-protection=none" }
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv17.C b/gcc/testsuite/g++.dg/ext/mv17.C
> index 87c13246ed2..8c1fcac47f5 100644
> --- a/gcc/testsuite/g++.dg/ext/mv17.C
> +++ b/gcc/testsuite/g++.dg/ext/mv17.C
> @@ -2,7 +2,7 @@
>
>  // { dg-do run { target i?86-*-* x86_64-*-* } }
>  // { dg-require-ifunc "" }
> -// { dg-options "-O2" }
> +// { dg-options "-O2 -fcf-protection=none" }
>
>  #include <assert.h>
>
> diff --git a/gcc/testsuite/g++.dg/ext/mv18.C b/gcc/testsuite/g++.dg/ext/mv18.C
> index 1f024de9b95..3e64a26a31e 100644
> --- a/gcc/testsuite/g++.dg/ext/mv18.C
> +++ b/gcc/testsuite/g++.dg/ext/mv18.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target pie } */
> -/* { dg-options "-O2 -fPIE -pie" } */
> +/* { dg-options "-O2 -fPIE -pie -fcf-protection=none" } */
>
>  #include "mv1.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv19.C b/gcc/testsuite/g++.dg/ext/mv19.C
> index d1ea788745f..6a5c4190056 100644
> --- a/gcc/testsuite/g++.dg/ext/mv19.C
> +++ b/gcc/testsuite/g++.dg/ext/mv19.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target pie } */
> -/* { dg-options "-O2 -fPIE -pie -march=x86-64" } */
> +/* { dg-options "-O2 -fPIE -pie -march=x86-64 -fcf-protection=none" } */
>
>  #include "mv14.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv20.C b/gcc/testsuite/g++.dg/ext/mv20.C
> index 98f7408e1fc..302c1070201 100644
> --- a/gcc/testsuite/g++.dg/ext/mv20.C
> +++ b/gcc/testsuite/g++.dg/ext/mv20.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target pie } */
> -/* { dg-options "-O2 -fPIE -pie -march=x86-64" } */
> +/* { dg-options "-O2 -fPIE -pie -march=x86-64 -fcf-protection=none" } */
>
>  #include "mv15.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv21.C b/gcc/testsuite/g++.dg/ext/mv21.C
> index 9708ad95019..dfece312e97 100644
> --- a/gcc/testsuite/g++.dg/ext/mv21.C
> +++ b/gcc/testsuite/g++.dg/ext/mv21.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target static } */
> -/* { dg-options "-O2 -static" } */
> +/* { dg-options "-O2 -static -fcf-protection=none" } */
>
>  #include "mv1.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv22.C b/gcc/testsuite/g++.dg/ext/mv22.C
> index 2550136fdac..199f06037c7 100644
> --- a/gcc/testsuite/g++.dg/ext/mv22.C
> +++ b/gcc/testsuite/g++.dg/ext/mv22.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target static } */
> -/* { dg-options "-O2 -static -march=x86-64" } */
> +/* { dg-options "-O2 -static -march=x86-64 -fcf-protection=none" } */
>
>  #include "mv14.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv23.C b/gcc/testsuite/g++.dg/ext/mv23.C
> index f00afb01f15..946d8d95085 100644
> --- a/gcc/testsuite/g++.dg/ext/mv23.C
> +++ b/gcc/testsuite/g++.dg/ext/mv23.C
> @@ -2,6 +2,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
>  /* { dg-require-effective-target static } */
> -/* { dg-options "-O2 -static -march=x86-64" } */
> +/* { dg-options "-O2 -static -march=x86-64 -fcf-protection=none" } */
>
>  #include "mv15.C"
> diff --git a/gcc/testsuite/g++.dg/ext/mv26.C b/gcc/testsuite/g++.dg/ext/mv26.C
> index 1b455130e46..6c883e1830a 100644
> --- a/gcc/testsuite/g++.dg/ext/mv26.C
> +++ b/gcc/testsuite/g++.dg/ext/mv26.C
> @@ -1,6 +1,7 @@
>  // PR c++/84059
>  // { dg-do compile { target i?86-*-* x86_64-*-* } }
>  // { dg-require-ifunc "" }
> +/* { dg-options "-fcf-protection=none" } */
>
>  template <typename> struct a
>  {
> diff --git a/gcc/testsuite/g++.dg/ext/mv6.C b/gcc/testsuite/g++.dg/ext/mv6.C
> index 2273065996b..056ca55b911 100644
> --- a/gcc/testsuite/g++.dg/ext/mv6.C
> +++ b/gcc/testsuite/g++.dg/ext/mv6.C
> @@ -2,7 +2,7 @@
>
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" }  */
> -/* { dg-options "-march=x86-64" } */
> +/* { dg-options "-march=x86-64 -fcf-protection=none" } */
>
>  class Foo
>  {
> diff --git a/gcc/testsuite/g++.dg/ext/mvc1.C b/gcc/testsuite/g++.dg/ext/mvc1.C
> index ff37238a4e0..c3930ed0d2c 100644
> --- a/gcc/testsuite/g++.dg/ext/mvc1.C
> +++ b/gcc/testsuite/g++.dg/ext/mvc1.C
> @@ -1,5 +1,6 @@
>  /* { dg-do run { target i?86-*-* x86_64-*-* } } */
>  /* { dg-require-ifunc "" } */
> +/* { dg-options "-fcf-protection=none" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
>  int
> diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
> index 7987d53d305..00a3f3e5d5f 100644
> --- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
> +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
> @@ -1,6 +1,6 @@
>  /* Verify nocf_check functions are not ICF optimized.  */
>  /* { dg-do compile } */
> -/* { dg-options "-O2" } */
> +/* { dg-options "-O2 -fcf-protection=none -mno-cet" } */
>  /* { dg-final { scan-assembler-not "endbr" } } */
>  /* { dg-final { scan-assembler-not "fn3:" } } */
>  /* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */
> diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c
> index 07c4a6b61ef..c8b26f947d3 100644
> --- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c
> +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c
> @@ -1,6 +1,6 @@
>  /* Verify nocf_check function calls are not ICF optimized.  */
>  /* { dg-do compile } */
> -/* { dg-options "-O2" } */
> +/* { dg-options "-O2 -fcf-protection=none -mno-cet" } */
>  /* { dg-final { scan-assembler-not "endbr" } } */
>  /* { dg-final { scan-assembler-not "fn2:" } } */
>  /* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */
> diff --git a/gcc/testsuite/gcc.target/i386/cet-property-2.c b/gcc/testsuite/gcc.target/i386/cet-property-2.c
> index 5a87dab92f1..bca6f6cdeb7 100644
> --- a/gcc/testsuite/gcc.target/i386/cet-property-2.c
> +++ b/gcc/testsuite/gcc.target/i386/cet-property-2.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options "-mcet" } */
> +/* { dg-options "-mcet -fcf-protection=none" } */
>  /* { dg-final { scan-assembler-not ".note.gnu.property" } } */
>
>  extern void foo (void);
> diff --git a/gcc/testsuite/gcc.target/i386/mvc1.c b/gcc/testsuite/gcc.target/i386/mvc1.c
> index 752b3af7469..995056f850f 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc1.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc1.c
> @@ -1,4 +1,5 @@
>  /* { dg-do run } */
> +/* { dg-options "-fcf-protection=none" } */
>  /* { dg-require-ifunc "" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
> diff --git a/gcc/testsuite/gcc.target/i386/mvc10.c b/gcc/testsuite/gcc.target/i386/mvc10.c
> index 9a7b609c0b3..7452a33659f 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc10.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc10.c
> @@ -1,5 +1,6 @@
>  /* PR ipa/84722.  */
>  /* { dg-do run } */
> +/* { dg-options "-fcf-protection=none" } */
>  /* { dg-require-ifunc "" } */
>
>  __attribute__ ((target_clones ("avx", "arch=core-avx2", "default"))) int
> diff --git a/gcc/testsuite/gcc.target/i386/mvc11.c b/gcc/testsuite/gcc.target/i386/mvc11.c
> index 5bd10f4651d..c91ba635559 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc11.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc11.c
> @@ -1,6 +1,6 @@
>  /* { dg-do run } */
>  /* { dg-require-ifunc "" } */
> -/* { dg-options "-std=gnu99" } */
> +/* { dg-options "-std=gnu99 -fcf-protection=none" } */
>
>  __attribute__((noipa)) int
>  baz (int (*fn) (void))
> diff --git a/gcc/testsuite/gcc.target/i386/mvc6.c b/gcc/testsuite/gcc.target/i386/mvc6.c
> index af631394980..f14f575ba96 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc6.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc6.c
> @@ -1,6 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> -/* { dg-options "-O3" } */
> +/* { dg-options "-O3 -fcf-protection=none" } */
>  /* { dg-final { scan-assembler "vpshufb" } } */
>  /* { dg-final { scan-assembler "punpcklbw" } } */
>
> diff --git a/gcc/testsuite/gcc.target/i386/mvc7.c b/gcc/testsuite/gcc.target/i386/mvc7.c
> index a3697ba9b75..1a8226b65c6 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc7.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc7.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> +/* { dg-options "-fcf-protection=none" } */
>  /* { dg-final { scan-assembler "foo.resolver" } } */
>  /* { dg-final { scan-assembler "avx" } } */
>  /* { dg-final { scan-assembler "slm" } } */
> diff --git a/gcc/testsuite/gcc.target/i386/mvc8.c b/gcc/testsuite/gcc.target/i386/mvc8.c
> index 97d7941a5ab..cf3b4e12bec 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc8.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc8.c
> @@ -1,6 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> -/* { dg-options "-O3 -fno-inline" } */
> +/* { dg-options "-O3 -fno-inline -fcf-protection=none" } */
>  /* { dg-final { scan-assembler-not "constprop" } } */
>  __attribute__((target_clones("arch=core-avx2","arch=slm","default")))
>  void foo (float *a, int b) {
> diff --git a/gcc/testsuite/gcc.target/i386/mvc9.c b/gcc/testsuite/gcc.target/i386/mvc9.c
> index 4052f2afb54..5d140f2526b 100644
> --- a/gcc/testsuite/gcc.target/i386/mvc9.c
> +++ b/gcc/testsuite/gcc.target/i386/mvc9.c
> @@ -1,6 +1,6 @@
>  /* { dg-do run { target lto } } */
>  /* { dg-require-ifunc "" } */
> -/* { dg-options "-O2 -flto" } */
> +/* { dg-options "-O2 -flto -fcf-protection=none" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
>  int
> diff --git a/gcc/testsuite/gcc.target/i386/pr81213.c b/gcc/testsuite/gcc.target/i386/pr81213.c
> index 13e15d5fef0..52bdc1bda94 100644
> --- a/gcc/testsuite/gcc.target/i386/pr81213.c
> +++ b/gcc/testsuite/gcc.target/i386/pr81213.c
> @@ -1,6 +1,7 @@
>  /* PR ipa/81214.  */
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> +/* { dg-options "-fcf-protection=none" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
>  static int
> diff --git a/gcc/testsuite/gcc.target/i386/pr81214.c b/gcc/testsuite/gcc.target/i386/pr81214.c
> index 2584decdb3c..15db31da140 100644
> --- a/gcc/testsuite/gcc.target/i386/pr81214.c
> +++ b/gcc/testsuite/gcc.target/i386/pr81214.c
> @@ -1,6 +1,7 @@
>  /* PR ipa/81214.  */
>  /* { dg-do compile } */
>  /* { dg-require-ifunc "" } */
> +/* { dg-options "-fcf-protection=none" } */
>
>  __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
>  int
> 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" } */
> diff --git a/gcc/testsuite/gcc.target/i386/sse-26.c b/gcc/testsuite/gcc.target/i386/sse-26.c
> index f2607e64b59..0d786b2e37f 100644
> --- a/gcc/testsuite/gcc.target/i386/sse-26.c
> +++ b/gcc/testsuite/gcc.target/i386/sse-26.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -msse2 -mmmx -mno-sse3 -mno-3dnow -mno-fma -mno-fxsr -mno-xsave -mno-rtm -mno-prfchw -mno-rdseed -mno-adx -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-ibt -mno-shstk -mno-vaes -mno-vpclmulqdq" } */
> +/* { dg-options "-fcf-protection=none -O2 -Werror-implicit-function-declaration -march=k8 -msse2 -mmmx -mno-sse3 -mno-3dnow -mno-fma -mno-fxsr -mno-xsave -mno-rtm -mno-prfchw -mno-rdseed -mno-adx -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-ibt -mno-shstk -mno-vaes -mno-vpclmulqdq" } */
>  /* { dg-add-options bind_pic_locally } */
>
>  #include "sse-13.c"
> --
> 2.14.3
>

Patch

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/g++.dg/ext/mv1.C b/gcc/testsuite/g++.dg/ext/mv1.C
index 4eedbff7b23..af81f3aa056 100644
--- a/gcc/testsuite/g++.dg/ext/mv1.C
+++ b/gcc/testsuite/g++.dg/ext/mv1.C
@@ -1,7 +1,7 @@ 
 /* Test case to check if Multiversioning works.  */
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
-/* { dg-options "-O2 -fPIC" } */
+/* { dg-options "-O2 -fPIC -fcf-protection=none" } */
 
 #include <assert.h>
 
diff --git a/gcc/testsuite/g++.dg/ext/mv14.C b/gcc/testsuite/g++.dg/ext/mv14.C
index 1e7a1619698..82b153b7ebb 100644
--- a/gcc/testsuite/g++.dg/ext/mv14.C
+++ b/gcc/testsuite/g++.dg/ext/mv14.C
@@ -1,7 +1,7 @@ 
 /* Test case to check if Multiversioning works.  */
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
-/* { dg-options "-O2 -fPIC -march=x86-64" } */
+/* { dg-options "-O2 -fPIC -march=x86-64 -fcf-protection=none" } */
 
 #include <assert.h>
 
diff --git a/gcc/testsuite/g++.dg/ext/mv15.C b/gcc/testsuite/g++.dg/ext/mv15.C
index c0beadf16ea..3d1bf9934dd 100644
--- a/gcc/testsuite/g++.dg/ext/mv15.C
+++ b/gcc/testsuite/g++.dg/ext/mv15.C
@@ -1,7 +1,7 @@ 
 /* Test case to check if Multiversioning works.  */
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
-/* { dg-options "-O2 -fPIC -march=x86-64" } */
+/* { dg-options "-O2 -fPIC -march=x86-64 -fcf-protection=none" } */
 
 #include <assert.h>
 
diff --git a/gcc/testsuite/g++.dg/ext/mv16.C b/gcc/testsuite/g++.dg/ext/mv16.C
index 3e7c228a7f1..6e1d7a2aad6 100644
--- a/gcc/testsuite/g++.dg/ext/mv16.C
+++ b/gcc/testsuite/g++.dg/ext/mv16.C
@@ -4,7 +4,7 @@ 
 
 // { dg-do run { target i?86-*-* x86_64-*-* } }
 // { dg-require-ifunc "" }
-// { dg-options "-O2" }
+// { dg-options "-O2 -fcf-protection=none" }
 
 #include <assert.h>
 
diff --git a/gcc/testsuite/g++.dg/ext/mv17.C b/gcc/testsuite/g++.dg/ext/mv17.C
index 87c13246ed2..8c1fcac47f5 100644
--- a/gcc/testsuite/g++.dg/ext/mv17.C
+++ b/gcc/testsuite/g++.dg/ext/mv17.C
@@ -2,7 +2,7 @@ 
 
 // { dg-do run { target i?86-*-* x86_64-*-* } }
 // { dg-require-ifunc "" }
-// { dg-options "-O2" }
+// { dg-options "-O2 -fcf-protection=none" }
 
 #include <assert.h>
 
diff --git a/gcc/testsuite/g++.dg/ext/mv18.C b/gcc/testsuite/g++.dg/ext/mv18.C
index 1f024de9b95..3e64a26a31e 100644
--- a/gcc/testsuite/g++.dg/ext/mv18.C
+++ b/gcc/testsuite/g++.dg/ext/mv18.C
@@ -2,6 +2,6 @@ 
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
 /* { dg-require-effective-target pie } */
-/* { dg-options "-O2 -fPIE -pie" } */
+/* { dg-options "-O2 -fPIE -pie -fcf-protection=none" } */
 
 #include "mv1.C"
diff --git a/gcc/testsuite/g++.dg/ext/mv19.C b/gcc/testsuite/g++.dg/ext/mv19.C
index d1ea788745f..6a5c4190056 100644
--- a/gcc/testsuite/g++.dg/ext/mv19.C
+++ b/gcc/testsuite/g++.dg/ext/mv19.C
@@ -2,6 +2,6 @@ 
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
 /* { dg-require-effective-target pie } */
-/* { dg-options "-O2 -fPIE -pie -march=x86-64" } */
+/* { dg-options "-O2 -fPIE -pie -march=x86-64 -fcf-protection=none" } */
 
 #include "mv14.C"
diff --git a/gcc/testsuite/g++.dg/ext/mv20.C b/gcc/testsuite/g++.dg/ext/mv20.C
index 98f7408e1fc..302c1070201 100644
--- a/gcc/testsuite/g++.dg/ext/mv20.C
+++ b/gcc/testsuite/g++.dg/ext/mv20.C
@@ -2,6 +2,6 @@ 
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
 /* { dg-require-effective-target pie } */
-/* { dg-options "-O2 -fPIE -pie -march=x86-64" } */
+/* { dg-options "-O2 -fPIE -pie -march=x86-64 -fcf-protection=none" } */
 
 #include "mv15.C"
diff --git a/gcc/testsuite/g++.dg/ext/mv21.C b/gcc/testsuite/g++.dg/ext/mv21.C
index 9708ad95019..dfece312e97 100644
--- a/gcc/testsuite/g++.dg/ext/mv21.C
+++ b/gcc/testsuite/g++.dg/ext/mv21.C
@@ -2,6 +2,6 @@ 
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
 /* { dg-require-effective-target static } */
-/* { dg-options "-O2 -static" } */
+/* { dg-options "-O2 -static -fcf-protection=none" } */
 
 #include "mv1.C"
diff --git a/gcc/testsuite/g++.dg/ext/mv22.C b/gcc/testsuite/g++.dg/ext/mv22.C
index 2550136fdac..199f06037c7 100644
--- a/gcc/testsuite/g++.dg/ext/mv22.C
+++ b/gcc/testsuite/g++.dg/ext/mv22.C
@@ -2,6 +2,6 @@ 
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
 /* { dg-require-effective-target static } */
-/* { dg-options "-O2 -static -march=x86-64" } */
+/* { dg-options "-O2 -static -march=x86-64 -fcf-protection=none" } */
 
 #include "mv14.C"
diff --git a/gcc/testsuite/g++.dg/ext/mv23.C b/gcc/testsuite/g++.dg/ext/mv23.C
index f00afb01f15..946d8d95085 100644
--- a/gcc/testsuite/g++.dg/ext/mv23.C
+++ b/gcc/testsuite/g++.dg/ext/mv23.C
@@ -2,6 +2,6 @@ 
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
 /* { dg-require-effective-target static } */
-/* { dg-options "-O2 -static -march=x86-64" } */
+/* { dg-options "-O2 -static -march=x86-64 -fcf-protection=none" } */
 
 #include "mv15.C"
diff --git a/gcc/testsuite/g++.dg/ext/mv26.C b/gcc/testsuite/g++.dg/ext/mv26.C
index 1b455130e46..6c883e1830a 100644
--- a/gcc/testsuite/g++.dg/ext/mv26.C
+++ b/gcc/testsuite/g++.dg/ext/mv26.C
@@ -1,6 +1,7 @@ 
 // PR c++/84059
 // { dg-do compile { target i?86-*-* x86_64-*-* } }
 // { dg-require-ifunc "" }
+/* { dg-options "-fcf-protection=none" } */
 
 template <typename> struct a
 {
diff --git a/gcc/testsuite/g++.dg/ext/mv6.C b/gcc/testsuite/g++.dg/ext/mv6.C
index 2273065996b..056ca55b911 100644
--- a/gcc/testsuite/g++.dg/ext/mv6.C
+++ b/gcc/testsuite/g++.dg/ext/mv6.C
@@ -2,7 +2,7 @@ 
 
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" }  */
-/* { dg-options "-march=x86-64" } */
+/* { dg-options "-march=x86-64 -fcf-protection=none" } */
 
 class Foo
 {
diff --git a/gcc/testsuite/g++.dg/ext/mvc1.C b/gcc/testsuite/g++.dg/ext/mvc1.C
index ff37238a4e0..c3930ed0d2c 100644
--- a/gcc/testsuite/g++.dg/ext/mvc1.C
+++ b/gcc/testsuite/g++.dg/ext/mvc1.C
@@ -1,5 +1,6 @@ 
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-require-ifunc "" } */
+/* { dg-options "-fcf-protection=none" } */
 
 __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
 int
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
index 7987d53d305..00a3f3e5d5f 100644
--- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
@@ -1,6 +1,6 @@ 
 /* Verify nocf_check functions are not ICF optimized.  */
 /* { dg-do compile } */
-/* { dg-options "-O2" } */
+/* { dg-options "-O2 -fcf-protection=none -mno-cet" } */
 /* { dg-final { scan-assembler-not "endbr" } } */
 /* { dg-final { scan-assembler-not "fn3:" } } */
 /* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c
index 07c4a6b61ef..c8b26f947d3 100644
--- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c
@@ -1,6 +1,6 @@ 
 /* Verify nocf_check function calls are not ICF optimized.  */
 /* { dg-do compile } */
-/* { dg-options "-O2" } */
+/* { dg-options "-O2 -fcf-protection=none -mno-cet" } */
 /* { dg-final { scan-assembler-not "endbr" } } */
 /* { dg-final { scan-assembler-not "fn2:" } } */
 /* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */
diff --git a/gcc/testsuite/gcc.target/i386/cet-property-2.c b/gcc/testsuite/gcc.target/i386/cet-property-2.c
index 5a87dab92f1..bca6f6cdeb7 100644
--- a/gcc/testsuite/gcc.target/i386/cet-property-2.c
+++ b/gcc/testsuite/gcc.target/i386/cet-property-2.c
@@ -1,5 +1,5 @@ 
 /* { dg-do compile } */
-/* { dg-options "-mcet" } */
+/* { dg-options "-mcet -fcf-protection=none" } */
 /* { dg-final { scan-assembler-not ".note.gnu.property" } } */
 
 extern void foo (void);
diff --git a/gcc/testsuite/gcc.target/i386/mvc1.c b/gcc/testsuite/gcc.target/i386/mvc1.c
index 752b3af7469..995056f850f 100644
--- a/gcc/testsuite/gcc.target/i386/mvc1.c
+++ b/gcc/testsuite/gcc.target/i386/mvc1.c
@@ -1,4 +1,5 @@ 
 /* { dg-do run } */
+/* { dg-options "-fcf-protection=none" } */
 /* { dg-require-ifunc "" } */
 
 __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
diff --git a/gcc/testsuite/gcc.target/i386/mvc10.c b/gcc/testsuite/gcc.target/i386/mvc10.c
index 9a7b609c0b3..7452a33659f 100644
--- a/gcc/testsuite/gcc.target/i386/mvc10.c
+++ b/gcc/testsuite/gcc.target/i386/mvc10.c
@@ -1,5 +1,6 @@ 
 /* PR ipa/84722.  */
 /* { dg-do run } */
+/* { dg-options "-fcf-protection=none" } */
 /* { dg-require-ifunc "" } */
 
 __attribute__ ((target_clones ("avx", "arch=core-avx2", "default"))) int
diff --git a/gcc/testsuite/gcc.target/i386/mvc11.c b/gcc/testsuite/gcc.target/i386/mvc11.c
index 5bd10f4651d..c91ba635559 100644
--- a/gcc/testsuite/gcc.target/i386/mvc11.c
+++ b/gcc/testsuite/gcc.target/i386/mvc11.c
@@ -1,6 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-require-ifunc "" } */
-/* { dg-options "-std=gnu99" } */
+/* { dg-options "-std=gnu99 -fcf-protection=none" } */
 
 __attribute__((noipa)) int 
 baz (int (*fn) (void))
diff --git a/gcc/testsuite/gcc.target/i386/mvc6.c b/gcc/testsuite/gcc.target/i386/mvc6.c
index af631394980..f14f575ba96 100644
--- a/gcc/testsuite/gcc.target/i386/mvc6.c
+++ b/gcc/testsuite/gcc.target/i386/mvc6.c
@@ -1,6 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-require-ifunc "" } */
-/* { dg-options "-O3" } */
+/* { dg-options "-O3 -fcf-protection=none" } */
 /* { dg-final { scan-assembler "vpshufb" } } */
 /* { dg-final { scan-assembler "punpcklbw" } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/mvc7.c b/gcc/testsuite/gcc.target/i386/mvc7.c
index a3697ba9b75..1a8226b65c6 100644
--- a/gcc/testsuite/gcc.target/i386/mvc7.c
+++ b/gcc/testsuite/gcc.target/i386/mvc7.c
@@ -1,5 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-require-ifunc "" } */
+/* { dg-options "-fcf-protection=none" } */
 /* { dg-final { scan-assembler "foo.resolver" } } */
 /* { dg-final { scan-assembler "avx" } } */
 /* { dg-final { scan-assembler "slm" } } */
diff --git a/gcc/testsuite/gcc.target/i386/mvc8.c b/gcc/testsuite/gcc.target/i386/mvc8.c
index 97d7941a5ab..cf3b4e12bec 100644
--- a/gcc/testsuite/gcc.target/i386/mvc8.c
+++ b/gcc/testsuite/gcc.target/i386/mvc8.c
@@ -1,6 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-require-ifunc "" } */
-/* { dg-options "-O3 -fno-inline" } */
+/* { dg-options "-O3 -fno-inline -fcf-protection=none" } */
 /* { dg-final { scan-assembler-not "constprop" } } */
 __attribute__((target_clones("arch=core-avx2","arch=slm","default")))
 void foo (float *a, int b) {
diff --git a/gcc/testsuite/gcc.target/i386/mvc9.c b/gcc/testsuite/gcc.target/i386/mvc9.c
index 4052f2afb54..5d140f2526b 100644
--- a/gcc/testsuite/gcc.target/i386/mvc9.c
+++ b/gcc/testsuite/gcc.target/i386/mvc9.c
@@ -1,6 +1,6 @@ 
 /* { dg-do run { target lto } } */
 /* { dg-require-ifunc "" } */
-/* { dg-options "-O2 -flto" } */
+/* { dg-options "-O2 -flto -fcf-protection=none" } */
 
 __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
 int
diff --git a/gcc/testsuite/gcc.target/i386/pr81213.c b/gcc/testsuite/gcc.target/i386/pr81213.c
index 13e15d5fef0..52bdc1bda94 100644
--- a/gcc/testsuite/gcc.target/i386/pr81213.c
+++ b/gcc/testsuite/gcc.target/i386/pr81213.c
@@ -1,6 +1,7 @@ 
 /* PR ipa/81214.  */
 /* { dg-do compile } */
 /* { dg-require-ifunc "" } */
+/* { dg-options "-fcf-protection=none" } */
 
 __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
 static int
diff --git a/gcc/testsuite/gcc.target/i386/pr81214.c b/gcc/testsuite/gcc.target/i386/pr81214.c
index 2584decdb3c..15db31da140 100644
--- a/gcc/testsuite/gcc.target/i386/pr81214.c
+++ b/gcc/testsuite/gcc.target/i386/pr81214.c
@@ -1,6 +1,7 @@ 
 /* PR ipa/81214.  */
 /* { dg-do compile } */
 /* { dg-require-ifunc "" } */
+/* { dg-options "-fcf-protection=none" } */
 
 __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
 int
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" } */
diff --git a/gcc/testsuite/gcc.target/i386/sse-26.c b/gcc/testsuite/gcc.target/i386/sse-26.c
index f2607e64b59..0d786b2e37f 100644
--- a/gcc/testsuite/gcc.target/i386/sse-26.c
+++ b/gcc/testsuite/gcc.target/i386/sse-26.c
@@ -1,5 +1,5 @@ 
 /* { dg-do compile } */
-/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -msse2 -mmmx -mno-sse3 -mno-3dnow -mno-fma -mno-fxsr -mno-xsave -mno-rtm -mno-prfchw -mno-rdseed -mno-adx -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-ibt -mno-shstk -mno-vaes -mno-vpclmulqdq" } */
+/* { dg-options "-fcf-protection=none -O2 -Werror-implicit-function-declaration -march=k8 -msse2 -mmmx -mno-sse3 -mno-3dnow -mno-fma -mno-fxsr -mno-xsave -mno-rtm -mno-prfchw -mno-rdseed -mno-adx -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-ibt -mno-shstk -mno-vaes -mno-vpclmulqdq" } */
 /* { dg-add-options bind_pic_locally } */
 
 #include "sse-13.c"