summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2014-11-03 17:19:11 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2014-11-03 17:19:11 -0500
commit9361c12bf91406ca7d2888ef0f61ce957c19ece2 (patch)
tree252b7325724b86e707b98a4c0a7935ae122bef22
parent8285b4c9a87877973963ae3c450a7ffb4659c97d (diff)
downloadgcc-9361c12bf91406ca7d2888ef0f61ce957c19ece2.tar.gz
gimple-walk.c: Use gassign
gcc/ChangeLog.gimple-classes: * gimple-walk.c (walk_gimple_op): Within case GIMPLE_ASSIGN, introduce local gassign * "assign_stmt" and use it in place of "stmt" for typesafety.
-rw-r--r--gcc/ChangeLog.gimple-classes6
-rw-r--r--gcc/gimple-walk.c74
2 files changed, 45 insertions, 35 deletions
diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 9b455c30c59..8e18adcbf3d 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,11 @@
2014-11-03 David Malcolm <dmalcolm@redhat.com>
+ * gimple-walk.c (walk_gimple_op): Within case GIMPLE_ASSIGN,
+ introduce local gassign * "assign_stmt" and use it in place of
+ "stmt" for typesafety.
+
+2014-11-03 David Malcolm <dmalcolm@redhat.com>
+
* tree-ssa-dse.c (dse_optimize_stmt): Add checked cast. Replace
is_gimple_assign with dyn_cast, introducing local gassign *
"assign_stmt", using it in place of "stmt" for typesafety.
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 9a800e2c521..d74e66a3587 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -195,46 +195,50 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
switch (gimple_code (stmt))
{
case GIMPLE_ASSIGN:
- /* Walk the RHS operands. If the LHS is of a non-renamable type or
- is a register variable, we may use a COMPONENT_REF on the RHS. */
- if (wi)
- {
- tree lhs = gimple_assign_lhs (stmt);
- wi->val_only
- = (is_gimple_reg_type (TREE_TYPE (lhs)) && !is_gimple_reg (lhs))
- || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS;
- }
+ {
+ gassign *assign_stmt = as_a <gassign *> (stmt);
- for (i = 1; i < gimple_num_ops (stmt); i++)
- {
- ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi,
- pset);
- if (ret)
- return ret;
- }
+ /* Walk the RHS operands. If the LHS is of a non-renamable type or
+ is a register variable, we may use a COMPONENT_REF on the RHS. */
+ if (wi)
+ {
+ tree lhs = gimple_assign_lhs (assign_stmt);
+ wi->val_only
+ = (is_gimple_reg_type (TREE_TYPE (lhs)) && !is_gimple_reg (lhs))
+ || gimple_assign_rhs_class (assign_stmt) != GIMPLE_SINGLE_RHS;
+ }
- /* Walk the LHS. If the RHS is appropriate for a memory, we
- may use a COMPONENT_REF on the LHS. */
- if (wi)
- {
- /* If the RHS is of a non-renamable type or is a register variable,
- we may use a COMPONENT_REF on the LHS. */
- tree rhs1 = gimple_assign_rhs1 (stmt);
- wi->val_only
- = (is_gimple_reg_type (TREE_TYPE (rhs1)) && !is_gimple_reg (rhs1))
- || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS;
- wi->is_lhs = true;
+ for (i = 1; i < gimple_num_ops (assign_stmt); i++)
+ {
+ ret = walk_tree (gimple_op_ptr (assign_stmt, i), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ }
+
+ /* Walk the LHS. If the RHS is appropriate for a memory, we
+ may use a COMPONENT_REF on the LHS. */
+ if (wi)
+ {
+ /* If the RHS is of a non-renamable type or is a register variable,
+ we may use a COMPONENT_REF on the LHS. */
+ tree rhs1 = gimple_assign_rhs1 (assign_stmt);
+ wi->val_only
+ = (is_gimple_reg_type (TREE_TYPE (rhs1)) && !is_gimple_reg (rhs1))
+ || gimple_assign_rhs_class (assign_stmt) != GIMPLE_SINGLE_RHS;
+ wi->is_lhs = true;
}
- ret = walk_tree (gimple_op_ptr (stmt, 0), callback_op, wi, pset);
- if (ret)
- return ret;
+ ret = walk_tree (gimple_op_ptr (assign_stmt, 0), callback_op, wi, pset);
+ if (ret)
+ return ret;
- if (wi)
- {
- wi->val_only = true;
- wi->is_lhs = false;
- }
+ if (wi)
+ {
+ wi->val_only = true;
+ wi->is_lhs = false;
+ }
+ }
break;
case GIMPLE_CALL: