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]

[gimple-classes, committed 34/44] build_assign and build_type_cast take const gassign *


gcc/ChangeLog.gimple-classes:
	* asan.c (asan_expand_check_ifn): Strengthen local "shadow_test"
	from gimple to gassign *.  Introduce gassign * locals "add_7",
	"cast", "t_ge_shadow", "and_expr", using them in place of
	gimple_seq_last_stmt (seq) for typesafety.
	* gimple-builder.c (build_assign): Strengthen param "g" from
	gimple to const gassign * for all overloads.
	(build_type_cast): Likewise for param "op".
	* gimple-builder.h (build_assign): Strengthen param from gimple to
	const gassign * for all overloads.
	(build_type_cast): Strengthen param 2 from gimple to
	const gassign *.
---
 gcc/ChangeLog.gimple-classes | 14 ++++++++++++++
 gcc/asan.c                   | 44 ++++++++++++++++++++++++--------------------
 gcc/gimple-builder.c         | 11 ++++++-----
 gcc/gimple-builder.h         | 14 +++++++++-----
 4 files changed, 53 insertions(+), 30 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index d207213..631e0df 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,19 @@
 2014-11-04  David Malcolm  <dmalcolm@redhat.com>
 
+	* asan.c (asan_expand_check_ifn): Strengthen local "shadow_test"
+	from gimple to gassign *.  Introduce gassign * locals "add_7",
+	"cast", "t_ge_shadow", "and_expr", using them in place of
+	gimple_seq_last_stmt (seq) for typesafety.
+	* gimple-builder.c (build_assign): Strengthen param "g" from
+	gimple to const gassign * for all overloads.
+	(build_type_cast): Likewise for param "op".
+	* gimple-builder.h (build_assign): Strengthen param from gimple to
+	const gassign * for all overloads.
+	(build_type_cast): Strengthen param 2 from gimple to
+	const gassign *.
+
+2014-11-04  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_expr_type): Split out if clause handling
 	GIMPLE_ASSIGN and GIMPLE_CALL with an inner if GIMPLE_CALL
 	into a pair of if clauses, first for GIMPLE_CALL, then for
diff --git a/gcc/asan.c b/gcc/asan.c
index 9b25f56..6808c30 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -2633,7 +2633,7 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls)
 	     & ((base_addr & 7) + (real_size_in_bytes - 1)) >= shadow).  */
 	  tree shadow = build_shadow_mem_access (&gsi, loc, base_addr,
 						 shadow_ptr_type);
-	  gimple shadow_test = build_assign (NE_EXPR, shadow, 0);
+	  gassign *shadow_test = build_assign (NE_EXPR, shadow, 0);
 	  gimple_seq seq = NULL;
 	  gimple_seq_add_stmt (&seq, shadow_test);
 	  /* Aligned (>= 8 bytes) can test just
@@ -2641,23 +2641,24 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls)
 	     to be 0.  */
 	  if (align < 8)
 	    {
-	      gimple_seq_add_stmt (&seq, build_assign (BIT_AND_EXPR,
-						       base_addr, 7));
-	      gimple_seq_add_stmt (&seq,
-				   build_type_cast (shadow_type,
-						    gimple_seq_last (seq)));
+	      gassign *and_7 = build_assign (BIT_AND_EXPR,
+					     base_addr, 7);
+	      gimple_seq_add_stmt (&seq, and_7);
+	      gassign *cast = build_type_cast (shadow_type, and_7);
+	      gimple_seq_add_stmt (&seq, cast);
 	      if (real_size_in_bytes > 1)
 		gimple_seq_add_stmt (&seq,
 				     build_assign (PLUS_EXPR,
-						   gimple_seq_last (seq),
+						   cast,
 						   real_size_in_bytes - 1));
 	      t = gimple_assign_lhs (gimple_seq_last_stmt (seq));
 	    }
 	  else
 	    t = build_int_cst (shadow_type, real_size_in_bytes - 1);
-	  gimple_seq_add_stmt (&seq, build_assign (GE_EXPR, t, shadow));
+	  gassign *t_ge_shadow = build_assign (GE_EXPR, t, shadow);
+	  gimple_seq_add_stmt (&seq, t_ge_shadow);
 	  gimple_seq_add_stmt (&seq, build_assign (BIT_AND_EXPR, shadow_test,
-						   gimple_seq_last (seq)));
+						   t_ge_shadow));
 	  t = gimple_assign_lhs (gimple_seq_last (seq));
 	  gimple_seq_set_location (seq, loc);
 	  gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING);
@@ -2684,21 +2685,24 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls)
 
 	  tree shadow = build_shadow_mem_access (&gsi, loc, base_end_addr,
 						 shadow_ptr_type);
-	  gimple shadow_test = build_assign (NE_EXPR, shadow, 0);
+	  gassign *shadow_test = build_assign (NE_EXPR, shadow, 0);
 	  gimple_seq seq = NULL;
 	  gimple_seq_add_stmt (&seq, shadow_test);
