From cfa129e79a83dc2db9caebb8c8e36410cfb80739 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Tue, 16 Jan 2018 06:20:49 +0300 Subject: [PATCH] DCE: delete :optional functionals. It avoided deleting them due to deletion notes, don't report deletion of BIND nodes, which are of no interest anyway. Fixes lp#1743430 --- src/compiler/dce.lisp | 4 +--- src/compiler/ir1util.lisp | 2 ++ tests/compiler-2.pure.lisp | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/dce.lisp b/src/compiler/dce.lisp index c42eedfbd..78419675f 100644 --- a/src/compiler/dce.lisp +++ b/src/compiler/dce.lisp @@ -8,8 +8,6 @@ ;;; A CLAMBDA is deemed to be "externally referenced" if: ;;; - It is of KIND :TOPLEVEL (a toplevel CLAMBDA). -;;; - It is of KIND :OPTIONAL (an OPTIONAL-DISPATCH entry point, -;;; which may not be deleted even if it is not referenced). ;;; - It is LAMBDA-HAS-EXTERNAL-REFERENCES-P true (from COMPILE ;;; or from the fopcompiler, possibly other causes). ;;; - It has a REF which has a NODE-COMPONENT other than the @@ -22,7 +20,7 @@ ;;; implement. (defun lambda-externally-referenced-p (clambda) (or (lambda-has-external-references-p clambda) - (member (lambda-kind clambda) '(:toplevel :optional)) + (eq (lambda-kind clambda) :toplevel) (let ((home-component (lambda-component clambda))) (some (lambda (ref) (not (eq (node-component ref) diff --git a/src/compiler/ir1util.lisp b/src/compiler/ir1util.lisp index 17bdcc436..94f2ef750 100644 --- a/src/compiler/ir1util.lisp +++ b/src/compiler/ir1util.lisp @@ -1783,6 +1783,8 @@ ;; the CAST will get a note, no need to note ;; twice. (not (cast-p node)) + ;; Nothing interesting in BIND nodes + (not (bind-p node)) (or (eq first 'original-source-start) (and (atom first) (or (not (symbolp first)) diff --git a/tests/compiler-2.pure.lisp b/tests/compiler-2.pure.lisp index 72f0519d1..92916e62c 100644 --- a/tests/compiler-2.pure.lisp +++ b/tests/compiler-2.pure.lisp @@ -1051,3 +1051,8 @@ :allow-warnings t)))) + +(with-test (:name (:delete-recursive-optional)) + (checked-compile '(lambda (x) + (lambda () + (labels ((f (&optional a) (values x a #'f)))))))) -- 2.11.4.GIT