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 [7/25] Suppress BUILT_IN_CHKP_ARG_BND optimizations.


Hi,

Here is a patch which hadles the problem with optimization of BUILT_IN_CHKP_ARG_BND calls.  Pointer Bounds Checker expects that argument of this call is a default SSA_NAME of the PARM_DECL whose bounds we want to get.  The problem is in optimizations which may replace arg with it's copy or a known value.  This patch suppress such modifications.

Thanks,
Ilya
--

gcc/

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

	* tree-into-ssa.c: Include "target.h"
	(rewrite_update_stmt): Skip BUILT_IN_CHKP_ARG_BND calls.
	* tree-ssa-dom.c: Include "target.h"
	(cprop_into_stmt): Skip BUILT_IN_CHKP_ARG_BND calls.


diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 981e9f4..8d48f6d 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "diagnostic-core.h"
 #include "tree-into-ssa.h"
+#include "target.h"
 
 
 /* This file builds the SSA form for a function as described in:
@@ -1921,8 +1922,14 @@ rewrite_update_stmt (gimple stmt, gimple_stmt_iterator gsi)
     }
 
   /* Rewrite USES included in OLD_SSA_NAMES and USES whose underlying
-     symbol is marked for renaming.  */
-  if (rewrite_uses_p (stmt))
+     symbol is marked for renaming.
+     Skip calls to BUILT_IN_CHKP_ARG_BND whose arg should never be
+     renamed.  */
+  if (rewrite_uses_p (stmt)
+      && !(flag_check_pointer_bounds
+	   && (gimple_code (stmt) == GIMPLE_CALL)
+	   && gimple_call_fndecl (stmt)
+	   == targetm.builtin_chkp_function (BUILT_IN_CHKP_ARG_BND)))
     {
       if (is_gimple_debug (stmt))
 	{
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 211bfcf..445278a 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "tree-ssa-threadedge.h"
 #include "tree-ssa-dom.h"
+#include "target.h"
 
 /* This file implements optimizations on the dominator tree.  */
 
@@ -2266,6 +2267,16 @@ cprop_into_stmt (gimple stmt)
   use_operand_p op_p;
   ssa_op_iter iter;
 
+  /* Call used to obtain bounds of input arg by Pointer Bounds Checker
+     should not be optimized.  Argument of the call is a default
+     SSA_NAME of PARM_DECL.  It should never be replaced by value.  */
+  if (flag_check_pointer_bounds && gimple_code (stmt) == GIMPLE_CALL)
+    {
+      tree fndecl = gimple_call_fndecl (stmt);
+      if (fndecl == targetm.builtin_chkp_function (BUILT_IN_CHKP_ARG_BND))
+	return;
+    }
+
   FOR_EACH_SSA_USE_OPERAND (op_p, stmt, iter, SSA_OP_USE)
     cprop_operand (stmt, op_p);
 }


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