X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fphysenvanal.lisp;h=1da7274caee1b426bb8e2d220a1b9944f6675a63;hb=77c80b85dc9ae9bde0692d4193187bfca507b936;hp=ef0257f8b60ad6bd156d5e141f97d46374802696;hpb=34dd23563d2f5cf05c72b971da0d0b065a09bf2a;p=sbcl.git diff --git a/src/compiler/physenvanal.lisp b/src/compiler/physenvanal.lisp index ef0257f..1da7274 100644 --- a/src/compiler/physenvanal.lisp +++ b/src/compiler/physenvanal.lisp @@ -123,9 +123,8 @@ ;;; If FUN has no physical environment, assign one, otherwise clean up ;;; the old physical environment, removing/flagging variables that ;;; have no sets or refs. If a var has no references, we remove it -;;; from the closure. If it has no sets, we clear the INDIRECT flag. -;;; This is necessary because pre-analysis is done before -;;; optimization. +;;; from the closure. We always clear the INDIRECT flag. This is +;;; necessary because pre-analysis is done before optimization. (defun reinit-lambda-physenv (fun) (let ((old (lambda-physenv (lambda-home fun)))) (cond (old @@ -136,8 +135,7 @@ (physenv-closure old))) (flet ((clear (fun) (dolist (var (lambda-vars fun)) - (unless (lambda-var-sets var) - (setf (lambda-var-indirect var) nil))))) + (setf (lambda-var-indirect var) nil)))) (clear fun) (map nil #'clear (lambda-lets fun)))) (t @@ -184,7 +182,7 @@ (let ((set-physenv (get-node-physenv set))) (unless (eq set-physenv physenv) - (setf did-something t + (setf did-something t (lambda-var-indirect var) t) (close-over var set-physenv physenv)))))) did-something)) @@ -279,7 +277,7 @@ ;;; the component tail. ;;; -- Close over the NLX-INFO in the exit environment. ;;; -- If the exit is from an :ESCAPE function, then substitute a -;;; constant reference to NLX-Info structure for the escape +;;; constant reference to NLX-INFO structure for the escape ;;; function reference. This will cause the escape function to ;;; be deleted (although not removed from the DFO.) The escape ;;; function is no longer needed, and we don't want to emit code @@ -402,20 +400,27 @@ (emit-cleanups block1 block2))))))) (values)) -;;; Mark all tail-recursive uses of function result continuations with -;;; the corresponding TAIL-SET. Nodes whose type is NIL (i.e. don't -;;; return) such as calls to ERROR are never annotated as tail in -;;; order to preserve debugging information. +;;; Mark optimizable tail-recursive uses of function result +;;; continuations with the corresponding TAIL-SET. (defun tail-annotate (component) (declare (type component component)) (dolist (fun (component-lambdas component)) (let ((ret (lambda-return fun))) + ;; Nodes whose type is NIL (i.e. don't return) such as calls to + ;; ERROR are never annotated as TAIL-P, in order to preserve + ;; debugging information. + ;; + ;; FIXME: It might be better to add another DEFKNOWN property + ;; (e.g. NO-TAIL-RECURSION) and use it for error-handling + ;; functions like ERROR, instead of spreading this special case + ;; net so widely. (when ret (let ((result (return-result ret))) (do-uses (use result) - (when (and (immediately-used-p result use) + (when (and (policy use merge-tail-calls) + (immediately-used-p result use) (or (not (eq (node-derived-type use) *empty-type*)) (not (basic-combination-p use)) (eq (basic-combination-kind use) :local))) - (setf (node-tail-p use) t))))))) + (setf (node-tail-p use) t))))))) (values))