public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation
@ 2017-08-01  8:57 Tsimbalist, Igor V
  2017-08-25 22:46 ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Jeff Law
  0 siblings, 1 reply; 17+ messages in thread
From: Tsimbalist, Igor V @ 2017-08-01  8:57 UTC (permalink / raw)
  To: 'gcc-patches@gcc.gnu.org'; +Cc: Tsimbalist, Igor V

[-- Attachment #1: Type: text/plain, Size: 53 bytes --]

Part#6. Add x86 tests for Intel CET implementation.

[-- Attachment #2: 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation.patch --]
[-- Type: application/octet-stream, Size: 34836 bytes --]

From e4a8227e83e8e9f3ddbaa97707f3d335009e0e77 Mon Sep 17 00:00:00 2001
From: Igor Tsimbalist <igor.v.tsimbalist@intel.com>
Date: Fri, 21 Jul 2017 19:40:40 +0300
Subject: [PATCH 6/9] Part#6. Add x86 tests for Intel CET implementation.

gcc/testsuite/

	* g++.dg/cet-notrack-1.C: New test.
	* gcc.target/i386/cet-intrin-1.c: Likewise.
	* gcc.target/i386/cet-intrin-10.c: Likewise.
	* gcc.target/i386/cet-intrin-2.c: Likewise.
	* gcc.target/i386/cet-intrin-3.c: Likewise.
	* gcc.target/i386/cet-intrin-4.c: Likewise.
	* gcc.target/i386/cet-intrin-5.c: Likewise.
	* gcc.target/i386/cet-intrin-6.c: Likewise.
	* gcc.target/i386/cet-intrin-7.c: Likewise.
	* gcc.target/i386/cet-intrin-8.c: Likewise.
	* gcc.target/i386/cet-intrin-9.c: Likewise.
	* gcc.target/i386/cet-label.c: Likewise.
	* gcc.target/i386/cet-notrack-1a.c: Likewise.
	* gcc.target/i386/cet-notrack-1b.c: Likewise.
	* gcc.target/i386/cet-notrack-2a.c: Likewise.
	* gcc.target/i386/cet-notrack-2b.c: Likewise.
	* gcc.target/i386/cet-notrack-3.c: Likewise.
	* gcc.target/i386/cet-notrack-4a.c: Likewise.
	* gcc.target/i386/cet-notrack-4b.c: Likewise.
	* gcc.target/i386/cet-notrack-5a.c: Likewise.
	* gcc.target/i386/cet-notrack-5b.c: Likewise.
	* gcc.target/i386/cet-notrack-6a.c: Likewise.
	* gcc.target/i386/cet-notrack-6b.c: Likewise.
	* gcc.target/i386/cet-notrack-7.c: Likewise.
	* gcc.target/i386/cet-property-1.c: Likewise.
	* gcc.target/i386/cet-property-2.c: Likewise.
	* gcc.target/i386/cet-rdssp-1.c: Likewise.
	* gcc.target/i386/cet-sjlj-1.c: Likewise.
	* gcc.target/i386/cet-sjlj-2.c: Likewise.
	* gcc.target/i386/cet-sjlj-3.c: Likewise.
	* gcc.target/i386/cet-switch-1.c: Likewise.
	* gcc.target/i386/cet-switch-2.c: Likewise.
	* lib/target-supports.exp (check_effective_target_cet): New
	proc.
---
 gcc/testsuite/g++.dg/cet-notrack-1.C           | 25 ++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-1.c   | 33 ++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-10.c  | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-2.c   | 32 ++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-3.c   | 33 ++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-4.c   | 31 +++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-5.c   | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-6.c   | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-7.c   | 18 ++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-8.c   | 18 ++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-9.c   | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-label.c      | 16 +++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-1a.c | 21 ++++++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-1b.c | 22 ++++++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-2a.c | 12 +++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-2b.c | 12 +++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-3.c  | 14 ++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-4a.c |  6 ++++
 gcc/testsuite/gcc.target/i386/cet-notrack-4b.c |  6 ++++
 gcc/testsuite/gcc.target/i386/cet-notrack-5a.c | 16 +++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-5b.c | 21 ++++++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-6a.c | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-6b.c | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-7.c  | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-property-1.c | 11 ++++++
 gcc/testsuite/gcc.target/i386/cet-property-2.c | 11 ++++++
 gcc/testsuite/gcc.target/i386/cet-rdssp-1.c    | 39 ++++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-sjlj-1.c     | 42 +++++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-sjlj-2.c     |  4 +++
 gcc/testsuite/gcc.target/i386/cet-sjlj-3.c     | 46 ++++++++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-switch-1.c   | 26 +++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-switch-2.c   | 26 +++++++++++++++
 gcc/testsuite/lib/target-supports.exp          | 14 ++++++++
 33 files changed, 660 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cet-notrack-1.C
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-10.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-4.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-5.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-6.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-7.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-8.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-9.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-label.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-1a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-1b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-2a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-2b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-4a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-4b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-5a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-5b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-6a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-6b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-7.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-property-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-property-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-rdssp-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-sjlj-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-sjlj-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-sjlj-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-switch-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-switch-2.c
---
 gcc/testsuite/g++.dg/cet-notrack-1.C           | 25 ++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-1.c   | 33 ++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-10.c  | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-2.c   | 32 ++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-3.c   | 33 ++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-4.c   | 31 +++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-5.c   | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-6.c   | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-7.c   | 18 ++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-8.c   | 18 ++++++++++
 gcc/testsuite/gcc.target/i386/cet-intrin-9.c   | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-label.c      | 16 +++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-1a.c | 21 ++++++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-1b.c | 22 ++++++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-2a.c | 12 +++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-2b.c | 12 +++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-3.c  | 14 ++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-4a.c |  6 ++++
 gcc/testsuite/gcc.target/i386/cet-notrack-4b.c |  6 ++++
 gcc/testsuite/gcc.target/i386/cet-notrack-5a.c | 16 +++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-5b.c | 21 ++++++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-6a.c | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-6b.c | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-notrack-7.c  | 15 +++++++++
 gcc/testsuite/gcc.target/i386/cet-property-1.c | 11 ++++++
 gcc/testsuite/gcc.target/i386/cet-property-2.c | 11 ++++++
 gcc/testsuite/gcc.target/i386/cet-rdssp-1.c    | 39 ++++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-sjlj-1.c     | 42 +++++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-sjlj-2.c     |  4 +++
 gcc/testsuite/gcc.target/i386/cet-sjlj-3.c     | 46 ++++++++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-switch-1.c   | 26 +++++++++++++++
 gcc/testsuite/gcc.target/i386/cet-switch-2.c   | 26 +++++++++++++++
 gcc/testsuite/lib/target-supports.exp          | 14 ++++++++
 33 files changed, 660 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cet-notrack-1.C
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-10.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-4.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-5.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-6.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-7.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-8.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-intrin-9.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-label.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-1a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-1b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-2a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-2b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-4a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-4b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-5a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-5b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-6a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-6b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-notrack-7.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-property-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-property-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-rdssp-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-sjlj-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-sjlj-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-sjlj-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-switch-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-switch-2.c

diff --git a/gcc/testsuite/g++.dg/cet-notrack-1.C b/gcc/testsuite/g++.dg/cet-notrack-1.C
new file mode 100644
index 0000000..3aff747
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cet-notrack-1.C
@@ -0,0 +1,25 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler "endbr32|endbr64" } } */
+/* { dg-final { scan-assembler-times "\tcall\[ \t]+puts" 2 } } */
+/* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */
+#include <stdio.h>
+
+struct A {
+virtual int foo() { return 42; }
+};
+
+struct B : A {
+int foo() __attribute__((notrack)) { return 73; }
+};
+
+int main() {
+B b;
+A& a = b;
+int (A::*amem) () __attribute__((notrack)) = &A::foo; // take address
+if ((a.*amem)() == 73) // use the address
+  printf("pass\n");
+else
+  printf("fail\n");
+return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-1.c b/gcc/testsuite/gcc.target/i386/cet-intrin-1.c
new file mode 100644
index 0000000..23388fd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-1.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 2 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 4 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "rdsspd|incsspd\[ \t]+(%|)eax" { target ia32 } } } */
+/* { dg-final { scan-assembler "rdssp\[dq]\[ \t]+(%|)\[re]ax" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "incssp\[dq]\[ \t]+(%|)\[re]di" { target { ! ia32 } } } } */
+
+#include <immintrin.h>
+
+unsigned int f1 ()
+{
+  unsigned int x = 0;
+  return __builtin_ia32_rdsspd (x);
+}
+
+void f3 (unsigned int _a)
+{
+  __builtin_ia32_incsspd (_a);
+}
+
+#ifdef __x86_64__
+unsigned long long f2 ()
+{
+  unsigned long long x = 0;
+  return __builtin_ia32_rdsspq (x);
+}
+
+void f4 (unsigned int _a)
+{
+  __builtin_ia32_incsspq (_a);
+}
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-10.c b/gcc/testsuite/gcc.target/i386/cet-intrin-10.c
new file mode 100644
index 0000000..9d85675
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-10.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcet" } */
+/* { dg-final { scan-assembler-times "clrssbsy" 2 } } */
+
+#include <immintrin.h>
+
+void f1 (void *__B)
+{
+  __builtin_ia32_clrssbsy (__B);
+}
+
+void f2 (void *__B)
+{
+  _clrssbsy (__B);
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-2.c b/gcc/testsuite/gcc.target/i386/cet-intrin-2.c
new file mode 100644
index 0000000..1efa69f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-2.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mshstk" } */
+/* { dg-final { scan-assembler "rdsspd|incsspd\[ \t]+(%|)eax" { target ia32 } } } */
+/* { dg-final { scan-assembler "rdssp\[dq]\[ \t]+(%|)\[re]ax" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "incssp\[dq]\[ \t]+(%|)\[re]di" { target { ! ia32 } } } } */
+
+#include <immintrin.h>
+
+unsigned int f1 ()
+{
+  unsigned int x = 0;
+  return __builtin_ia32_rdsspd (x);
+}
+
+void f3 (unsigned int _a)
+{
+  __builtin_ia32_incsspd (_a);
+}
+
+#ifdef __x86_64__
+unsigned long long f2 ()
+{
+  unsigned long long x = 0;
+  return __builtin_ia32_rdsspq (x);
+}
+
+
+void f4 (unsigned int _a)
+{
+  __builtin_ia32_incsspq (_a);
+}
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-3.c b/gcc/testsuite/gcc.target/i386/cet-intrin-3.c
new file mode 100644
index 0000000..d287075
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-3.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 2 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 4 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "rdsspd|incsspd\[ \t]+(%|)eax" { target ia32 } } } */
+/* { dg-final { scan-assembler "rdssp\[dq]\[ \t]+(%|)\[re]ax" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "incssp\[dq]\[ \t]+(%|)\[re]di" { target { ! ia32 } } } } */
+
+#include <immintrin.h>
+
+unsigned int f1 ()
+{
+  unsigned int x = 0;
+  return _rdsspd (x);
+}
+
+void f3 (unsigned int _a)
+{
+  _incsspd (_a);
+}
+
+#ifdef __x86_64__
+unsigned long long f2 ()
+{
+  unsigned long long x = 0;
+  return _rdsspq (x);
+}
+
+void f4 (unsigned int _a)
+{
+  _incsspq (_a);
+}
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-4.c b/gcc/testsuite/gcc.target/i386/cet-intrin-4.c
new file mode 100644
index 0000000..61f280d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-4.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mshstk" } */
+/* { dg-final { scan-assembler "rdsspd|incsspd\[ \t]+(%|)eax" { target ia32 } } } */
+/* { dg-final { scan-assembler "rdssp\[dq]\[ \t]+(%|)\[re]ax"  { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "incssp\[dq]\[ \t]+(%|)\[re]di" { target { ! ia32 } } } } */
+
+#include <immintrin.h>
+
+unsigned int f1 ()
+{
+  unsigned int x = 0;
+  return _rdsspd (x);
+}
+
+void f3 (unsigned int _a)
+{
+  _incsspd (_a);
+}
+
+#ifdef __x86_64__
+unsigned long long f2 ()
+{
+  unsigned long long x = 0;
+  return _rdsspq (x);
+}
+
+void f4 (unsigned int _a)
+{
+  _incsspq (_a);
+}
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-5.c b/gcc/testsuite/gcc.target/i386/cet-intrin-5.c
new file mode 100644
index 0000000..0b93736
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-5.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcet" } */
+/* { dg-final { scan-assembler-times "saveprevssp" 2 } } */
+
+#include <immintrin.h>
+
+void f1 (void)
+{
+  __builtin_ia32_saveprevssp ();
+}
+
+void f2 (void)
+{
+  _saveprevssp ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-6.c b/gcc/testsuite/gcc.target/i386/cet-intrin-6.c
new file mode 100644
index 0000000..df76334
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-6.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcet" } */
+/* { dg-final { scan-assembler-times "rstorssp" 2 } } */
+
+#include <immintrin.h>
+
+void f1 (void *__B)
+{
+  __builtin_ia32_rstorssp (__B);
+}
+
+void f2 (void *__B)
+{
+  _rstorssp (__B);
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-7.c b/gcc/testsuite/gcc.target/i386/cet-intrin-7.c
new file mode 100644
index 0000000..06be7ee
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-7.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcet" } */
+/* { dg-final { scan-assembler-times "wrssd" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "wrss\[d|q]" 2 { target lp64 } } } */
+
+#include <immintrin.h>
+
+void f1 (unsigned int __A, void *__B)
+{
+  __builtin_ia32_wrssd (__A, __B);
+}
+
+#ifdef __x86_64__
+void f2 (unsigned long long __A, void *__B)
+{
+  _wrssq (__A, __B);
+}
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-8.c b/gcc/testsuite/gcc.target/i386/cet-intrin-8.c
new file mode 100644
index 0000000..88b2ce2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-8.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcet" } */
+/* { dg-final { scan-assembler-times "wrussd" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "wruss\[d|q]" 2 { target lp64 } } } */
+
+#include <immintrin.h>
+
+void f1 (unsigned int __A, void *__B)
+{
+  __builtin_ia32_wrussd (__A, __B);
+}
+
+#ifdef __x86_64__
+void f2 (unsigned long long __A, void *__B)
+{
+  _wrussq (__A, __B);
+}
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/cet-intrin-9.c b/gcc/testsuite/gcc.target/i386/cet-intrin-9.c
new file mode 100644
index 0000000..c4a9582
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-intrin-9.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcet" } */
+/* { dg-final { scan-assembler-times "setssbsy" 2 } } */
+
+#include <immintrin.h>
+
+void f1 (void)
+{
+  __builtin_ia32_setssbsy ();
+}
+
+void f2 (void)
+{
+  _setssbsy ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-label.c b/gcc/testsuite/gcc.target/i386/cet-label.c
new file mode 100644
index 0000000..62b5dce
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-label.c
@@ -0,0 +1,16 @@
+/* Verify that CET works.  */
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 3 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 3 { target { ! ia32 } } } } */
+
+int func (int arg)
+{
+  static void *array[] = { &&foo, &&bar };
+
+  goto *array[arg];
+foo:
+  return arg*111;
+bar:
+  return arg*777;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-1a.c b/gcc/testsuite/gcc.target/i386/cet-notrack-1a.c
new file mode 100644
index 0000000..68600f2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-1a.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -fno-instrument-control-flow -mno-cet" } */
+/* { dg-final { scan-assembler-not "endbr" } } */
+/* { dg-final { scan-assembler-not "notrack call\[ \t]+" } } */
+
+int func (int a) __attribute__ ((notrack));
+int (*fptr) (int a) __attribute__ ((notrack));
+
+int foo (int arg)
+{
+  int a, b;
+  a = func (arg);
+  b = (*fptr) (arg);
+  return a+b;
+}
+
+int func (int arg)
+{
+  int (*fptrl) (int a) __attribute__ ((notrack));
+  return arg*(*fptrl)(arg);
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-1b.c b/gcc/testsuite/gcc.target/i386/cet-notrack-1b.c
new file mode 100644
index 0000000..38441c7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-1b.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "notrack call\[ \t]+" 2 } } */
+
+int func (int a) __attribute__ ((notrack));
+int (*fptr) (int a) __attribute__ ((notrack));
+
+int foo (int arg)
+{
+int a, b;
+  a = func (arg);
+  b = (*fptr) (arg);
+  return a+b;
+}
+
+int func (int arg)
+{
+int (*fptrl) (int a) __attribute__ ((notrack));
+  return arg*(*fptrl)(arg);
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-2a.c b/gcc/testsuite/gcc.target/i386/cet-notrack-2a.c
new file mode 100644
index 0000000..d2caf6a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-2a.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */
+
+void
+bar (void (*foo) (void))
+{
+  void (*func) (void) __attribute__((notrack)) = foo;
+  func ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-2b.c b/gcc/testsuite/gcc.target/i386/cet-notrack-2b.c
new file mode 100644
index 0000000..b7e8cf2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-2b.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O2 -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "notrack jmp\[ \t]+" 1 } } */
+
+void
+bar (void (*foo) (void))
+{
+  void (*func) (void) __attribute__((notrack)) = foo;
+  func ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-3.c b/gcc/testsuite/gcc.target/i386/cet-notrack-3.c
new file mode 100644
index 0000000..caafd7c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-3.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */
+
+typedef void (*func_t) (void) __attribute__((notrack));
+extern func_t func;
+
+void
+bar (void)
+{
+  func ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-4a.c b/gcc/testsuite/gcc.target/i386/cet-notrack-4a.c
new file mode 100644
index 0000000..b93e5bf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-4a.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-instrument-control-flow -mno-cet" } */
+
+int var1 __attribute__((notrack)); /* { dg-warning "'notrack' attribute only applies to function types" } */
+int *var2 __attribute__((notrack)); /* { dg-warning "'notrack' attribute only applies to function types" } */
+void (**var3) (void) __attribute__((notrack)); /* { dg-warning "'notrack' attribute only applies to function types" } */
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-4b.c b/gcc/testsuite/gcc.target/i386/cet-notrack-4b.c
new file mode 100644
index 0000000..2b7fd9b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-4b.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+
+int var1 __attribute__((notrack)); /* { dg-warning "'notrack' attribute only applies to function types" } */
+int *var2 __attribute__((notrack)); /* { dg-warning "'notrack' attribute only applies to function types" } */
+void (**var3) (void) __attribute__((notrack)); /* { dg-warning "'notrack' attribute only applies to function types" } */
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-5a.c b/gcc/testsuite/gcc.target/i386/cet-notrack-5a.c
new file mode 100644
index 0000000..8940260
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-5a.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-not "\tcall\[ \t]+" } } */
+/* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */
+
+int (*fptr) (int) __attribute__ ((notrack));
+
+int
+foo (int arg)
+{
+  int a;
+  a = (*fptr) (arg); /* notrack call.  */
+  return arg+a;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-5b.c b/gcc/testsuite/gcc.target/i386/cet-notrack-5b.c
new file mode 100644
index 0000000..5ad845a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-5b.c
@@ -0,0 +1,21 @@
+/* Check the attribute do not proparate through assignment.  */
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "\tcall\[ \t]+" 1 } } */
+/* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */
+
+int (*fptr) (int) __attribute__ ((notrack));
+int (*fptr1) (int);
+
+int
+foo (int arg)
+{
+  int a;
+  a = (*fptr) (arg); /* notrack call.  */
+  arg += a;
+  fptr1 = fptr;
+  a = (*fptr1) (arg); /* track call.  */
+  return arg+a;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-6a.c b/gcc/testsuite/gcc.target/i386/cet-notrack-6a.c
new file mode 100644
index 0000000..a085b4c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-6a.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "\t(?:call|jmp)\[ \t]+foo" 1 } } */
+/* { dg-final { scan-assembler-not "notrack call\[ \t]+" } } */
+
+int foo (int arg);
+
+int func (int arg)
+{
+  int (*fptrl) (int a) __attribute__ ((notrack)) = foo;
+
+  return (*fptrl)(arg);
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-6b.c b/gcc/testsuite/gcc.target/i386/cet-notrack-6b.c
new file mode 100644
index 0000000..6bc25b5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-6b.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-not "\tcall\[ \t]+" } } */
+/* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */
+
+int foo (int arg);
+
+int func (int arg)
+{
+  int (*fptrl) (int a) __attribute__ ((notrack)) = foo;
+
+  return (*fptrl)(arg);  /* notrack call.  */
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-7.c b/gcc/testsuite/gcc.target/i386/cet-notrack-7.c
new file mode 100644
index 0000000..b90bf5a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-notrack-7.c
@@ -0,0 +1,15 @@
+/* Check the notrack prefix is not generated for direct call.  */
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "notrack call\[ \t]+foo" 0 } } */
+/* { dg-final { scan-assembler-times "\tcall\[ \t]+foo" 1 } } */
+
+extern void foo (void) __attribute__((notrack));
+
+void
+bar (void)
+{
+  foo ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-property-1.c b/gcc/testsuite/gcc.target/i386/cet-property-1.c
new file mode 100644
index 0000000..4782e76
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-property-1.c
@@ -0,0 +1,11 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler ".note.gnu.property" } } */
+
+extern void foo (void);
+
+void
+bar (void)
+{
+  foo ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-property-2.c b/gcc/testsuite/gcc.target/i386/cet-property-2.c
new file mode 100644
index 0000000..5a87dab
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-property-2.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-mcet" } */
+/* { dg-final { scan-assembler-not ".note.gnu.property" } } */
+
+extern void foo (void);
+
+void
+bar (void)
+{
+  foo ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-rdssp-1.c b/gcc/testsuite/gcc.target/i386/cet-rdssp-1.c
new file mode 100644
index 0000000..f9223a5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-rdssp-1.c
@@ -0,0 +1,39 @@
+/* { dg-do run { target cet } } */
+/* { dg-options "-O2 -finstrument-control-flow -mcet" } */
+
+void _exit(int status) __attribute__ ((__noreturn__));
+
+#ifdef __x86_64__
+# define incssp(x) __builtin_ia32_incsspq (x)
+# define rdssp(x) __builtin_ia32_rdsspq (x)
+#else
+# define incssp(x) __builtin_ia32_incsspd (x)
+# define rdssp(x) __builtin_ia32_rdsspd (x)
+#endif
+
+static void
+__attribute__ ((noinline, noclone))
+test (unsigned long frames)
+{
+  unsigned long ssp = 0;
+  ssp = rdssp (ssp);
+  if (ssp != 0)
+    {
+      unsigned long tmp = frames;
+      while (tmp > 255)
+	{
+	  incssp (tmp);
+	  tmp -= 255;
+	}
+      incssp (tmp);
+    }
+  /* We must call _exit since shadow stack is incorrect now.  */
+  _exit (0);
+}
+
+int
+main ()
+{
+  test (1);
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-sjlj-1.c b/gcc/testsuite/gcc.target/i386/cet-sjlj-1.c
new file mode 100644
index 0000000..9f25d9a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-sjlj-1.c
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 4 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 4 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "rdssp\[dq]" 2 } } */
+/* { dg-final { scan-assembler-times "incssp\[dq]" 1 } } */
+
+/* Based on gcc.dg/setjmp-3.c.  */
+
+void *buf[5];
+
+extern void abort (void);
+
+void raise0(void)
+{
+  __builtin_longjmp (buf, 1);
+}
+
+int execute(int cmd)
+{
+  int last = 0;
+
+  if (__builtin_setjmp (buf) == 0)
+    while (1)
+      {
+	last = 1;
+	raise0 ();
+      }
+
+  if (last == 0)
+    return 0;
+  else
+    return cmd;
+}
+
+int main(void)
+{
+  if (execute (1) == 0)
+    abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-sjlj-2.c b/gcc/testsuite/gcc.target/i386/cet-sjlj-2.c
new file mode 100644
index 0000000..e32ecf6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-sjlj-2.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target cet } } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+
+#include "cet-sjlj-1.c"
diff --git a/gcc/testsuite/gcc.target/i386/cet-sjlj-3.c b/gcc/testsuite/gcc.target/i386/cet-sjlj-3.c
new file mode 100644
index 0000000..5b97f74
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-sjlj-3.c
@@ -0,0 +1,46 @@
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 4 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 4 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "call	_setjmp" 1 } } */
+/* { dg-final { scan-assembler-times "call	longjmp" 1 } } */
+
+#include <stdio.h>
+#include <setjmp.h>
+
+jmp_buf buf;
+int bar (int);
+
+int
+foo (int i)
+{
+  int j = i * 11;
+
+  if (!setjmp (buf))
+    {
+      j += 33;
+      printf ("After setjmp: j = %d\n", j);
+      bar (j);
+    }
+
+  return j + i;
+}
+
+int
+bar (int i)
+{
+int j = i;
+
+  j -= 111;
+  printf ("In longjmp: j = %d\n", j);
+  longjmp (buf, 1);
+
+  return j;
+}
+
+int
+main ()
+{
+  foo (10);
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-switch-1.c b/gcc/testsuite/gcc.target/i386/cet-switch-1.c
new file mode 100644
index 0000000..61af4ef
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-switch-1.c
@@ -0,0 +1,26 @@
+/* Verify that CET works.  */
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "notrack jmp\[ \t]+\[*]" 1 } } */
+
+void func2 (int);
+
+int func1 (int arg)
+{
+  switch (arg)
+  {
+    case 1: func2 (arg*100);
+    case 2: func2 (arg*300);
+    case 5: func2 (arg*500);
+    case 8: func2 (arg*700);
+    case 7: func2 (arg*900);
+    case -1: func2 (arg*-100);
+    case -2: func2 (arg*-300);
+    case -5: func2 (arg*-500);
+    case -7: func2 (arg*-700);
+    case -9: func2 (arg*-900);
+  }
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-switch-2.c b/gcc/testsuite/gcc.target/i386/cet-switch-2.c
new file mode 100644
index 0000000..f9fb69f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-switch-2.c
@@ -0,0 +1,26 @@
+/* Verify that CET works.  */
+/* { dg-do compile } */
+/* { dg-options "-O -finstrument-control-flow -mcet -mcet-switch" } */
+/* { dg-final { scan-assembler-times "endbr32" 12 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 12 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "\[ \t]+jmp\[ \t]+\[*]" 1 } } */
+
+void func2 (int);
+
+int func1 (int arg)
+{
+  switch (arg)
+  {
+    case 1: func2 (arg*100);
+    case 2: func2 (arg*300);
+    case 5: func2 (arg*500);
+    case 8: func2 (arg*700);
+    case 7: func2 (arg*900);
+    case -1: func2 (arg*-100);
+    case -2: func2 (arg*-300);
+    case -5: func2 (arg*-500);
+    case -7: func2 (arg*-700);
+    case -9: func2 (arg*-900);
+  }
+  return 0;
+}
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 5a65627..f6f297b 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -8482,3 +8482,17 @@ proc check_effective_target_arm_coproc4_ok { } {
     return [check_cached_effective_target arm_coproc4_ok \
 		check_effective_target_arm_coproc4_ok_nocache]
 }
+
+# Return 1 if CET instructions can be compiled.
+
+proc check_effective_target_cet { } {
+    if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
+	return 0
+    }
+    return [check_no_compiler_messages cet object {
+	void foo (void)
+	{
+	  asm ("setssbsy");
+	}
+    } "-O2" ]
+}
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation
@ 2017-09-18 10:17 Uros Bizjak
  2017-09-19 15:18 ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Tsimbalist, Igor V
  0 siblings, 1 reply; 17+ messages in thread
