From 6c73418c95ae5aca7e63d8d5703a90e178350527 Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Sat, 6 Mar 2021 20:53:57 +0000 Subject: [PATCH] Fix miscompilation of funcall forms in some cases (bug#46974) * lisp/emacs-lisp/comp.el (comp-call-optim-func): Call comp-cstr-imm-vld-p before relying on comp-cstr-imm to return the right value. --- lisp/emacs-lisp/comp.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 8a6e761fe40..134b5a28086 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3282,11 +3282,13 @@ FUNCTION can be a function-name or byte compiled function." do (comp-loop-insn-in-block b (pcase insn (`(set ,lval (callref funcall ,f . ,rest)) - (when-let ((new-form (comp-call-optim-form-call + (when-let ((ok (comp-cstr-imm-vld-p f)) + (new-form (comp-call-optim-form-call (comp-cstr-imm f) rest))) (setf insn `(set ,lval ,new-form)))) (`(callref funcall ,f . ,rest) - (when-let ((new-form (comp-call-optim-form-call + (when-let ((ok (comp-cstr-imm-vld-p f)) + (new-form (comp-call-optim-form-call (comp-cstr-imm f) rest))) (setf insn new-form))))))) -- 2.39.2