- (if (member original-kind '(:let :mv-let :assignment))
- (let ((home (lambda-home clambda)))
- (setf (lambda-lets home) (delete clambda (lambda-lets home))))
- ;; If the function isn't a LET, we unlink the function head
- ;; and tail from the component head and tail to indicate that
- ;; the code is unreachable. We also delete the function from
- ;; COMPONENT-LAMBDAS (it won't be there before local call
- ;; analysis, but no matter.) If the lambda was never
- ;; referenced, we give a note.
- (let* ((bind-block (node-block bind))
- (component (block-component bind-block))
- (return (lambda-return clambda))
- (return-block (and return (node-block return))))
- (unless (leaf-ever-used clambda)
- (let ((*compiler-error-context* bind))
- (compiler-notify 'code-deletion-note
- :format-control "deleting unused function~:[.~;~:*~% ~S~]"
- :format-arguments (list (leaf-debug-name clambda)))))
- (unless (block-delete-p bind-block)
- (unlink-blocks (component-head component) bind-block))
- (when (and return-block (not (block-delete-p return-block)))
- (mark-for-deletion return-block)
- (unlink-blocks return-block (component-tail component)))
- (setf (component-reanalyze component) t)
- (let ((tails (lambda-tail-set clambda)))
- (setf (tail-set-funs tails)
- (delete clambda (tail-set-funs tails)))
- (setf (lambda-tail-set clambda) nil))
- (setf (component-lambdas component)
- (delq clambda (component-lambdas component)))))
+ (case original-kind
+ (:zombie)
+ ((:let :mv-let :assignment)
+ (let ((bind-block (node-block bind)))
+ (mark-for-deletion bind-block))
+ (let ((home (lambda-home clambda)))
+ (setf (lambda-lets home) (delete clambda (lambda-lets home))))
+ ;; KLUDGE: In presence of NLEs we cannot always understand that
+ ;; LET's BIND dominates its body [for a LET "its" body is not
+ ;; quite its]; let's delete too dangerous for IR2 stuff. --
+ ;; APD, 2004-01-01
+ (dolist (var (lambda-vars clambda))
+ (flet ((delete-node (node)
+ (mark-for-deletion (node-block node))))
+ (mapc #'delete-node (leaf-refs var))
+ (mapc #'delete-node (lambda-var-sets var)))))
+ (t
+ ;; Function has no reachable references.
+ (dolist (ref (lambda-refs clambda))
+ (mark-for-deletion (node-block ref)))
+ ;; If the function isn't a LET, we unlink the function head
+ ;; and tail from the component head and tail to indicate that
+ ;; the code is unreachable. We also delete the function from
+ ;; COMPONENT-LAMBDAS (it won't be there before local call
+ ;; analysis, but no matter.) If the lambda was never
+ ;; referenced, we give a note.
+ (let* ((bind-block (node-block bind))
+ (component (block-component bind-block))
+ (return (lambda-return clambda))
+ (return-block (and return (node-block return))))
+ (unless (leaf-ever-used clambda)
+ (let ((*compiler-error-context* bind))
+ (compiler-notify 'code-deletion-note
+ :format-control "deleting unused function~:[.~;~:*~% ~S~]"
+ :format-arguments (list (leaf-debug-name clambda)))))
+ (unless (block-delete-p bind-block)
+ (unlink-blocks (component-head component) bind-block))
+ (when (and return-block (not (block-delete-p return-block)))
+ (mark-for-deletion return-block)
+ (unlink-blocks return-block (component-tail component)))
+ (setf (component-reanalyze component) t)
+ (let ((tails (lambda-tail-set clambda)))
+ (setf (tail-set-funs tails)
+ (delete clambda (tail-set-funs tails)))
+ (setf (lambda-tail-set clambda) nil))
+ (setf (component-lambdas component)
+ (delq clambda (component-lambdas component))))))