summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.target')
-rw-r--r--gcc/testsuite/gcc.target/i386/chkp-builtins-1.c9
-rw-r--r--gcc/testsuite/gcc.target/i386/chkp-builtins-2.c9
-rw-r--r--gcc/testsuite/gcc.target/i386/chkp-builtins-3.c9
-rw-r--r--gcc/testsuite/gcc.target/i386/chkp-builtins-4.c9
-rw-r--r--gcc/testsuite/gcc.target/i386/chkp-const-check-1.c11
-rw-r--r--gcc/testsuite/gcc.target/i386/chkp-const-check-2.c8
-rw-r--r--gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c17
-rw-r--r--gcc/testsuite/gcc.target/i386/chkp-remove-bndint-2.c17
9 files changed, 104 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c
new file mode 100644
index 00000000000..bcc1198b5b1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fdump-tree-chkp" } */
+/* { dg-final { scan-tree-dump-not "bnd_init_ptr_bounds" "chkp" } } */
+
+void *
+chkp_test (void *p)
+{
+ return __builtin___bnd_init_ptr_bounds (p);
+}
diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c
new file mode 100644
index 00000000000..1f4a244ee92
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fdump-tree-chkp" } */
+/* { dg-final { scan-tree-dump-not "bnd_copy_ptr_bounds" "chkp" } } */
+
+void *
+chkp_test (void *p, void *q)
+{
+ return __builtin___bnd_copy_ptr_bounds (p, q);
+}
diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c
new file mode 100644
index 00000000000..ea54ede3c57
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fdump-tree-chkp" } */
+/* { dg-final { scan-tree-dump-not "bnd_set_ptr_bounds" "chkp" } } */
+
+void *
+chkp_test (void *p)
+{
+ return __builtin___bnd_set_ptr_bounds (p, 10);
+}
diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c
new file mode 100644
index 00000000000..cee780b2371
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fdump-tree-chkp" } */
+/* { dg-final { scan-tree-dump-not "bnd_null_ptr_bounds" "chkp" } } */
+
+void *
+chkp_test (void *p)
+{
+ return __builtin___bnd_null_ptr_bounds (p);
+}
diff --git a/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c b/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c
new file mode 100644
index 00000000000..2cd5af1f626
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt" } */
+/* { dg-final { scan-tree-dump-not "bndcl" "chkpopt" } } */
+/* { dg-final { scan-tree-dump-not "bndcu" "chkpopt" } } */
+
+
+int test (int *p)
+{
+ p = (int *)__builtin___bnd_set_ptr_bounds (p, sizeof (int));
+ return *p;
+}
diff --git a/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c b/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c
new file mode 100644
index 00000000000..98497f958a1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -Wchkp" } */
+
+int test (int *p)
+{
+ p = (int *)__builtin___bnd_set_ptr_bounds (p, sizeof (int));
+ return *(p + 1); /* { dg-warning "memory access check always fail" "" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c b/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c
new file mode 100644
index 00000000000..bcecdd032c1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt-details" } */
+/* { dg-final { scan-tree-dump "Moving creation of \[^ \]+ down to its use" "chkpopt" } } */
+
+extern int arr[];
+
+int test (int i)
+{
+ int res;
+ if (i >= 0)
+ res = arr[i];
+ else
+ res = -i;
+ return res;
+}
diff --git a/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c b/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c
new file mode 100644
index 00000000000..db710041f87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-not "bndint" "optimized" } } */
+
+
+struct S
+{
+ int a;
+ int b;
+ int c;
+};
+
+int test (struct S *ps)
+{
+ int *pi = &ps->b;
+ return *pi;
+}
diff --git a/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-2.c b/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-2.c
new file mode 100644
index 00000000000..c97ac277893
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-2.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-optimized -Wchkp" } */
+/* { dg-final { scan-tree-dump-not "bndint" "optimized" } } */
+
+
+struct S
+{
+ int a;
+ int b;
+ int c;
+};
+
+int test (struct S *ps)
+{
+ int *pi = &ps->b;
+ return *(pi + 1); /* { dg-warning "memory access check always fail" "" } */
+}