From 904448c676063cba97e61f8205798e5ad234b7a7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 30 Sep 2021 07:59:27 -0700 Subject: compiler: fix up linkage and recalc liveness in one peephole case. * stdlib/optimize.tl (basic-blocks peephole-block): Rearrange the code a bit so we don't calculate the xbl, which potentially performs the cut-block, if there is no ybl. We set the bb.recalc flag since we may have cut a block into two and have redirected a jump, and also update the links for that reason. --- stdlib/optimize.tl | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 902ca89f..a2717425 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -414,16 +414,19 @@ (match-case jinsns ((@jlabel (end (t @reg)) . @jrest) - (let* ((xbl (if jrest - bb.(cut-block jbl jrest jinsns) - jbl.next)) - (ybl bl.next) + (let* ((ybl bl.next) + (xbl (if ybl + (if jrest + bb.(cut-block jbl jrest jinsns) + jbl.next))) (yinsns ybl.insns)) (cond - ((and xbl ybl) - (set ybl.insns ^(,ybl.label ,(car insns) ,*(cdr yinsns))) - (pushnew ybl bb.rescan) - ^((if (t ,reg) ,xbl.label))) + (xbl + (set ybl.insns ^(,ybl.label ,(car insns) ,*(cdr yinsns))) + (pushnew ybl bb.rescan) + (set bb.recalc t) + (set bb.links (list ybl xbl)) + ^((if (t ,reg) ,xbl.label))) (t insns)))) (@jelse insns)))) (@(require ((if @(as reg (d @dn)) @jlabel) . @nil) -- cgit v1.2.3