emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp f28b178 1/2: * Split type hint pass from dead code r


From: Andrea Corallo
Subject: feature/native-comp f28b178 1/2: * Split type hint pass from dead code removal pass into dedicated one.
Date: Mon, 25 May 2020 17:26:35 -0400 (EDT)

branch: feature/native-comp
commit f28b1780c6d5ed974e414a423cef8d11ed8145e6
Author: Andrea Corallo <address@hidden>
Commit: Andrea Corallo <address@hidden>

    * Split type hint pass from dead code removal pass into dedicated one.
    
    Given SSA prop overwrite mvar type slot we clean-up the compiler type
    hints as last.
    
    * lisp/emacs-lisp/comp.el (comp-passes): Add comp-remove-type-hints.
    (comp-remove-type-hints-func): Code move.
    (comp-dead-code): Do not call `comp-remove-type-hints-func'.
    (comp-remove-type-hints): Add as new pass.
---
 lisp/emacs-lisp/comp.el | 44 +++++++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 02917cb..1153976 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -167,6 +167,7 @@ Can be one of: 'd-default', 'd-impure' or 'd-ephemeral'.  
See `comp-ctxt'.")
                         comp-dead-code
                         comp-tco
                         comp-propagate-alloc
+                        comp-remove-type-hints
                         comp-final)
   "Passes to be executed in order.")
 
@@ -2089,18 +2090,6 @@ Return the list of m-var ids nuked."
                                              insn))))))
       nuke-list)))
 
-(defun comp-remove-type-hints-func ()
-  "Remove type hints from the current function.
-These are substituted with a normal 'set' op."
-  (cl-loop
-   for b being each hash-value of (comp-func-blocks comp-func)
-   do (cl-loop
-       for insn-cell on (comp-block-insns b)
-       for insn = (car insn-cell)
-       do (pcase insn
-            (`(set ,l-val (call ,(pred comp-type-hint-p) ,r-val))
-             (setcar insn-cell `(set ,l-val ,r-val)))))))
-
 (defun comp-dead-code (_)
   "Dead code elimination."
   (when (>= comp-speed 2)
@@ -2112,9 +2101,7 @@ These are substituted with a normal 'set' op."
                     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-log-func comp-func 3)))))
              (comp-ctxt-funcs-h comp-ctxt))))
 
 
@@ -2157,6 +2144,33 @@ These are substituted with a normal 'set' op."
              (comp-ctxt-funcs-h comp-ctxt))))
 
 
+;;; Type hint removal pass specific code.
+
+;; This must run after all SSA prop not to have the type hint
+;; information overwritten.
+
+(defun comp-remove-type-hints-func ()
+  "Remove type hints from the current function.
+These are substituted with a normal 'set' op."
+  (cl-loop
+   for b being each hash-value of (comp-func-blocks comp-func)
+   do (cl-loop
+       for insn-cell on (comp-block-insns b)
+       for insn = (car insn-cell)
+       do (pcase insn
+            (`(set ,l-val (call ,(pred comp-type-hint-p) ,r-val))
+             (setcar insn-cell `(set ,l-val ,r-val)))))))
+
+(defun comp-remove-type-hints (_)
+  "Dead code elimination."
+  (when (>= comp-speed 2)
+    (maphash (lambda (_ f)
+               (let ((comp-func f))
+                 (comp-remove-type-hints-func)
+                 (comp-log-func comp-func 3)))
+             (comp-ctxt-funcs-h comp-ctxt))))
+
+
 ;;; Final pass specific code.
 
 (defun comp-finalize-container (cont)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]