Commit 949cfd0a by Andi Kleen Committed by Andi Kleen

Improve dump files for SRA early candidate check v2

v2: Include message improvements from Eric Botcazou

gcc/:
2011-06-24  Andi Kleen  <ak@linux.intel.com>

	* tree-sra.c (type_internals_preclude_sra_p): Add msg
	parameter. Split up ifs and report reason in *msg.
	(reject): Add.
	(find_var_candiate): Add msg variable.
	Split up ifs and report reason to reject.
	(find_param_candidates): Add msg variable.
	Pass msg to type_internals_preclude_sra_p.

From-SVN: r175370
parent 908e152c
2011-06-24 Andi Kleen <ak@linux.intel.com>
* tree-sra.c (type_internals_preclude_sra_p): Add msg
parameter. Split up ifs and report reason in *msg.
(reject): Add.
(find_var_candiate): Add msg variable.
Split up ifs and report reason to reject.
(find_param_candidates): Add msg variable.
Pass msg to type_internals_preclude_sra_p.
2011-06-23 Jeff Law <law@redhat.com> 2011-06-23 Jeff Law <law@redhat.com>
PR middle-end/48770 PR middle-end/48770
......
...@@ -648,7 +648,7 @@ disqualify_candidate (tree decl, const char *reason) ...@@ -648,7 +648,7 @@ disqualify_candidate (tree decl, const char *reason)
scalarization. */ scalarization. */
static bool static bool
type_internals_preclude_sra_p (tree type) type_internals_preclude_sra_p (tree type, const char **msg)
{ {
tree fld; tree fld;
tree et; tree et;
...@@ -663,15 +663,39 @@ type_internals_preclude_sra_p (tree type) ...@@ -663,15 +663,39 @@ type_internals_preclude_sra_p (tree type)
{ {
tree ft = TREE_TYPE (fld); tree ft = TREE_TYPE (fld);
if (TREE_THIS_VOLATILE (fld) if (TREE_THIS_VOLATILE (fld))
|| !DECL_FIELD_OFFSET (fld) || !DECL_SIZE (fld) {
|| !host_integerp (DECL_FIELD_OFFSET (fld), 1) *msg = "volatile structure field";
|| !host_integerp (DECL_SIZE (fld), 1) return true;
|| (AGGREGATE_TYPE_P (ft) }
&& int_bit_position (fld) % BITS_PER_UNIT != 0)) if (!DECL_FIELD_OFFSET (fld))
return true; {
*msg = "no structure field offset";
return true;
}
if (!DECL_SIZE (fld))
{
*msg = "zero structure field size";
return true;
}
if (!host_integerp (DECL_FIELD_OFFSET (fld), 1))
{
*msg = "structure field offset not fixed";
return true;
}
if (!host_integerp (DECL_SIZE (fld), 1))
{
*msg = "structure field size not fixed";
return true;
}
if (AGGREGATE_TYPE_P (ft)
&& int_bit_position (fld) % BITS_PER_UNIT != 0)
{
*msg = "structure field is bit field";
return true;
}
if (AGGREGATE_TYPE_P (ft) && type_internals_preclude_sra_p (ft)) if (AGGREGATE_TYPE_P (ft) && type_internals_preclude_sra_p (ft, msg))
return true; return true;
} }
...@@ -681,9 +705,12 @@ type_internals_preclude_sra_p (tree type) ...@@ -681,9 +705,12 @@ type_internals_preclude_sra_p (tree type)
et = TREE_TYPE (type); et = TREE_TYPE (type);
if (TYPE_VOLATILE (et)) if (TYPE_VOLATILE (et))
return true; {
*msg = "element type is volatile";
return true;
}
if (AGGREGATE_TYPE_P (et) && type_internals_preclude_sra_p (et)) if (AGGREGATE_TYPE_P (et) && type_internals_preclude_sra_p (et, msg))
return true; return true;
return false; return false;
...@@ -1538,6 +1565,19 @@ is_va_list_type (tree type) ...@@ -1538,6 +1565,19 @@ is_va_list_type (tree type)
return TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (va_list_type_node); return TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (va_list_type_node);
} }
/* Print message to dump file why a variable was rejected. */
static void
reject (tree var, const char *msg)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Rejected (%d): %s: ", DECL_UID (var), msg);
print_generic_expr (dump_file, var, 0);
fprintf (dump_file, "\n");
}
}
/* The very first phase of intraprocedural SRA. It marks in candidate_bitmap /* The very first phase of intraprocedural SRA. It marks in candidate_bitmap
those with type which is suitable for scalarization. */ those with type which is suitable for scalarization. */
...@@ -1547,6 +1587,7 @@ find_var_candidates (void) ...@@ -1547,6 +1587,7 @@ find_var_candidates (void)
tree var, type; tree var, type;
referenced_var_iterator rvi; referenced_var_iterator rvi;
bool ret = false; bool ret = false;
const char *msg;
FOR_EACH_REFERENCED_VAR (cfun, var, rvi) FOR_EACH_REFERENCED_VAR (cfun, var, rvi)
{ {
...@@ -1554,19 +1595,50 @@ find_var_candidates (void) ...@@ -1554,19 +1595,50 @@ find_var_candidates (void)
continue; continue;
type = TREE_TYPE (var); type = TREE_TYPE (var);
if (!AGGREGATE_TYPE_P (type) if (!AGGREGATE_TYPE_P (type))
|| needs_to_live_in_memory (var) {
|| TREE_THIS_VOLATILE (var) reject (var, "not aggregate");
|| !COMPLETE_TYPE_P (type) continue;
|| !host_integerp (TYPE_SIZE (type), 1) }
|| tree_low_cst (TYPE_SIZE (type), 1) == 0 if (needs_to_live_in_memory (var))
|| type_internals_preclude_sra_p (type) {
/* Fix for PR 41089. tree-stdarg.c needs to have va_lists intact but reject (var, "needs to live in memory");
continue;
}
if (TREE_THIS_VOLATILE (var))
{
reject (var, "is volatile");
continue;
}
if (!COMPLETE_TYPE_P (type))
{
reject (var, "has incomplete type");
continue;
}
if (!host_integerp (TYPE_SIZE (type), 1))
{
reject (var, "type size not fixed");
continue;
}
if (tree_low_cst (TYPE_SIZE (type), 1) == 0)
{
reject (var, "type size is zero");
continue;
}
if (type_internals_preclude_sra_p (type, &msg))
{
reject (var, msg);
continue;
}
if (/* Fix for PR 41089. tree-stdarg.c needs to have va_lists intact but
we also want to schedule it rather late. Thus we ignore it in we also want to schedule it rather late. Thus we ignore it in
the early pass. */ the early pass. */
|| (sra_mode == SRA_MODE_EARLY_INTRA (sra_mode == SRA_MODE_EARLY_INTRA
&& is_va_list_type (type))) && is_va_list_type (type)))
continue; {
reject (var, "is va_list");
continue;
}
bitmap_set_bit (candidate_bitmap, DECL_UID (var)); bitmap_set_bit (candidate_bitmap, DECL_UID (var));
...@@ -3228,6 +3300,7 @@ find_param_candidates (void) ...@@ -3228,6 +3300,7 @@ find_param_candidates (void)
tree parm; tree parm;
int count = 0; int count = 0;
bool ret = false; bool ret = false;
const char *msg;
for (parm = DECL_ARGUMENTS (current_function_decl); for (parm = DECL_ARGUMENTS (current_function_decl);
parm; parm;
...@@ -3268,7 +3341,7 @@ find_param_candidates (void) ...@@ -3268,7 +3341,7 @@ find_param_candidates (void)
|| !host_integerp (TYPE_SIZE (type), 1) || !host_integerp (TYPE_SIZE (type), 1)
|| tree_low_cst (TYPE_SIZE (type), 1) == 0 || tree_low_cst (TYPE_SIZE (type), 1) == 0
|| (AGGREGATE_TYPE_P (type) || (AGGREGATE_TYPE_P (type)
&& type_internals_preclude_sra_p (type))) && type_internals_preclude_sra_p (type, &msg)))
continue; continue;
bitmap_set_bit (candidate_bitmap, DECL_UID (parm)); bitmap_set_bit (candidate_bitmap, DECL_UID (parm));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment