diff options
author | Andrea Corallo <akrl@sdf.org> | 2020-11-14 16:25:56 +0100 |
---|---|---|
committer | Andrea Corallo <akrl@sdf.org> | 2020-11-14 22:06:31 +0100 |
commit | 22da28cf6643b6293aa0255eca5f398dad23516d (patch) | |
tree | c32484f4e7f8c1bbf9117694a5f567812c1eeed2 /lisp/emacs-lisp | |
parent | 3d14a74f8f35fe16823361beb03dd0957dd6f510 (diff) | |
download | emacs-22da28cf6643b6293aa0255eca5f398dad23516d.tar.gz emacs-22da28cf6643b6293aa0255eca5f398dad23516d.tar.bz2 emacs-22da28cf6643b6293aa0255eca5f398dad23516d.zip |
* Split logic into comp-fwprop-call and improve it
* lisp/emacs-lisp/comp.el (comp-func-ret-valset)
(comp-fwprop-call): New functions.
(comp-fwprop-insn): Remove code duplicaiton and call
`comp-fwprop-call'.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/comp.el | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index fa94d399eb5..ffd483108d3 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -670,6 +670,11 @@ Return the corresponding `comp-constraint' or `comp-constraint-f'." (when-let ((spec (gethash func comp-known-constraints-h))) (comp-constraint-range (comp-constraint-f-ret spec)))) +(defun comp-func-ret-valset (func) + "Return the valset returned by function FUNC." + (when-let ((spec (gethash func comp-known-constraints-h))) + (comp-constraint-valset (comp-constraint-f-ret spec)))) + (defun comp-func-unique-in-cu-p (func) "Return t if FUNC is known to be unique in the current compilation unit." (if (symbolp func) @@ -2601,26 +2606,29 @@ Return LVAL." (mapcar #'comp-mvar-range rhs-mvars)))) lval)) +(defun comp-fwprop-call (insn lval f args) + "Propagate on a call INSN into LVAL. +F is the function being called with arguments ARGS. +Fold the call in case." + (if-let ((range (comp-func-ret-range f))) + (setf (comp-mvar-range lval) range + (comp-mvar-typeset lval) nil) + (if-let ((valset (comp-func-ret-valset f))) + (setf (comp-mvar-valset lval) valset + (comp-mvar-typeset lval) nil) + (setf (comp-mvar-typeset lval) (comp-func-ret-typeset f)))) + (comp-function-call-maybe-fold insn f args)) + (defun comp-fwprop-insn (insn) "Propagate within INSN." (pcase insn (`(set ,lval ,rval) (pcase rval (`(,(or 'call 'callref) ,f . ,args) - (if-let ((range (comp-func-ret-range f))) - (setf (comp-mvar-range lval) range - (comp-mvar-typeset lval) nil) - (setf (comp-mvar-typeset lval) - (comp-func-ret-typeset f))) - (comp-function-call-maybe-fold insn f args)) + (comp-fwprop-call insn lval f args)) (`(,(or 'direct-call 'direct-callref) ,f . ,args) (let ((f (comp-func-name (gethash f (comp-ctxt-funcs-h comp-ctxt))))) - (if-let ((range (comp-func-ret-range f))) - (setf (comp-mvar-range lval) range - (comp-mvar-typeset lval) nil) - (setf (comp-mvar-typeset lval) - (comp-func-ret-typeset f))) - (comp-function-call-maybe-fold insn f args))) + (comp-fwprop-call insn lval f args))) (_ (comp-mvar-propagate lval rval)))) (`(assume ,lval ,rval ,kind) |