From b3816280ade558c475386da7c36ab9079ea434f2 Mon Sep 17 00:00:00 2001
From: gerd <gerd>
Date: Mon, 6 Oct 2003 12:39:58 +0000
Subject: [PATCH] 	FIXME: Dead code elimination sometimes leaves spurious
 references 	to unused lambda-vars.  Unused vars are not packed, and so
 have a 	tn but a null tn-offset.  Some of these cases have been fixed,
 but 	not all of them, and since it's not sure if/when all of them will 
 be fixed, add a hack for these cases.

	* src/compiler/debug-dump.lisp (dump-1-variable): If the
	tn-offset of a tn is null, set the tn to nil.

	(compile nil
          '(lambda (a b)
             (declare (optimize (speed 3) (debug 1)))
             (let ((v7
                    (let ((v2 (block b5 (return-from b5 (if t b -4)))))
                         a)))
                  -65667836)))
	 => error nil is not integer, in dump-1-variable.

	This is caused by an exit from the return-from being deleted,
	while leaving the exit's value untouched, which leads to a
	remaining reference to lambda-var b, which is unused and therefore
	not being packed.

	* src/compiler/ir1opt.lisp (maybe-delete-exit): When no node
	receives the value of the exit, flush the dest of the exit's
	value.
---
 compiler/debug-dump.lisp | 12 +++++++++++-
 compiler/ir1opt.lisp     |  4 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/compiler/debug-dump.lisp b/compiler/debug-dump.lisp
index 9db4b595d..d0ccbf823 100644
--- a/compiler/debug-dump.lisp
+++ b/compiler/debug-dump.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/debug-dump.lisp,v 1.44 2003/02/16 19:05:19 emarsden Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/debug-dump.lisp,v 1.45 2003/10/06 12:39:58 gerd Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -379,6 +379,16 @@
 	 (kind (and tn (tn-kind tn)))
 	 (flags 0))
     (declare (type index flags))
+    ;;
+    ;; FIXME: Dead code elimination sometimes leaves spurious
+    ;; references to unused lambda-vars.  Unused vars are not packed,
+    ;; and so have a tn but a null tn-offset.  Some of these cases
+    ;; have been fixed, but not all of them, and since it's not sure
+    ;; if/when all of them will be fixed, add a hack for these cases.
+    ;; -- gerd 2003-10-06
+    (when (and tn (null (tn-offset tn)))
+      (setq tn nil))
+      
     (cond (minimal
 	   (setq flags (logior flags compiled-debug-variable-minimal-p))
 	   (unless tn
diff --git a/compiler/ir1opt.lisp b/compiler/ir1opt.lisp
index 2d96853c4..c82933a09 100644
--- a/compiler/ir1opt.lisp
+++ b/compiler/ir1opt.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/ir1opt.lisp,v 1.78 2003/10/05 12:34:35 gerd Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/ir1opt.lisp,v 1.79 2003/10/06 12:39:58 gerd Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -744,6 +744,8 @@
 		(when (and (basic-combination-p use)
 			   (eq (basic-combination-kind use) :local))
 		  (merges use))))
+	    (when (null (continuation-dest cont))
+	      (flush-dest value))
 	    (substitute-continuation-uses cont value)
 	    (dolist (merge (merges))
 	      (merge-tail-sets merge))))))))
-- 
GitLab