From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yu Han Quek Newsgroups: gmane.emacs.bugs Subject: bug#46540: 28.0.50; Native-comp optimization bug Date: Tue, 16 Feb 2021 03:19:18 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000822db505bb64ddff" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24480"; mail-complaints-to="usenet@ciao.gmane.io" To: 46540@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 15 20:27:28 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBjWp-0006Fg-Uv for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Feb 2021 20:27:28 +0100 Original-Received: from localhost ([::1]:56972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBjWp-0001kz-1J for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Feb 2021 14:27:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBjPe-0005sz-Qy for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 14:20:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55407) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBjPe-0003JT-Iv for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 14:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lBjPe-0000cO-EF for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 14:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yu Han Quek Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Feb 2021 19:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46540 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16134167782342 (code B ref -1); Mon, 15 Feb 2021 19:20:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Feb 2021 19:19:38 +0000 Original-Received: from localhost ([127.0.0.1]:38720 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBjPG-0000bi-B5 for submit@debbugs.gnu.org; Mon, 15 Feb 2021 14:19:38 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:48884) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBjPE-0000bZ-HT for submit@debbugs.gnu.org; Mon, 15 Feb 2021 14:19:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBjPE-0005ie-CH for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 14:19:36 -0500 Original-Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]:45338) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBjPA-00036x-Pt for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 14:19:36 -0500 Original-Received: by mail-oi1-x22c.google.com with SMTP id q186so4849827oig.12 for ; Mon, 15 Feb 2021 11:19:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=b1iU4tsicfBSXZxr1D5Mts+e/7/76nohQDtSFDCzkzs=; b=PaHqp4N8dXYNVLIU3e5y/suPXNEYk3d46eCiTpYX51aKjycjpcuo5YVE1aRxvRX9E0 JwhWp2JdHBJ1iQ4Vph0DWhTeKKIjObeO/ndvkn7M//28xC3KiJ/0wkuM5CSsQOxGMj1e Cs2YB2u9PdunztNUKH8w6ZsHScINZTmX/RnKspSRfBwN1uTgifcCAb3QNWgqO3hHQ3nx n6fK+oMWtnqrwc94JrMDnIECxL5jvuh6YUwUBawun1N3XcDkBKwbwMnWCrNufdYuOP0+ CQcFarbRINPTl/WVsUJvIr0HvdUk78zkC2Z7y//B5if5DpuFsdyuYdoK4+hHUuK6zLAL 6gLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=b1iU4tsicfBSXZxr1D5Mts+e/7/76nohQDtSFDCzkzs=; b=A06G28Ui8Mr2AWTUDrCkZaiA0wGRKdJeGvr3sGtCEsvb7zNIzxDhtDm/wSjnLQSW+v 7vE6qhhmsr9qHle97HWpapeP7p5u6VPVrAEkcvJEUAn81kihq2KltDILFl8tw12Et2cz yMGVAq7L6x1DywOMG2a0VzEPj6MifypbTdIPyGXGIINgeM87oOO1DARZs/9BeUN1sUiG IcjfVCjDi2n/URIZB3aQDivBnHQsUK538U5Z5fmPlzANULnj4YbAYwMcQrvjpnk1CWCf 5gR6JKia+dX/3KwI/4nKUWmZJge+3BZpiWPjUZZ0Lbia4r6/wK14gfQXyziOUtf9GBQh D6mg== X-Gm-Message-State: AOAM532Oj4W9R8+72R23lJpdK5Hn3PBBqpb8ru5b1kDuwkrzCyYq54EJ xZXdG6uxZ3N4PCtZH2iF59GB4Cd7Ly8FDDpg9zmK/2CuiKanew== X-Google-Smtp-Source: ABdhPJyZlgNTCB1yLDyKV0cKtGTibFbFI6yFi0UUkIFoh1BZT31tzgrhoGKHp3pE8HX4nCpaaHLIUG0gNU2OMEZwxjU= X-Received: by 2002:aca:5988:: with SMTP id n130mr308664oib.60.1613416770971; Mon, 15 Feb 2021 11:19:30 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::22c; envelope-from=qythium@gmail.com; helo=mail-oi1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:200081 Archived-At: --000000000000822db505bb64ddff Content-Type: text/plain; charset="UTF-8" The following function gives an incorrect result when compiled natively with comp-speed >= 2. ;; -*- lexical-binding: t; -*- (defun native-comp-bug (body) (let ((x (car body)) (y (cadr body))) (unless (and (natnump x) (natnump y) (<= x y)) (error "")) x)) (native-comp-bug '(3 4)) ;; Expected result: 3 ;; Actual result: 0 The car of the argument is ignored and treated as 0. This appears to be a minimal repro, manually shrunk from the original function discovered in rx.el (rx--translate-bounded-repetition). If either lexical binding, natnump/inequality checks, or error form is removed, the function behaves as expected. Setting comp-speed to 0 or 1 also causes the function to behave as expected, but setting it to 2 or 3 produces the error. In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.2.0, NS appkit-2022.20 Version 11.1 (Build 20C69)) of 2021-02-03 built on QYH2.local Repository revision: e56c26d06f72b58acdc59c7e2958be9b691d3e78 Repository branch: master System Description: macOS 11.2.1 Configured using: 'configure --with-ns --with-modules '--enable-locallisppath=/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp' --with-xwidgets --with-nativecomp --without-rsvg 'CFLAGS=-I/usr/local/opt/gcc/include -O2 -march=native' 'LDFLAGS=-L/usr/local/opt/gcc/lib/gcc/10 -L/usr/local/opt/libgccjit/lib/gcc/10 -L/usr/local/opt/gcc/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0 -I/usr/local/opt/gcc/include -I/usr/local/opt/libgccjit/include'' Configured features: ACL GIF GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG THREADS TIFF TOOLKIT_SCROLL_BARS XWIDGETS ZLIB Important settings: value of $LC_ALL: en_US.UTF-8 value of $LC_CTYPE: UTF-8 value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs password-cache json map text-property-search time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils term/xterm xterm comp comp-cstr warnings subr-x rx cl-seq cl-macs cl-extra help-mode easymenu seq byte-opt gv cl-loaddefs cl-lib bytecomp byte-compile cconv iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face pcase macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads xwidget-internal kqueue cocoa ns lcms2 multi-tty make-network-process nativecomp emacs) Memory information: ((conses 16 79127 4281) (symbols 48 8088 1) (strings 32 20784 4357) (string-bytes 1 680668) (vectors 16 13082) (vector-slots 8 220094 8657) (floats 8 27 13) (intervals 56 213 0) (buffers 984 11)) --000000000000822db505bb64ddff Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

