Add debug_vn_reference_ops helper

This factors out a helper to dump VN reference operands, sth that
proves useful in debugging VN issues.

2021-04-07  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.h (print_vn_reference_ops): Declare.
	* tree-ssa-pre.c (print_pre_expr): Factor out VN reference operand
	printing...
	* tree-ssa-sccvn.c (print_vn_reference_ops): ... into this new
	function.
	(debug_vn_reference_ops): New.
This commit is contained in:
Richard Biener 2021-04-07 09:09:09 +02:00
parent e0bdccac58
commit 6eaf7ac6f4
3 changed files with 51 additions and 38 deletions

View File

@ -1067,45 +1067,8 @@ print_pre_expr (FILE *outfile, const pre_expr expr)
case REFERENCE:
{
vn_reference_op_t vro;
unsigned int i;
vn_reference_t ref = PRE_EXPR_REFERENCE (expr);
fprintf (outfile, "{");
for (i = 0;
ref->operands.iterate (i, &vro);
i++)
{
bool closebrace = false;
if (vro->opcode != SSA_NAME
&& TREE_CODE_CLASS (vro->opcode) != tcc_declaration)
{
fprintf (outfile, "%s", get_tree_code_name (vro->opcode));
if (vro->op0)
{
fprintf (outfile, "<");
closebrace = true;
}
}
if (vro->op0)
{
print_generic_expr (outfile, vro->op0);
if (vro->op1)
{
fprintf (outfile, ",");
print_generic_expr (outfile, vro->op1);
}
if (vro->op2)
{
fprintf (outfile, ",");
print_generic_expr (outfile, vro->op2);
}
}
if (closebrace)
fprintf (outfile, ">");
if (i != ref->operands.length () - 1)
fprintf (outfile, ",");
}
fprintf (outfile, "}");
print_vn_reference_ops (outfile, ref->operands);
if (ref->vuse)
{
fprintf (outfile, "@");

View File

@ -249,6 +249,55 @@ vn_reference_hasher::equal (const vn_reference_s *v, const vn_reference_s *c)
typedef hash_table<vn_reference_hasher> vn_reference_table_type;
typedef vn_reference_table_type::iterator vn_reference_iterator_type;
/* Pretty-print OPS to OUTFILE. */
void
print_vn_reference_ops (FILE *outfile, const vec<vn_reference_op_s> ops)
{
vn_reference_op_t vro;
unsigned int i;
fprintf (outfile, "{");
for (i = 0; ops.iterate (i, &vro); i++)
{
bool closebrace = false;
if (vro->opcode != SSA_NAME
&& TREE_CODE_CLASS (vro->opcode) != tcc_declaration)
{
fprintf (outfile, "%s", get_tree_code_name (vro->opcode));
if (vro->op0)
{
fprintf (outfile, "<");
closebrace = true;
}
}
if (vro->op0)
{
print_generic_expr (outfile, vro->op0);
if (vro->op1)
{
fprintf (outfile, ",");
print_generic_expr (outfile, vro->op1);
}
if (vro->op2)
{
fprintf (outfile, ",");
print_generic_expr (outfile, vro->op2);
}
}
if (closebrace)
fprintf (outfile, ">");
if (i != ops.length () - 1)
fprintf (outfile, ",");
}
fprintf (outfile, "}");
}
DEBUG_FUNCTION void
debug_vn_reference_ops (const vec<vn_reference_op_s> ops)
{
print_vn_reference_ops (stderr, ops);
fputc ('\n', stderr);
}
/* The set of VN hashtables. */

View File

@ -265,6 +265,7 @@ void vn_reference_lookup_call (gcall *, vn_reference_t *, vn_reference_t);
vn_reference_t vn_reference_insert_pieces (tree, alias_set_type, alias_set_type,
tree, vec<vn_reference_op_s>,
tree, unsigned int);
void print_vn_reference_ops (FILE *, const vec<vn_reference_op_s>);
bool vn_nary_op_eq (const_vn_nary_op_t const vno1,
const_vn_nary_op_t const vno2);