/* Miscellaneous SSA utility functions.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GCC.
value = degenerate_phi_result (def_stmt);
if (value && walk_tree (&value, find_released_ssa_name, NULL, NULL))
value = NULL;
+ /* error_mark_node is what fixup_noreturn_call changes PHI arguments
+ to. */
+ else if (value == error_mark_node)
+ value = NULL;
}
else if (is_gimple_assign (def_stmt))
{
continue;
if (value)
- FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
- /* unshare_expr is not needed here. vexpr is either a
- SINGLE_RHS, that can be safely shared, some other RHS
- that was unshared when we found it had a single debug
- use, or a DEBUG_EXPR_DECL, that can be safely
- shared. */
- SET_USE (use_p, value);
+ {
+ FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
+ /* unshare_expr is not needed here. vexpr is either a
+ SINGLE_RHS, that can be safely shared, some other RHS
+ that was unshared when we found it had a single debug
+ use, or a DEBUG_EXPR_DECL, that can be safely
+ shared. */
+ SET_USE (use_p, value);
+ /* If we didn't replace uses with a debug decl fold the
+ resulting expression. Otherwise we end up with invalid IL. */
+ if (TREE_CODE (value) != DEBUG_EXPR_DECL)
+ fold_stmt_inplace (stmt);
+ }
else
gimple_debug_bind_reset_value (stmt);
}
}
+/* Reset all debug stmts that use SSA_NAME(s) defined in STMT. */
+
+void
+reset_debug_uses (gimple stmt)
+{
+ ssa_op_iter op_iter;
+ def_operand_p def_p;
+ imm_use_iterator imm_iter;
+ gimple use_stmt;
+
+ if (!MAY_HAVE_DEBUG_STMTS)
+ return;
+
+ FOR_EACH_PHI_OR_STMT_DEF (def_p, stmt, op_iter, SSA_OP_DEF)
+ {
+ tree var = DEF_FROM_PTR (def_p);
+
+ if (TREE_CODE (var) != SSA_NAME)
+ continue;
+
+ FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, var)
+ {
+ if (!gimple_debug_bind_p (use_stmt))
+ continue;
+
+ gimple_debug_bind_reset_value (use_stmt);
+ update_stmt (use_stmt);
+ }
+ }
+}
+
/* Delete SSA DEFs for SSA versions in the TOREMOVE bitmap, removing
dominated stmts before their dominators, so that release_ssa_defs
stands a chance of propagating DEFs into debug bind stmts. */
gcc_assert (!need_ssa_update_p (cfun));
- verify_stmts ();
+ verify_gimple_in_cfg (cfun);
timevar_push (TV_TREE_SSA_VERIFY);
if (ssa_operands_active ())
fini_ssa_operands ();
- delete_alias_heapvars ();
-
htab_delete (cfun->gimple_df->default_defs);
cfun->gimple_df->default_defs = NULL;
pt_solution_reset (&cfun->gimple_df->escaped);
&& TYPE_RESTRICT (outer_type))
return false;
- /* If the outer type is (void *) or a pointer to an incomplete
- record type or a pointer to an unprototyped function,
- then the conversion is not necessary. */
- if (VOID_TYPE_P (TREE_TYPE (outer_type))
- || ((TREE_CODE (TREE_TYPE (outer_type)) == FUNCTION_TYPE
- || TREE_CODE (TREE_TYPE (outer_type)) == METHOD_TYPE)
- && (TREE_CODE (TREE_TYPE (outer_type))
- == TREE_CODE (TREE_TYPE (inner_type)))
- && !prototype_p (TREE_TYPE (outer_type))
- && useless_type_conversion_p (TREE_TYPE (TREE_TYPE (outer_type)),
- TREE_TYPE (TREE_TYPE (inner_type)))))
+ /* If the outer type is (void *), the conversion is not necessary. */
+ if (VOID_TYPE_P (TREE_TYPE (outer_type)))
return true;
}
|| TYPE_PRECISION (inner_type) != TYPE_PRECISION (outer_type))
return false;
+ /* Preserve conversions to BOOLEAN_TYPE if it is not of precision
+ one. */
+ if (TREE_CODE (inner_type) != BOOLEAN_TYPE
+ && TREE_CODE (outer_type) == BOOLEAN_TYPE
+ && TYPE_PRECISION (outer_type) != 1)
+ return false;
+
/* We don't need to preserve changes in the types minimum or
maximum value in general as these do not generate code
unless the types precisions are different. */
/* Do not lose casts to function pointer types. */
if ((TREE_CODE (TREE_TYPE (outer_type)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (outer_type)) == METHOD_TYPE)
- && !useless_type_conversion_p (TREE_TYPE (outer_type),
- TREE_TYPE (inner_type)))
+ && !(TREE_CODE (TREE_TYPE (inner_type)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (inner_type)) == METHOD_TYPE))
return false;
/* We do not care for const qualification of the pointed-to types
/* Defer to the target if necessary. */
if (TYPE_ATTRIBUTES (inner_type) || TYPE_ATTRIBUTES (outer_type))
- return targetm.comp_type_attributes (outer_type, inner_type) != 0;
+ return comp_type_attributes (outer_type, inner_type) != 0;
return true;
}
changed conditionally uninitialized to unconditionally uninitialized. */
/* Emit a warning for T, an SSA_NAME, being uninitialized. The exact
- warning text is in MSGID and LOCUS may contain a location or be null. */
+ warning text is in MSGID and LOCUS may contain a location or be null.
+ WC is the warning code. */
void
-warn_uninit (tree t, const char *gmsgid, void *data)
+warn_uninit (enum opt_code wc, tree t, const char *gmsgid, void *data)
{
tree var = SSA_NAME_VAR (t);
gimple context = (gimple) data;
: DECL_SOURCE_LOCATION (var);
xloc = expand_location (location);
floc = expand_location (DECL_SOURCE_LOCATION (cfun->decl));
- if (warning_at (location, OPT_Wuninitialized, gmsgid, var))
+ if (warning_at (location, wc, gmsgid, var))
{
TREE_NO_WARNING (var) = 1;
/* We only do data flow with SSA_NAMEs, so that's all we
can warn about. */
if (data->always_executed)
- warn_uninit (t, "%qD is used uninitialized in this function",
+ warn_uninit (OPT_Wuninitialized,
+ t, "%qD is used uninitialized in this function",
data->stmt);
else if (data->warn_possibly_uninitialized)
- warn_uninit (t, "%qD may be used uninitialized in this function",
+ warn_uninit (OPT_Wuninitialized,
+ t, "%qD may be used uninitialized in this function",
data->stmt);
*walk_subtrees = 0;
break;
TYPE_SIZE (TREE_TYPE (*tp)),
int_const_binop (MULT_EXPR,
bitsize_int (BITS_PER_UNIT),
- TREE_OPERAND (*tp, 1), 0));
+ TREE_OPERAND (*tp, 1)));
}
else if (TREE_CODE (TREE_TYPE (sym)) == COMPLEX_TYPE
&& useless_type_conversion_p (TREE_TYPE (*tp),
}
}
+ else if (gimple_debug_bind_p (stmt)
+ && gimple_debug_bind_has_value_p (stmt))
+ {
+ tree *valuep = gimple_debug_bind_get_value_ptr (stmt);
+ tree decl;
+ maybe_rewrite_mem_ref_base (valuep);
+ decl = non_rewritable_mem_ref_base (*valuep);
+ if (decl && symbol_marked_for_renaming (decl))
+ gimple_debug_bind_reset_value (stmt);
+ }
+
if (gimple_references_memory_p (stmt)
|| is_gimple_debug (stmt))
update_stmt (stmt);