summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2021-08-05 11:50:25 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2021-08-05 15:33:05 +0200
commit2a17925aab75735b40f9b0ccaab4c46f6b9a9a32 (patch)
tree9bf4f3c62e87cc85f7588626be46845afb19a1cb /lisp/emacs-lisp
parent2d8c14d299600c08751bfb978883c9f1b7141555 (diff)
downloademacs-2a17925aab75735b40f9b0ccaab4c46f6b9a9a32.tar.gz
emacs-2a17925aab75735b40f9b0ccaab4c46f6b9a9a32.tar.bz2
emacs-2a17925aab75735b40f9b0ccaab4c46f6b9a9a32.zip
Cease attempts to const-propagate through setq
The current method of propagating constants through setq was unsound because it relied on each setq form only being traversed at most once during optimisation, which isn't necessarily true in general; it could be made to miscompile code in rare cases. Since it was only used in limited circumstances, disabling this optimisation doesn't cost us much. * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Don't update the known value when traversing `setq`. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test case.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/byte-opt.el12
1 files changed, 3 insertions, 9 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 96072ea1b55..6475f69eded 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -601,15 +601,9 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.")
(lexvar (assq var byte-optimize--lexvars))
(value (byte-optimize-form expr nil)))
(when lexvar
- ;; Set a new value or inhibit further substitution.
- (setcdr (cdr lexvar)
- (and
- ;; Inhibit if bound outside conditional code.
- (not (assq var byte-optimize--vars-outside-condition))
- ;; The new value must be substitutable.
- (byte-optimize--substitutable-p value)
- (list value)))
- (setcar (cdr lexvar) t)) ; Mark variable to be kept.
+ (setcar (cdr lexvar) t) ; Mark variable to be kept.
+ (setcdr (cdr lexvar) nil)) ; Inhibit further substitution.
+
(push var var-expr-list)
(push value var-expr-list))
(setq args (cddr args)))