From edaa9e08de9829705943283f171ac73a09e74fb3 Mon Sep 17 00:00:00 2001
From: ram <ram>
Date: Thu, 16 Aug 1990 16:25:20 +0000
Subject: [PATCH] Added code to LOCAL-CALL-ANALYZE to delete functions that
 were never referenced.

---
 compiler/locall.lisp | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/compiler/locall.lisp b/compiler/locall.lisp
index 161a5e0ec..ed1fde683 100644
--- a/compiler/locall.lisp
+++ b/compiler/locall.lisp
@@ -260,12 +260,18 @@
   (loop
     (unless (component-new-functions component) (return))
     (let ((fun (pop (component-new-functions component))))
-      (unless (eq (functional-kind fun) :deleted)
-	(when (lambda-p fun)
-	  (push fun (component-lambdas component)))
-	(local-call-analyze-1 fun)
-	(when (lambda-p fun)
-	  (maybe-let-convert fun)))))
+      (cond ((eq (functional-kind fun) :deleted))
+	    ((and (null (leaf-refs fun))
+		  (ecase (functional-kind fun)
+		    ((nil :escape :cleanup) t)
+		    ((:optional :top-level) nil)))
+	     (delete-functional fun))
+	    (t
+	     (when (lambda-p fun)
+	       (push fun (component-lambdas component)))
+	     (local-call-analyze-1 fun)
+	     (when (lambda-p fun)
+	       (maybe-let-convert fun))))))
 
   (undefined-value))
 
-- 
GitLab