ra: Add debug functions for printing spill costs and benefits

These have been incredibly useful when debugging regressions and weird
behavior in the Intel backend when trying to spill multiple registers
before retrying allocation.  With them, we can print out not only what
register was chosen, but the benefit and cost.  Seeing lists of chosen
registers where the benefit/cost was not sorted, and poor options were
chosen before better ones, led me to investigate a number of issues.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28257>
This commit is contained in:
Kenneth Graunke 2023-09-09 03:25:44 -07:00 committed by Marge Bot
parent 84e8a295a0
commit 8573e9bf47
2 changed files with 14 additions and 0 deletions

View file

@ -1031,6 +1031,12 @@ ra_get_spill_benefit(struct ra_graph *g, unsigned int n)
return benefit;
}
float
ra_debug_get_spill_benefit(struct ra_graph *g, unsigned int n)
{
return ra_get_spill_benefit(g, n);
}
/**
* Returns a node number to be spilled according to the cost/benefit using
* the pq test, or -1 if there are no spillable nodes.
@ -1077,3 +1083,9 @@ ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost)
{
g->nodes[n].spill_cost = cost;
}
float
ra_debug_get_node_spill_cost(struct ra_graph *g, unsigned int n)
{
return g->nodes[n].spill_cost;
}

View file

@ -133,6 +133,8 @@ void ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost);
int ra_get_best_spill_node(struct ra_graph *g);
/** @} */
float ra_debug_get_node_spill_cost(struct ra_graph *g, unsigned int n);
float ra_debug_get_spill_benefit(struct ra_graph *g, unsigned int n);
#ifdef __cplusplus
} // extern "C"