From 8187f1a3a27671d4d5b705901fa3fe30ed03cc5f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 9 Jun 2022 07:47:47 -0700 Subject: optimizer: remove root slot from basic-block. The root slot is just supposed to be (car bl.list): the first basic block. Unfortunately, it's not maintained when bl.list is edited, which could cause bugs. This change makes no difference in the stdlib compiled files, other than of course the changes in optimize.tlo from this code change itself; so that is evidence suggesting this change is least not making anything worse. * stdlib/optimize.tl (basic-blocks): Remove root slot. (basic-blocks (link-graph, calc-liveness, elim-dead-code): Refer to (car bl.list) instead of bl.root. --- stdlib/optimize.tl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 5a59a531..00bf1cc4 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -53,7 +53,6 @@ insns lt-dregs symvec - root (hash (hash)) (li-hash (hash :eq-based)) list @@ -120,7 +119,6 @@ ,list)) (defmeth basic-blocks link-graph (bb) - (set bb.root (car bb.list)) (each* ((bl bb.list) (nxbl (append (cdr bl) '(nil)))) (let* ((code bl.insns) @@ -275,7 +273,7 @@ (set-mask bl.used live-in)) (set changed t)))))) (set changed nil) - (visit bb.root)))))) + (visit (car bb.list))))))) (defmeth basic-blocks thread-jumps-block (bb code) (let* ((tail (last code)) @@ -549,9 +547,8 @@ (when bl.next (visit bl.next)) [mapcar visit bl.links]))) - (for ((bl bb.root)) (bl) ((set bl bl.next)) - (visit bl)) - (visit bb.root)) + (for ((bl (car bb.list))) (bl) ((set bl bl.next)) + (visit bl))) (upd bb.list (keep-if visited)) (let (flg) (each ((bl bb.list) -- cgit v1.2.3