-
- (let ((calls (if (eq (functional-kind fun) :external)
- (append (find-reference-funs fun)
- (lambda-calls fun))
- (lambda-calls fun))))
- (do ((res (find-initial-dfo-aux bind-block component)
- (dfo-scavenge-call-graph (first remaining-calls) res))
- (remaining-calls calls (rest remaining-calls)))
- ((null remaining-calls)
- res)
- (declare (type component res))))))))
-
-;;; Return true if FUN is either an XEP or has EXITS to some of its
-;;; ENTRIES.
-(defun has-xep-or-nlx (fun)
- (declare (type clambda fun))
- (or (eq (functional-kind fun) :external)
- (let ((entries (lambda-entries fun)))
+ (let ((res (find-initial-dfo-aux bind-block component)))
+ (declare (type component res))
+ ;; Scavenge call relationships.
+ (let ((calls (if (eq (lambda-kind clambda) :external)
+ (append (find-reference-funs clambda)
+ (lambda-calls clambda))
+ (lambda-calls clambda))))
+ (dolist (call calls)
+ (let ((call-home (lambda-home call)))
+ (setf res (dfo-scavenge-dependency-graph call-home res)))))
+ ;; Scavenge closure-over relationships: if FUN refers to a
+ ;; variable whose home lambda is not FUN, then the home lambda
+ ;; should be in the same component as FUN. (sbcl-0.6.13, and
+ ;; CMU CL, didn't do this, leading to the occasional failure
+ ;; when physenv analysis, which is local to each component,
+ ;; would bogusly conclude that a closed-over variable was
+ ;; unused and thus delete it. See e.g. cmucl-imp 2001-11-29.)
+ (dolist (var (lambda-refers-to-vars clambda))
+ (unless (null (lambda-var-refs var)) ; i.e. unless deleted
+ (let ((var-home-home (lambda-home (lambda-var-home var))))
+ (unless (eql (lambda-kind var-home-home) :deleted)
+ (setf res
+ (dfo-scavenge-dependency-graph var-home-home res))))))
+ ;; Voila.
+ res)))))
+
+;;; Return true if CLAMBDA either is an XEP or has EXITS to some of
+;;; its ENTRIES.
+(defun has-xep-or-nlx (clambda)
+ (declare (type clambda clambda))
+ (or (eq (functional-kind clambda) :external)
+ (let ((entries (lambda-entries clambda)))