The following function gives an incorrect result when = compiled natively
with comp-speed >=3D 2.

;; -*- lexical-bindi= ng: t; -*-

(defun native-comp-bug (body)
=C2=A0 (let ((x (car bod= y))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (y (cadr body)))
=C2=A0 =C2=A0 (unles= s (and
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(natnump x)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(natnump y)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(<=3D x y))
=C2=A0 =C2=A0 =C2= =A0 (error ""))
=C2=A0 =C2=A0 x))

(native-comp-bug '= ;(3 4))

;; Expected result: 3
;; Actual result: 0

The car = of the argument is ignored and treated as 0.

This appears to be a mi= nimal repro, manually shrunk from the original function
discovered in rx= .el (rx--translate-bounded-repetition).

If either lexical binding, n= atnump/inequality checks, or error form is removed,
the function behaves= as expected.

Setting comp-speed to 0 or 1 also causes the function = to behave as expected, but
setting it to 2 or 3 produces the error.
<= br>In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.2.0, NS appkit-2022= .20 Version 11.1 (Build 20C69))
=C2=A0of 2021-02-03 built on QYH2.local<= br>Repository revision: e56c26d06f72b58acdc59c7e2958be9b691d3e78
Reposit= ory branch: master
System Description: =C2=A0macOS 11.2.1

