This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, MPX, 2/X] Pointers Checker [9/25] Bound constants


Hi,

Here is a patch which adds support for bound constant to be used as DECL_INITIAL for constant static bounds generated by compiler.

Thanks,
Ilya
--

gcc/

2013-10-23  Ilya Enkovich  <ilya.enkovich@intel.com>

	* emit-rtl.c (immed_double_const): Support MODE_POINTER_BOUNDS.
	* explow.c (trunc_int_for_mode): Likewise.
	* varpool.c (ctor_for_folding): Do not fold constant
	bounds vars.


diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index b0fc846..5d13b69 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -538,7 +538,8 @@ immed_double_const (HOST_WIDE_INT i0, HOST_WIDE_INT i1, enum machine_mode mode)
 		  || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT
 		  /* We can get a 0 for an error mark.  */
 		  || GET_MODE_CLASS (mode) == MODE_VECTOR_INT
-		  || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT);
+		  || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT
+		  || GET_MODE_CLASS (mode) == MODE_POINTER_BOUNDS);
 
       if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
 	return gen_int_mode (i0, mode);
diff --git a/gcc/explow.c b/gcc/explow.c
index f278e29..095434f 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -52,7 +52,8 @@ trunc_int_for_mode (HOST_WIDE_INT c, enum machine_mode mode)
   int width = GET_MODE_PRECISION (mode);
 
   /* You want to truncate to a _what_?  */
-  gcc_assert (SCALAR_INT_MODE_P (mode));
+  gcc_assert (SCALAR_INT_MODE_P (mode)
+	      || POINTER_BOUNDS_MODE_P (mode));
 
   /* Canonicalize BImode to 0 and STORE_FLAG_VALUE.  */
   if (mode == BImode)
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 2eb1fc1..d9c08c1 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -254,6 +254,12 @@ ctor_for_folding (tree decl)
       && TREE_CODE (decl) != CONST_DECL)
     return error_mark_node;
 
+  /* Static constant bounds are created to be
+     used instead of constants and therefore
+     do not let folding it.  */
+  if (POINTER_BOUNDS_P (decl))
+    return error_mark_node;
+
   if (TREE_CODE (decl) == CONST_DECL
       || DECL_IN_CONSTANT_POOL (decl))
     return DECL_INITIAL (decl);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]