From 0f3c32ef3435203bb30ca1b080b9eeecaf1cd84d Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 23 Jan 2017 23:34:55 +0100 Subject: [PATCH] Better hop rendering. --- mach/proto/mcg/hop.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mach/proto/mcg/hop.c b/mach/proto/mcg/hop.c index b2e0b26c4..d36fa6fc8 100644 --- a/mach/proto/mcg/hop.c +++ b/mach/proto/mcg/hop.c @@ -245,8 +245,11 @@ static char* appendf(const char* fmt, ...) static struct vreg* actual(struct vreg* vreg) { - while (vreg->coalesced_with) - vreg = vreg->coalesced_with; + if (vreg) + { + while (vreg->coalesced_with) + vreg = vreg->coalesced_with; + } return vreg; } @@ -336,12 +339,17 @@ char* hop_render(struct hop* hop) while (hashtable_next(hop->valueusage, &hit)) { struct valueusage* usage = hit.value; + struct vreg* invreg = actual(usage->invreg); + struct vreg* outvreg = actual(usage->outvreg); + if (usage->input && usage->output && (invreg == outvreg)) + continue; + appendf(" "); - if (usage->input && usage->invreg) - appendvreg(actual(usage->invreg)); + if (usage->input && invreg) + appendvreg(invreg); appendf("->"); - if (usage->output && usage->outvreg) - appendvreg(actual(usage->outvreg)); + if (usage->output && outvreg) + appendvreg(outvreg); } appendf("\n"); return buffer; -- 2.34.1