0.8.13.26:
[sbcl.git] / src / compiler / dfo.lisp
index a22339d..51a5953 100644 (file)
@@ -22,7 +22,7 @@
   (let ((head (component-head component)))
     (do ()
        ((dolist (ep (block-succ head) t)
-          (unless (block-flag ep)
+          (unless (or (block-flag ep) (block-delete-p ep))
             (find-dfo-aux ep head component)
             (return nil))))))
   (let ((num 0))
     (do-blocks-backwards (block component :both)
       (if (block-flag block)
          (setf (block-number block) (incf num))
-         (setf (block-delete-p block) t)))
-    (do-blocks (block component)
-      (unless (block-flag block)
-       (delete-block block))))
+         (delete-block-lazily block)))
+    (clean-component component (component-head component)))
   (values))
 
 ;;; Move all the code and entry points from OLD to NEW. The code in
@@ -59,7 +57,7 @@
       (unless (eq old-next old-tail)
        (setf (block-next head) old-next)
        (setf (block-prev old-next) head)
-       
+
        (setf (block-prev next) old-last)
        (setf (block-next old-last) next))
 
 (defun find-dfo-aux (block head component)
   (unless (eq (block-component block) component)
     (join-components component (block-component block)))
-  (unless (block-flag block)
+  (unless (or (block-flag block) (block-delete-p block))
     (setf (block-flag block) t)
     (dolist (succ (block-succ block))
       (find-dfo-aux succ head component))
+    (when (component-nlx-info-generated-p component)
+      ;; FIXME: We also need (and do) this walk before physenv
+      ;; analysis, but at that time we are probably not very
+      ;; interested in the actual DF order.
+      ;;
+      ;; TODO: It is probable that one of successors have the same (or
+      ;; similar) set of NLXes; try to shorten the walk (but think
+      ;; about a loop, the only exit from which is non-local).
+      (map-block-nlxes (lambda (nlx-info)
+                         (let ((nle (nlx-info-target nlx-info)))
+                         (find-dfo-aux nle head component)))
+                       block))
     (remove-from-dfo block)
     (add-to-dfo block head))
   (values))
          (res home))))
     (res)))
 
-;;; If CLAMBDA is not already in COMPONENT, just return that
+;;; If CLAMBDA is already in COMPONENT, just return that
 ;;; component. Otherwise, move the code for CLAMBDA and all lambdas it
 ;;; physically depends on (either because of calls or because of
 ;;; closure relationships) into COMPONENT, or possibly into another
 
     (values (real) (top) (real-top))))
 
-;; COMPONENTs want strings for names, LEAF-DEBUG-NAMEs mightn't be
-;; strings..
+;;; COMPONENTs want strings for names, LEAF-DEBUG-NAMEs mightn't be
+;;; strings...
 (defun component-name-from-functional-debug-name (functional)
   (declare (type functional functional))
   (let ((leaf-debug-name (leaf-debug-name functional)))
     (the simple-string
       (if (stringp leaf-debug-name)
          leaf-debug-name
-         (debug-namify "function ~S" leaf-debug-name)))))
+         (debug-namify "function " leaf-debug-name)))))
 
 ;;; Given a list of top level lambdas, return
 ;;;   (VALUES NONTOP-COMPONENTS TOP-COMPONENTS HAIRY-TOP-COMPONENTS).
     ;; an existing component if we find that there are references
     ;; between them. Any code that is left in an initial component
     ;; must be unreachable, so we can delete it. Stray links to the
-    ;; initial component tail (due NIL function terminated blocks)
+    ;; initial component tail (due to NIL function terminated blocks)
     ;; are moved to the appropriate new component tail.
     (dolist (toplevel-lambda toplevel-lambdas)
       (let* ((old-component (lambda-component toplevel-lambda))
     ;; in the old LAMBDA into the new one (with LETs implicitly moved
     ;; by changing their home.)
     (do-blocks (block component)
-      (do-nodes (node cont block)
+      (do-nodes (node nil block)
        (let ((lexenv (node-lexenv node)))
          (when (eq (lexenv-lambda lexenv) lambda)
            (setf (lexenv-lambda lexenv) result-lambda))))
     ;; is always a preceding REF NIL node in top level lambdas.
     (let ((return (lambda-return lambda)))
       (when return
-       (let ((return-block (node-block return))
-             (result (return-result return)))
-         (setf (block-last return-block) (continuation-use result))
-         (flush-dest result)
-         (delete-continuation result)
-         (link-blocks return-block result-return-block))))))
+       (link-blocks (node-block return) result-return-block)
+        (flush-dest (return-result return))
+        (unlink-node return)))))
 
 ;;; Given a non-empty list of top level LAMBDAs, smash them into a
 ;;; top level lambda and component, returning these as values. We use
       ;; Make sure the result's return node starts a block so that we
       ;; can splice code in before it.
       (let ((prev (node-prev
-                  (continuation-use
-                   (return-result result-return)))))
-       (when (continuation-use prev)
-         (node-ends-block (continuation-use prev)))
-       (do-uses (use prev)
-         (let ((new (make-continuation)))
-           (delete-continuation-use use)
-           (add-continuation-use use new))))
+                  (lvar-uses (return-result result-return)))))
+       (when (ctran-use prev)
+         (node-ends-block (ctran-use prev))))
 
       (dolist (lambda (rest lambdas))
        (merge-1-toplevel-lambda result-lambda lambda)))