diff options
author | Andrea Corallo <akrl@sdf.org> | 2020-05-25 20:27:46 +0100 |
---|---|---|
committer | Andrea Corallo <akrl@sdf.org> | 2020-05-25 22:10:42 +0100 |
commit | f28b1780c6d5ed974e414a423cef8d11ed8145e6 (patch) | |
tree | 2c3b333c29da6ef60bb30d01524cf76108b3f342 /lisp/emacs-lisp | |
parent | b478d57e73ccff63788de805bfe178481ff084cf (diff) | |
download | emacs-f28b1780c6d5ed974e414a423cef8d11ed8145e6.tar.gz emacs-f28b1780c6d5ed974e414a423cef8d11ed8145e6.tar.bz2 emacs-f28b1780c6d5ed974e414a423cef8d11ed8145e6.zip |
* 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.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/comp.el | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 02917cb9a0a..11539761d1e 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) |