From 0e6592ef4d6ec26d34ad468971a022a98d3d9bb2 Mon Sep 17 00:00:00 2001 From: Paul Khuong Date: Fri, 24 May 2013 13:08:55 -0400 Subject: [PATCH] Robustify specialised IF/IF conversion introduced in 729ce57 * When unlinking a node from its destination LVAR, always mark the node as potentially up for dead code elimination. IR2 can become really confused when converting dead code; a more systematic cleanup pass might provide a useful safety net. * The changes make a widely-used ir1-manipulation function safer, so this might also fix some other obscure compiler bug. * Reported by James Y Knight on IRC and Fila Kolodny on Launchpad (fixes lp#1183496). --- src/compiler/ir1util.lisp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/compiler/ir1util.lisp b/src/compiler/ir1util.lisp index 6c0a271..dc96f0c 100644 --- a/src/compiler/ir1util.lisp +++ b/src/compiler/ir1util.lisp @@ -110,7 +110,7 @@ (first new-uses) new-uses))) (setf (lvar-uses lvar) nil)) - (setf (node-lvar node) nil))) + (flush-node node))) (values)) ;;; Delete NODE from its LVAR uses; if LVAR has no other uses, delete ;;; its DEST's block, which must be unreachable. @@ -1421,6 +1421,20 @@ (values)) +;;; This function is called to unlink a node from its LVAR; +;;; we assume that the LVAR's USE list has already been updated, +;;; and that we only have to mark the node as up for dead code +;;; elimination, and to clear it LVAR slot. +(defun flush-node (node) + (declare (type node node)) + (let* ((prev (node-prev node)) + (block (ctran-block prev))) + (reoptimize-component (block-component block) t) + (setf (block-attributep (block-flags block) + flush-p type-asserted type-check) + t)) + (setf (node-lvar node) nil)) + ;;; This function is called by people who delete nodes; it provides a ;;; way to indicate that the value of a lvar is no longer used. We ;;; null out the LVAR-DEST, set FLUSH-P in the blocks containing uses @@ -1433,13 +1447,7 @@ (setf (lvar-dest lvar) nil) (flush-lvar-externally-checkable-type lvar) (do-uses (use lvar) - (let ((prev (node-prev use))) - (let ((block (ctran-block prev))) - (reoptimize-component (block-component block) t) - (setf (block-attributep (block-flags block) - flush-p type-asserted type-check) - t))) - (setf (node-lvar use) nil)) + (flush-node use)) (setf (lvar-uses lvar) nil)) (values)) -- 1.7.10.4