From: Uros Bizjak @ 2017-09-18 10:17 UTC (permalink / raw)
  To: gcc-patches; +Cc: Tsimbalist, Igor V

Hello!

> gcc/testsuite/
>
> * g++.dg/cet-notrack-1.C: New test.
> * gcc.target/i386/cet-intrin-1.c: Likewise.
> * gcc.target/i386/cet-intrin-10.c: Likewise.
> * gcc.target/i386/cet-intrin-2.c: Likewise.
> * gcc.target/i386/cet-intrin-3.c: Likewise.
> * gcc.target/i386/cet-intrin-4.c: Likewise.
> * gcc.target/i386/cet-intrin-5.c: Likewise.
> * gcc.target/i386/cet-intrin-6.c: Likewise.
> * gcc.target/i386/cet-intrin-7.c: Likewise.
> * gcc.target/i386/cet-intrin-8.c: Likewise.
> * gcc.target/i386/cet-intrin-9.c: Likewise.
> * gcc.target/i386/cet-label.c: Likewise.
> * gcc.target/i386/cet-notrack-1a.c: Likewise.
> * gcc.target/i386/cet-notrack-1b.c: Likewise.
> * gcc.target/i386/cet-notrack-2a.c: Likewise.
> * gcc.target/i386/cet-notrack-2b.c: Likewise.
> * gcc.target/i386/cet-notrack-3.c: Likewise.
> * gcc.target/i386/cet-notrack-4a.c: Likewise.
> * gcc.target/i386/cet-notrack-4b.c: Likewise.
> * gcc.target/i386/cet-notrack-5a.c: Likewise.
> * gcc.target/i386/cet-notrack-5b.c: Likewise.
> * gcc.target/i386/cet-notrack-6a.c: Likewise.
> * gcc.target/i386/cet-notrack-6b.c: Likewise.
> * gcc.target/i386/cet-notrack-7.c: Likewise.
> * gcc.target/i386/cet-property-1.c: Likewise.
> * gcc.target/i386/cet-property-2.c: Likewise.
> * gcc.target/i386/cet-rdssp-1.c: Likewise.
> * gcc.target/i386/cet-sjlj-1.c: Likewise.
> * gcc.target/i386/cet-sjlj-2.c: Likewise.
> * gcc.target/i386/cet-sjlj-3.c: Likewise.
> * gcc.target/i386/cet-switch-1.c: Likewise.
> * gcc.target/i386/cet-switch-2.c: Likewise.
> * lib/target-supports.exp (check_effective_target_cet): New
> proc.

