From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#46847: 28.0.50; [native-comp] assume pseudo-insns should be verified Date: Mon, 01 Mar 2021 20:12:15 +0000 Message-ID: References: Reply-To: Andrea Corallo Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3748"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 46847@debbugs.gnu.org To: Pip Cet Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 01 21:13:18 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 1lGous-0000tX-5b for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Mar 2021 21:13:18 +0100 Original-Received: from localhost ([::1]:59638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGour-0007GW-5c for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Mar 2021 15:13:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGouc-0007EB-Lf for bug-gnu-emacs@gnu.org; Mon, 01 Mar 2021 15:13:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lGouc-0002oX-F0 for bug-gnu-emacs@gnu.org; Mon, 01 Mar 2021 15:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lGouc-0003Xn-9p for bug-gnu-emacs@gnu.org; Mon, 01 Mar 2021 15:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Mar 2021 20:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46847 X-GNU-PR-Package: emacs Original-Received: via spool by 46847-submit@debbugs.gnu.org id=B46847.161462954013557 (code B ref 46847); Mon, 01 Mar 2021 20:13:02 +0000 Original-Received: (at 46847) by debbugs.gnu.org; 1 Mar 2021 20:12:20 +0000 Original-Received: from localhost ([127.0.0.1]:50951 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGotv-0003Wa-Vu for submit@debbugs.gnu.org; Mon, 01 Mar 2021 15:12:20 -0500 Original-Received: from mx.sdf.org ([205.166.94.24]:62819) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGots-0003WR-Lz for 46847@debbugs.gnu.org; Mon, 01 Mar 2021 15:12:18 -0500 Original-Received: from mab (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 121KCFOh017247 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Mon, 1 Mar 2021 20:12:15 GMT In-Reply-To: (Pip Cet's message of "Mon, 1 Mar 2021 13:06:31 +0000") 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:201166 Archived-At: Pip Cet writes: > This is a wishlist item for the native-comp branch, though I consider > the feature in question to be so essential that its absence also > qualifies as a bug. > > The native-comp branch is emitting assume pseudo-insns. Those come in > various forms, but their interpretation is clear: they express > conditions which are meant to hold at runtime, and which the compiler > may use to optimize code. > > I would like to add an optional compiler pass which asserts that the > conditions are actually true at runtime. This is a basic safeguard > that any assume() mechanism should have, and it's perfectly equivalent > to the way eassume() becomes eassert() in debug builds of Emacs. > > Unfortunately, it turns out that while adding the compiler pass is > easy, there are many failures because the assume pseudo-insns emitted > at present are inconsistent or plain wrong. Some of these wrong > assumes result in reproducible Lisp-to-native-code bugs today; others > will not; for still others, we're not sure. I think the issue might be that how assumes works has been miss-understood here. Assumes are working after SSA rename in the world of mvar ids, in contrast we render code based on slot numbers. Rendering assertions based on assumes using the slot numbers (IIUC that's what your patch did) certainly leads to inconsistencies, but that's a fundamental miss-interpretation of how assumes are working. This is probably also why you often suggests assumes are inconsistent. Anyway, for the reasons above rendering 1:1 assumes into run-time checks is not easily possible. OTOH a possible way, and that's what I want to do, would be to verify just before each (non pseudo) insn actually rendered that the slots in use there are consistent with the prediction. One could even control that with a parameter and have a mode where we just inject asserts on return insns not to bloat excessively the code. Note: I'm not aware of any compiler emitting run-time checks to verify its compile time predictions by why not. I'll take this task as sounds like good verification/development cost trade-off to me. Will follow-up on this! Thanks Andrea