From ba6f32a4f2e5628c7cce6a6eb6be803623e7f777 Mon Sep 17 00:00:00 2001
From: ram <ram>
Date: Wed, 30 Jan 1991 23:17:22 +0000
Subject: [PATCH] In DELETE-LAMBDA-VAR, reoptimize the continuation so that we
 get a change to delete the LET on the last var deletion. In CHANGE-REF-LEAF,
 if the new leaf's type is a FUNCTION-TYPE, then just set the node type to
 that type.  This prevents the type from going totally vague when we change
 from one function type to another.

---
 compiler/ir1util.lisp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/compiler/ir1util.lisp b/compiler/ir1util.lisp
index cfe984d74..382b1aa6d 100644
--- a/compiler/ir1util.lisp
+++ b/compiler/ir1util.lisp
@@ -542,7 +542,8 @@ inlines
 ;;;
 ;;;    Deal with deleting the last (read) reference to a lambda-var.  We
 ;;; iterate over all local calls flushing the corresponding argument, allowing
-;;; the computation of the argument to be deleted.
+;;; the computation of the argument to be deleted.  We also mark the let for
+;;; reoptimization, since it may be that we have deleted the last variable.
 ;;;
 ;;;    The lambda-var may still have some sets, but this doesn't cause too much
 ;;; difficulty, since we can efficiently implement write-only variables.  We
@@ -559,8 +560,10 @@ inlines
 	(when (and (combination-p dest)
 		   (eq (basic-combination-fun dest) cont)
 		   (eq (basic-combination-kind dest) :local))
-	  (let ((args (basic-combination-args dest)))
-	    (flush-dest (elt args n))
+	  (let* ((args (basic-combination-args dest))
+		 (arg (elt args n)))
+	    (reoptimize-continuation arg)
+	    (flush-dest arg)
 	    (setf (elt args n) nil))))))
 
   (dolist (set (lambda-var-sets leaf))
@@ -1125,7 +1128,10 @@ inlines
     (push ref (leaf-refs leaf))
     (delete-ref ref)
     (setf (ref-leaf ref) leaf)
-    (derive-node-type ref (leaf-type leaf))
+    (let ((ltype (leaf-type leaf)))
+      (if (function-type-p ltype)
+	  (setf (node-derived-type ref) ltype)
+	  (derive-node-type ref ltype)))
     (reoptimize-continuation (node-cont ref)))
   (undefined-value))
 
-- 
GitLab