Difference of idx for Calls with no order relation is stable,
but may lead to circular dependencies. Fixed by looking at
the heights first.
Fixes backend/transform_loop.c (with -O0)
[r28436]
{
ir_node *n1 = *(ir_node **) c1;
ir_node *n2 = *(ir_node **) c2;
{
ir_node *n1 = *(ir_node **) c1;
ir_node *n2 = *(ir_node **) c2;
/*
Classical qsort() comparison function behavior:
/*
Classical qsort() comparison function behavior:
return 1;
/* The nodes have no depth order, but we need a total order because qsort()
return 1;
/* The nodes have no depth order, but we need a total order because qsort()
+ * is not stable.
+ *
+ * Additionally, we need to respect transitive dependencies. Consider a
+ * Call a depending on Call b and an independent Call c.
+ * We MUST NOT order c > a and b > c. */
+ h1 = get_irn_height(ir_heights, n1);
+ h2 = get_irn_height(ir_heights, n2);
+ if (h1 < h2) return -1;
+ if (h1 > h2) return 1;
+ /* Same height, so use a random (but stable) order */
return get_irn_idx(n1) - get_irn_idx(n2);
}
return get_irn_idx(n1) - get_irn_idx(n2);
}