- (dolist (called (lambda-calls fun))
- (dolist (ref (leaf-refs called))
- (let ((this-call (continuation-dest (node-cont ref))))
- (when (and (node-tail-p this-call)
- (eq (node-home-lambda this-call) fun))
- (setf (node-tail-p this-call) nil)
- (ecase (functional-kind called)
- ((nil :cleanup :optional)
- (let ((block (node-block this-call))
- (cont (node-cont call)))
- (ensure-block-start cont)
- (unlink-blocks block (first (block-succ block)))
- (link-blocks block next-block)
- (delete-continuation-use this-call)
- (add-continuation-use this-call cont)))
- (:deleted)
- (:assignment
- (aver (eq called fun))))))))
+ (dolist (called (lambda-calls-or-closes fun))
+ (when (lambda-p called)
+ (dolist (ref (leaf-refs called))
+ (let ((this-call (continuation-dest (node-cont ref))))
+ (when (and this-call
+ (node-tail-p this-call)
+ (eq (node-home-lambda this-call) fun))
+ (setf (node-tail-p this-call) nil)
+ (ecase (functional-kind called)
+ ((nil :cleanup :optional)
+ (let ((block (node-block this-call))
+ (cont (node-cont call)))
+ (ensure-block-start cont)
+ (unlink-blocks block (first (block-succ block)))
+ (link-blocks block next-block)
+ (delete-continuation-use this-call)
+ (add-continuation-use this-call cont)))
+ (:deleted)
+ ;; The called function might be an assignment in the
+ ;; case where we are currently converting that function.
+ ;; In steady-state, assignments never appear as a called
+ ;; function.
+ (:assignment
+ (aver (eq called fun)))))))))