From e72f960431aa61185c40cf38a471b6d8b0924a58 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 9 Jun 2022 11:11:36 -0700 Subject: optimizer: fix live set being unexpectedly nil. The following test case throws an exception: (compile-toplevel '(when-match @(or @b @c) nil nil)) the reason is that in the optimizer, the local-liveness method resets the bl.live set of live registers to nil. The expectation is that it will be recalculated. However, what happens is that * stdlib/optimize.tl (basic-block): Initialize live slot to zero. (basic-blocks local-liveness): Reset bl.live to 0, rather than nil. The problem is that sometimes the block in question is not reached in the graph traversal (down in the same function) which is supposed to assign it a live value. This happens in the above test case, and it's not due to any bug: the block is not reached by the forward traversal because the block has become unreachable. --- stdlib/optimize.tl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stdlib') diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 00bf1cc4..8e1e8182 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -32,7 +32,7 @@ def) (defstruct basic-block (live-info) - live + (live 0) label next links @@ -155,7 +155,7 @@ (pushnew bl nx.rlinks))))) (defmeth basic-blocks local-liveness (bb bl) - (set bl.live nil) + (set bl.live 0) (labels ((regnum (reg) (when-match (t @num) reg num)) (regnums (regs) -- cgit v1.2.3