summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-04-22 06:42:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-04-22 06:42:44 -0700
commit43303f6ce29bf502644c27115b0d9b680142f989 (patch)
treeef2b782e30b06703415ef061d39c11923d97f280
parent2480aea51560801f436823c53dc408a7333f683b (diff)
downloadtxr-43303f6ce29bf502644c27115b0d9b680142f989.tar.gz
txr-43303f6ce29bf502644c27115b0d9b680142f989.tar.bz2
txr-43303f6ce29bf502644c27115b0d9b680142f989.zip
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.
-rw-r--r--share/txr/stdlib/optimize.tl5
1 files changed, 4 insertions, 1 deletions
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)