summary refs log tree commit diff
path: root/cfg.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2017-08-17 04:47:10 -0400
committerQuentin Carbonneaux <quentin@c9x.me>2017-08-17 04:50:22 -0400
commitae80e4f7caa6be31f83ae6a94a26ab3b60a5b064 (patch)
tree46a064f691ca3aa20f4273facc164a3db91b64dd /cfg.c
parent2b64b75c845d0491c7a701e44485d2856eeb686d (diff)
downloadroux-ae80e4f7caa6be31f83ae6a94a26ab3b60a5b064.tar.gz
fix bug in jumps simplification
In presence of jump loops, the algorithm would
create cycles in the disjoint-set data structure.
This caused infinite recursion and stack overflows.
Diffstat (limited to 'cfg.c')
-rw-r--r--cfg.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/cfg.c b/cfg.c
index ea1ae12..b1c80c7 100644
--- a/cfg.c
+++ b/cfg.c
@@ -304,8 +304,11 @@ simpljmp(Fn *fn)
 	for (b=fn->start; b; b=b->link) {
 		assert(!b->phi);
 		if (b->nins == 0)
-		if (b->jmp.type == Jjmp)
-			uf[b->id] = b->s1;
+		if (b->jmp.type == Jjmp) {
+			uffind(&b->s1, uf);
+			if (b->s1 != b)
+				uf[b->id] = b->s1;
+		}
 	}
 	for (b=fn->start; b; b=b->link) {
 		if (b->s1)