From 3cb1f78bcf03446066f98807910eccfb7f5c22e3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 22 Apr 2021 06:42:44 -0700 Subject: compiler: bug: graph issue in dead code elimination. * share/txr/stdlib/optimize.tl (basic-blocks join-block): When we merge a block N with its physical predecessor P, we must iterate over the jump targets of N, and update their reverse list to point to P instead of N. A full call to link-graph would fix it also, but we don't call link-graph anywhere in the optimization pipeline after this point. The reverse links are relied on to be correct elsewhere, such merge-jump-tunks, which needs to walk the blocks which jump to a removed duplicate block, to retarget them to go to another copy of that block. --- share/txr/stdlib/optimize.tl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/txr/stdlib/optimize.tl b/share/txr/stdlib/optimize.tl index 83abaa1e..b011c568 100644 --- a/share/txr/stdlib/optimize.tl +++ b/share/txr/stdlib/optimize.tl @@ -107,7 +107,10 @@ (set bl.next nxbl.next) (set bl.links nxbl.links) (set bb.list (remq nxbl bb.list)) - (del [bb.hash nxbl.label])))) + (del [bb.hash nxbl.label]) + (each ((nx bl.links)) + (upd nx.rlinks (remq nxbl)) + (pushnew bl nx.rlinks))))) (defmacro rewrite-case (sym list . cases) ^(rewrite (lambda (,sym) -- cgit v1.2.3