]> git.eshelyaron.com Git - emacs.git/commitdiff
improve dead assignment
authorAndrea Corallo <akrl@sdf.org>
Tue, 19 Nov 2019 19:27:27 +0000 (20:27 +0100)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:38:07 +0000 (11:38 +0100)
lisp/emacs-lisp/comp.el

index b6a3662ec5d88b68a22655a0def0d5c8ee244703..073af957bed6f545c5981490356b2e33ac08c153 100644 (file)
@@ -1684,13 +1684,14 @@ Return t if something was changed."
   "Collect the mvar unique identifiers into INSN."
   (cl-loop for x in insn
            if (consp x)
-           append (comp-collect-mvar-ids x)
+             append (comp-collect-mvar-ids x)
            else
-           when (comp-mvar-p x)
-           collect (comp-mvar-id x)))
+             when (comp-mvar-p x)
+               collect (comp-mvar-id x)))
 
 (defun comp-dead-assignments-func ()
-  "Clean-up dead assignments into current function."
+  "Clean-up trivial dead assignments into current function.
+Return the list of m-var ids nuked."
   (let ((l-vals ())
         (r-vals ()))
     ;; Collect used r and l values.
@@ -1725,7 +1726,8 @@ Return t if something was changed."
                         (if (comp-limple-insn-call-p rest)
                             rest
                           `(comment ,(format "optimized out: %s"
-                                             insn)))))))))
+                                             insn))))))
+      nuke-list)))
 
 (defun comp-remove-type-hints-func ()
   "Remove type hints from the current function.
@@ -1744,7 +1746,11 @@ These are substituted with normals 'set'."
   (when (>= comp-speed 2)
     (maphash (lambda (_ f)
                (let ((comp-func f))
-                 (comp-dead-assignments-func)
+                 (cl-loop
+                  for i from 1
+                  while (comp-dead-assignments-func)
+                  finally (comp-log (format "dead code rm run %d times\n" i) 2)
+                          (comp-log-func comp-func 3))
                  (comp-remove-type-hints-func)
                  (comp-log-func comp-func 3)))
              (comp-ctxt-funcs-h comp-ctxt))))