Commit 5da257fd authored by Andreas Zwinkau's avatar Andreas Zwinkau
Browse files

Fix beabi call sorting

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]
parent 95730716
......@@ -979,6 +979,7 @@ static int cmp_call_dependency(const void *c1, const void *c2)
{
ir_node *n1 = *(ir_node **) c1;
ir_node *n2 = *(ir_node **) c2;
unsigned h1, h2;
/*
Classical qsort() comparison function behavior:
......@@ -993,7 +994,16 @@ static int cmp_call_dependency(const void *c1, const void *c2)
return 1;
/* The nodes have no depth order, but we need a total order because qsort()
* is not stable. */
* 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);
}
......
Supports Markdown
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