From 153cb9fc22c4a7742948b4e066204fed6ef91bf7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 23 Oct 2021 07:22:22 -0700 Subject: compiler: also clear .next before re-linking graph. * stdlib/optimize.tl (basic-blocks elim-dead-code): When clearing the links before recalculating the graph, also clear the next field of every block, because link-graph only sets this if necessary, assuming that the value is already nil. Thus by not resetting it, we risk leaving stale values in these .next fields. The code reachability calculation relies on next fields, so if they falsely point to dead blocks, those blocks could be falsely retained. --- stdlib/optimize.tl | 1 + 1 file changed, 1 insertion(+) (limited to 'stdlib/optimize.tl') diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 7f0fa396..bf5dfdaa 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -511,6 +511,7 @@ (defmeth basic-blocks elim-dead-code (bb) (each ((bl bb.list)) (set bl.links nil + bl.next nil bl.rlinks nil)) bb.(link-graph) (let* ((visited (hash :eq-based))) -- cgit v1.2.3