-	  gimple_seq_add_stmt (&seq, build_assign (BIT_AND_EXPR,
-						   base_end_addr, 7));
-	  gimple_seq_add_stmt (&seq, build_type_cast (shadow_type,
-						      gimple_seq_last (seq)));
-	  gimple_seq_add_stmt (&seq, build_assign (GE_EXPR,
-						   gimple_seq_last (seq),
-						   shadow));
-	  gimple_seq_add_stmt (&seq, build_assign (BIT_AND_EXPR, shadow_test,
-						   gimple_seq_last (seq)));
+	  gassign *and_7 = build_assign (BIT_AND_EXPR,
+					 base_end_addr, 7);
+	  gimple_seq_add_stmt (&seq, and_7);
+	  gassign *cast = build_type_cast (shadow_type, and_7);
+	  gimple_seq_add_stmt (&seq, cast);
+	  gassign *cast_ge_shadow = build_assign (GE_EXPR,
+						  cast,
+						  shadow);
+	  gimple_seq_add_stmt (&seq, cast_ge_shadow);
+	  gassign *and_expr = build_assign (BIT_AND_EXPR, shadow_test,
+					    cast_ge_shadow);
+	  gimple_seq_add_stmt (&seq, and_expr);
 	  if (!start_instrumented)
 	    gimple_seq_add_stmt (&seq, build_assign (BIT_IOR_EXPR, t,
-						     gimple_seq_last (seq)));
+						     and_expr));
 	  t = gimple_assign_lhs (gimple_seq_last (seq));
 	  gimple_seq_set_location (seq, loc);
 	  gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING);
diff --git a/gcc/gimple-builder.c b/gcc/gimple-builder.c
index a7c6c4e..cab4e4b 100644
--- a/gcc/gimple-builder.c
+++ b/gcc/gimple-builder.c
@@ -70,7 +70,7 @@ build_assign (enum tree_code code, tree op1, int val, tree lhs)
 }
 
 gassign *
-build_assign (enum tree_code code, gimple g, int val, tree lhs )
+build_assign (enum tree_code code, const gassign *g, int val, tree lhs )
 {
   return build_assign (code, gimple_assign_lhs (g), val, lhs);
 }
@@ -93,19 +93,20 @@ build_assign (enum tree_code code, tree op1, tree op2, tree lhs)
 }
 
 gassign *
-build_assign (enum tree_code code, gimple op1, tree op2, tree lhs)
+build_assign (enum tree_code code, const gassign *op1, tree op2, tree lhs)
 {
   return build_assign (code, gimple_assign_lhs (op1), op2, lhs);
 }
 
 gassign *
-build_assign (enum tree_code code, tree op1, gimple op2, tree lhs)
+build_assign (enum tree_code code, tree op1, const gassign *op2, tree lhs)
 {
   return build_assign (code, op1, gimple_assign_lhs (op2), lhs);
 }
 
 gassign *
-build_assign (enum tree_code code, gimple op1, gimple op2, tree lhs)
+build_assign (enum tree_code code, const gassign *op1, const gassign *op2,
+	      tree lhs)
 {
   return build_assign (code, gimple_assign_lhs (op1), gimple_assign_lhs (op2),
                        lhs);
@@ -124,7 +125,7 @@ build_type_cast (tree to_type, tree op, tree lhs)
 }
 
 gassign *
-build_type_cast (tree to_type, gimple op, tree lhs)
+build_type_cast (tree to_type, const gassign *op, tree lhs)
 {
   return build_type_cast (to_type, gimple_assign_lhs (op), lhs);
 }
diff --git a/gcc/gimple-builder.h b/gcc/gimple-builder.h
index f8ec23a..68f931b 100644
--- a/gcc/gimple-builder.h
+++ b/gcc/gimple-builder.h
@@ -22,12 +22,16 @@ along with GCC; see the file COPYING3.  If not see
 #define GCC_GIMPLE_BUILDER_H
 
 gassign *build_assign (enum tree_code, tree, int, tree lhs = NULL_TREE);
-gassign *build_assign (enum tree_code, gimple, int, tree lhs = NULL_TREE);
+gassign *build_assign (enum tree_code, const gassign *, int,
+		       tree lhs = NULL_TREE);
 gassign *build_assign (enum tree_code, tree, tree, tree lhs = NULL_TREE);
-gassign *build_assign (enum tree_code, gimple, tree, tree lhs = NULL_TREE);
-gassign *build_assign (enum tree_code, tree, gimple, tree lhs = NULL_TREE);
-gassign *build_assign (enum tree_code, gimple, gimple, tree lhs = NULL_TREE);
+gassign *build_assign (enum tree_code, const gassign *, tree,
+		       tree lhs = NULL_TREE);
+gassign *build_assign (enum tree_code, tree, const gassign *,
+		       tree lhs = NULL_TREE);
+gassign *build_assign (enum tree_code, const gassign *, const gassign *,
+		       tree lhs = NULL_TREE);
 gassign *build_type_cast (tree, tree, tree lhs = NULL_TREE);
-gassign *build_type_cast (tree, gimple, tree lhs = NULL_TREE);
+gassign *build_type_cast (tree, const gassign *, tree lhs = NULL_TREE);
 
 #endif /* GCC_GIMPLE_BUILDER_H */
-- 
1.7.11.7


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