This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, PR middle-end/66134] Fix coalescing for bounds used in abnormal phi
- From: Ilya Enkovich <enkovich dot gnu at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 15 May 2015 12:43:29 +0300
- Subject: [PATCH, PR middle-end/66134] Fix coalescing for bounds used in abnormal phi
- Authentication-results: sourceware.org; auth=none
Hi,
This patch fixes misuse of abnormal bounds copy to avoid coalescing issue. Bootstrapped and regtested for x86_64-unknown-linux-gnu. Applied to trunk. Is it OK for gcc-5?
Thanks,
Ilya
--
gcc/
2015-05-15 Ilya Enkovich <enkovich.gnu@gmail.com>
PR middle-end/66134
* tree-chkp.c (chkp_get_orginal_bounds_for_abnormal_copy): New.
(chkp_maybe_copy_and_register_bounds): Don't copy abnormal copy.
gcc/testsuite/
2015-05-15 Ilya Enkovich <enkovich.gnu@gmail.com>
PR middle-end/66134
* gcc.target/i386/mpx/pr66134.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66134.c b/gcc/testsuite/gcc.target/i386/mpx/pr66134.c
new file mode 100755
index 0000000..3889674
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr66134.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx -fno-tree-ccp" } */
+
+extern int vfork (void) __attribute__ ((__nothrow__ , __leaf__));
+void test1 (void);
+void test2 (void);
+void test3 (int *);
+
+void test (int *p)
+{
+ test1 ();
+ p++;
+ test2 ();
+ p++;
+ vfork ();
+ test3 (p);
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 288470b..17a52bc 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -1097,7 +1097,20 @@ chkp_get_bounds_var (tree ptr_var)
return bnd_var;
}
+/* If BND is an abnormal bounds copy, return a copied value.
+ Otherwise return BND. */
+static tree
+chkp_get_orginal_bounds_for_abnormal_copy (tree bnd)
+{
+ if (bitmap_bit_p (chkp_abnormal_copies, SSA_NAME_VERSION (bnd)))
+ {
+ gimple bnd_def = SSA_NAME_DEF_STMT (bnd);
+ gcc_checking_assert (gimple_code (bnd_def) == GIMPLE_ASSIGN);
+ bnd = gimple_assign_rhs1 (bnd_def);
+ }
+ return bnd;
+}
/* Register bounds BND for object PTR in global bounds table.
A copy of bounds may be created for abnormal ssa names.
@@ -1141,11 +1154,7 @@ chkp_maybe_copy_and_register_bounds (tree ptr, tree bnd)
/* For abnormal copies we may just find original
bounds and use them. */
if (!abnormal_ptr && !SSA_NAME_IS_DEFAULT_DEF (bnd))
- {
- gimple bnd_def = SSA_NAME_DEF_STMT (bnd);
- gcc_checking_assert (gimple_code (bnd_def) == GIMPLE_ASSIGN);
- bnd = gimple_assign_rhs1 (bnd_def);
- }
+ bnd = chkp_get_orginal_bounds_for_abnormal_copy (bnd);
/* For undefined values we usually use none bounds
value but in case of abnormal edge it may cause
coalescing failures. Use default definition of
@@ -1177,6 +1186,7 @@ chkp_maybe_copy_and_register_bounds (tree ptr, tree bnd)
copy = make_temp_ssa_name (pointer_bounds_type_node,
gimple_build_nop (),
CHKP_BOUND_TMP_NAME);
+ bnd = chkp_get_orginal_bounds_for_abnormal_copy (bnd);
assign = gimple_build_assign (copy, bnd);
if (dump_file && (dump_flags & TDF_DETAILS))