A couple of questions:

+/* { dg-do compile } */
+/* { dg-options "-O2 -mcet" } */
+/* { dg-final { scan-assembler-times "setssbsy" 2 } } */
+
+#include <immintrin.h>
+
+void f1 (void)
+{
+  __builtin_ia32_setssbsy ();
+}
+
+void f2 (void)
+{
+  _setssbsy ();
+}

Is there a reason that both, __builtin and intrinsic versions are
tested in a couple of places? The intrinsic version is just a wrapper
for __builtin, so IMO testing intrinsic version should be enough.


diff --git a/gcc/testsuite/gcc.target/i386/cet-rdssp-1.c
b/gcc/testsuite/gcc.target/i386/cet-rdssp-1.c
new file mode 100644
index 0000000..f9223a5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-rdssp-1.c
@@ -0,0 +1,39 @@
+/* { dg-do run { target cet } } */
+/* { dg-options "-O2 -finstrument-control-flow -mcet" } */

The "target cet" directive just checks that CET instructions can be
compiled. The test will (probably?) fail on targets with binutils that
can compile CET instructions, but the target itself doesn't support
CET. If this is the case, then check header has to be introduced, so
the test can be bypassed on targets without runtime support.

Uros.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-10-24 16:02 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-01  8:57 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Tsimbalist, Igor V
2017-08-25 22:46 ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Jeff Law
2017-09-15 15:36   ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Tsimbalist, Igor V
2017-09-18 10:17 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Uros Bizjak
2017-09-19 15:18 ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Tsimbalist, Igor V
2017-09-19 16:13   ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Uros Bizjak
2017-09-19 21:29     ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Tsimbalist, Igor V
2017-10-12 18:56       ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Tsimbalist, Igor V
2017-10-13  9:10         ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Uros Bizjak
2017-10-13 11:01           ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Tsimbalist, Igor V
2017-10-13 12:01             ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Uros Bizjak
2017-10-24 15:37               ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Rainer Orth
2017-10-24 16:04                 ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Uros Bizjak
2017-10-22 11:58             ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Andreas Schwab
2017-10-22 17:39               ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Tsimbalist, Igor V
2017-10-22 12:26             ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation H.J. Lu
2017-10-22 14:14               ` 0006-Part-6.-Add-x86-tests-for-Intel-CET-implementation Tsimbalist, Igor V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).