}
/* A trivial destructor should still clobber the object. */
- tree clobber = build_clobber (TREE_TYPE (instance));
+ tree clobber = build_clobber (TREE_TYPE (instance), CLOBBER_OBJECT_END);
return build2 (MODIFY_EXPR, void_type_node,
instance, clobber);
}
storage is dead when we enter the constructor or leave the destructor. */
static tree
-build_clobber_this ()
+build_clobber_this (clobber_kind kind)
{
/* Clobbering an empty base is pointless, and harmful if its one byte
TYPE_SIZE overlays real data. */
if (!vbases)
ctype = CLASSTYPE_AS_BASE (ctype);
- tree clobber = build_clobber (ctype);
+ tree clobber = build_clobber (ctype, kind);
tree thisref = current_class_ref;
if (ctype != current_class_type)
because part of the initialization might happen before we enter the
constructor, via AGGR_INIT_ZERO_FIRST (c++/68006). */
&& !implicit_default_ctor_p (decl1))
- finish_expr_stmt (build_clobber_this ());
+ finish_expr_stmt (build_clobber_this (CLOBBER_OBJECT_BEGIN));
if (!processing_template_decl
&& DECL_CONSTRUCTOR_P (decl1)
finish_decl_cleanup (NULL_TREE, stmt);
}
else
- finish_decl_cleanup (NULL_TREE, build_clobber_this ());
+ finish_decl_cleanup (NULL_TREE,
+ build_clobber_this (CLOBBER_OBJECT_END));
}
/* And insert cleanups for our bases and members so that they
&& m_after_stmt
&& bitmap_bit_p (m_single_use_names, SSA_NAME_VERSION (op)))
{
- tree clobber = build_clobber (TREE_TYPE (m_vars[p]), CLOBBER_EOL);
+ tree clobber = build_clobber (TREE_TYPE (m_vars[p]),
+ CLOBBER_STORAGE_END);
g = gimple_build_assign (m_vars[p], clobber);
gimple_stmt_iterator gsi = gsi_for_stmt (m_after_stmt);
gsi_insert_after (&gsi, g, GSI_SAME_STMT);
tree ret = build_fold_addr_expr (var);
if (!stmt_ends_bb_p (gsi_stmt (m_gsi)))
{
- tree clobber = build_clobber (atype, CLOBBER_EOL);
+ tree clobber = build_clobber (atype, CLOBBER_STORAGE_END);
g = gimple_build_assign (var, clobber);
gsi_insert_after (&m_gsi, g, GSI_SAME_STMT);
}
ret = build_fold_addr_expr (var);
if (!stmt_ends_bb_p (gsi_stmt (m_gsi)))
{
- tree clobber = build_clobber (m_limb_type, CLOBBER_EOL);
+ tree clobber = build_clobber (m_limb_type,
+ CLOBBER_STORAGE_END);
g = gimple_build_assign (var, clobber);
gsi_insert_after (&m_gsi, g, GSI_SAME_STMT);
}
}
if (var)
{
- tree clobber = build_clobber (TREE_TYPE (var), CLOBBER_EOL);
+ tree clobber = build_clobber (TREE_TYPE (var), CLOBBER_STORAGE_END);
g = gimple_build_assign (var, clobber);
gsi_insert_after (&m_gsi, g, GSI_SAME_STMT);
}
pass_waccess::check_stmt (gimple *stmt)
{
if (m_check_dangling_p
- && gimple_clobber_p (stmt, CLOBBER_EOL))
+ && gimple_clobber_p (stmt, CLOBBER_STORAGE_END))
{
/* Ignore clobber statements in blocks with exceptional edges. */
basic_block bb = gimple_bb (stmt);
tmp = build_call_expr_loc (EXPR_LOCATION (*e), tmp, 2, v,
build_zero_cst (ptr_type_node));
tsi_link_after (&e, tmp, TSI_SAME_STMT);
- tmp = build_clobber (TREE_TYPE (v), CLOBBER_EOL);
+ tmp = build_clobber (TREE_TYPE (v), CLOBBER_STORAGE_END);
tmp = fold_build2_loc (loc, MODIFY_EXPR, TREE_TYPE (v), v,
fold_convert (TREE_TYPE (v), tmp));
++e;
build_zero_cst (ptr_type_node));
gimplify_and_add (tmp, &cleanup);
gimple *clobber_stmt;
- tmp = build_clobber (TREE_TYPE (v), CLOBBER_EOL);
+ tmp = build_clobber (TREE_TYPE (v), CLOBBER_STORAGE_END);
clobber_stmt = gimple_build_assign (v, tmp);
gimple_set_location (clobber_stmt, end_locus);
gimplify_seq_add_stmt (&cleanup, clobber_stmt);
&& !is_gimple_reg (t)
&& flag_stack_reuse != SR_NONE)
{
- tree clobber = build_clobber (TREE_TYPE (t), CLOBBER_EOL);
+ tree clobber = build_clobber (TREE_TYPE (t), CLOBBER_STORAGE_END);
gimple *clobber_stmt;
clobber_stmt = gimple_build_assign (t, clobber);
gimple_set_location (clobber_stmt, end_locus);
{
if (flag_stack_reuse == SR_ALL)
{
- tree clobber = build_clobber (TREE_TYPE (temp), CLOBBER_EOL);
+ tree clobber = build_clobber (TREE_TYPE (temp),
+ CLOBBER_STORAGE_END);
clobber = build2 (MODIFY_EXPR, TREE_TYPE (temp), temp, clobber);
gimple_push_cleanup (temp, clobber, false, pre_p, true);
}
{ dg-final { scan-tree-dump-times "b = \"a\\\\x00bc\";" 1 "gimple" } }
{ dg-final { scan-tree-dump-times "c = \"\";" 1 "gimple" } }
{ dg-final { scan-tree-dump-times "d = " 1 "gimple" } }
- { dg-final { scan-tree-dump-times "d = {CLOBBER\\(eol\\)}" 1 "gimple" } }
+ { dg-final { scan-tree-dump-times "d = {CLOBBER\\(eos\\)}" 1 "gimple" } }
{ dg-final { scan-tree-dump-times "e = " 1 "gimple" } }
- { dg-final { scan-tree-dump-times "e = {CLOBBER\\(eol\\)}" 1 "gimple" } } */
+ { dg-final { scan-tree-dump-times "e = {CLOBBER\\(eos\\)}" 1 "gimple" } } */
annot_expr_kind_last
};
-/* The kind of a TREE_CLOBBER_P CONSTRUCTOR node. */
+/* The kind of a TREE_CLOBBER_P CONSTRUCTOR node. Other than _UNDEF, these are
+ in roughly sequential order. */
enum clobber_kind {
/* Unspecified, this clobber acts as a store of an undefined value. */
CLOBBER_UNDEF,
- /* This clobber ends the lifetime of the storage. */
- CLOBBER_EOL,
+ /* Beginning of storage duration, e.g. malloc. */
+ CLOBBER_STORAGE_BEGIN,
+ /* Beginning of object lifetime, e.g. C++ constructor. */
+ CLOBBER_OBJECT_BEGIN,
+ /* End of object lifetime, e.g. C++ destructor. */
+ CLOBBER_OBJECT_END,
+ /* End of storage duration, e.g. free. */
+ CLOBBER_STORAGE_END,
CLOBBER_LAST
};
&& !is_gimple_reg (*varp)
&& !(id->debug_map && id->debug_map->get (p)))
{
- tree clobber = build_clobber (TREE_TYPE (*varp), CLOBBER_EOL);
+ tree clobber = build_clobber (TREE_TYPE (*varp),
+ CLOBBER_STORAGE_END);
gimple *clobber_stmt;
clobber_stmt = gimple_build_assign (*varp, clobber);
gimple_set_location (clobber_stmt, gimple_location (stmt));
&& !is_gimple_reg (id->retvar)
&& !stmt_ends_bb_p (stmt))
{
- tree clobber = build_clobber (TREE_TYPE (id->retvar), CLOBBER_EOL);
+ tree clobber = build_clobber (TREE_TYPE (id->retvar),
+ CLOBBER_STORAGE_END);
gimple *clobber_stmt;
clobber_stmt = gimple_build_assign (id->retvar, clobber);
gimple_set_location (clobber_stmt, gimple_location (old_stmt));
if (TREE_CLOBBER_P (node))
{
pp_string (pp, "CLOBBER");
- if (CLOBBER_KIND (node) == CLOBBER_EOL)
- pp_string (pp, "(eol)");
+ switch (CLOBBER_KIND (node))
+ {
+ case CLOBBER_STORAGE_BEGIN:
+ pp_string (pp, "(bos)");
+ break;
+ case CLOBBER_STORAGE_END:
+ pp_string (pp, "(eos)");
+ break;
+ case CLOBBER_OBJECT_BEGIN:
+ pp_string (pp, "(bob)");
+ break;
+ case CLOBBER_OBJECT_END:
+ pp_string (pp, "(eob)");
+ break;
+ default:
+ break;
+ }
}
else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
FOR_EACH_IMM_USE_STMT (stmt, iter, saved_val)
if (gimple_call_builtin_p (stmt, BUILT_IN_STACK_RESTORE))
{
- clobber = build_clobber (TREE_TYPE (var), CLOBBER_EOL);
+ clobber = build_clobber (TREE_TYPE (var), CLOBBER_STORAGE_END);
clobber_stmt = gimple_build_assign (var, clobber);
i = gsi_for_stmt (stmt);