Configu= red using:
=C2=A0'configure --with-ns --with-modules
=C2=A0'-= -enable-locallisppath=3D/Library/Application
=C2=A0Support/Emacs/${versi= on}/site-lisp:/Library/Application
=C2=A0Support/Emacs/site-lisp' --= with-xwidgets --with-nativecomp
=C2=A0--without-rsvg 'CFLAGS=3D-I/us= r/local/opt/gcc/include -O2 -march=3Dnative'
=C2=A0'LDFLAGS=3D-L= /usr/local/opt/gcc/lib/gcc/10
=C2=A0-L/usr/local/opt/libgccjit/lib/gcc/1= 0
=C2=A0-L/usr/local/opt/gcc/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0=
=C2=A0-I/usr/local/opt/gcc/include -I/usr/local/opt/libgccjit/include&#= 39;'

Configured features:
ACL GIF GMP GNUTLS JPEG JSON LCMS2 = LIBXML2 MODULES NATIVE_COMP NOTIFY
KQUEUE NS PDUMPER PNG THREADS TIFF TO= OLKIT_SCROLL_BARS XWIDGETS ZLIB

Important settings:
=C2=A0 value = of $LC_ALL: en_US.UTF-8
=C2=A0 value of $LC_CTYPE: UTF-8
=C2=A0 value= of $LANG: en_US.UTF-8
=C2=A0 locale-coding-system: utf-8-unix

Ma= jor mode: Lisp Interaction

Minor modes in effect:
=C2=A0 tooltip-= mode: t
=C2=A0 global-eldoc-mode: t
=C2=A0 eldoc-mode: t
=C2=A0 el= ectric-indent-mode: t
=C2=A0 mouse-wheel-mode: t
=C2=A0 tool-bar-mode= : t
=C2=A0 menu-bar-mode: t
=C2=A0 file-name-shadow-mode: t
=C2=A0= global-font-lock-mode: t
=C2=A0 font-lock-mode: t
=C2=A0 blink-curso= r-mode: t
=C2=A0 auto-composition-mode: t
=C2=A0 auto-encryption-mode= : t
=C2=A0 auto-compression-mode: t
=C2=A0 line-number-mode: t
=C2= =A0 transient-mark-mode: t

Load-path shadows:
None found.

= Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-l= oaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmailrmail-loaddefs auth-source eieio eieio-core eieio-loaddefs
password-cac= he json map text-property-search time-date mm-decode
mm-bodies mm-encode= mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc= 2045 ietf-drums mm-util mail-prsvr mail-utils
term/xterm xterm comp comp= -cstr warnings subr-x rx cl-seq cl-macs
cl-extra help-mode easymenu seq = byte-opt gv cl-loaddefs cl-lib bytecomp
byte-compile cconv iso-transl to= oltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel= term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd= fontset image regexp-opt fringe
tabulated-list replace newcomment text-= mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-e= shadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax f= acemenu font-core
term/tty-colors frame minibuffer cl-generic cham georg= ian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean jap= anese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethio= pic indian
cyrillic chinese composite charscript charprop case-table epa= -hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice butt= on
loaddefs faces cus-face pcase macroexp files window text-propertiesoverlay sha1 md5 base64 format env code-pages mule custom widget
hasht= able-print-readable backquote threads xwidget-internal kqueue cocoa
ns l= cms2 multi-tty make-network-process nativecomp emacs)

Memory informa= tion:
((conses 16 79127 4281)
=C2=A0(symbols 48 8088 1)
=C2=A0(str= ings 32 20784 4357)
=C2=A0(string-bytes 1 680668)
=C2=A0(vectors 16 1= 3082)
=C2=A0(vector-slots 8 220094 8657)
=C2=A0(floats 8 27 13)
= =C2=A0(intervals 56 213 0)
=C2=A0(buffers 984 11))
--000000000000822db505bb64ddff--