From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFBC4C433F5 for ; Thu, 18 Nov 2021 20:12:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B69ED61ACE for ; Thu, 18 Nov 2021 20:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbhKRUPA (ORCPT ); Thu, 18 Nov 2021 15:15:00 -0500 Received: from gate.crashing.org ([63.228.1.57]:56730 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbhKRUPA (ORCPT ); Thu, 18 Nov 2021 15:15:00 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 1AIK8hFn006261; Thu, 18 Nov 2021 14:08:44 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 1AIK8hhe006260; Thu, 18 Nov 2021 14:08:43 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 18 Nov 2021 14:08:43 -0600 From: Segher Boessenkool To: Joseph Myers Cc: Prathamesh Kulkarni , David Malcolm , gcc-patches@gcc.gnu.org, linux-toolchains@vger.kernel.org Subject: Re: [PATCH 2/6] Add returns_zero_on_success/failure attributes Message-ID: <20211118200843.GY614@gate.crashing.org> References: <20211113203732.2098220-1-dmalcolm@redhat.com> <20211113203732.2098220-4-dmalcolm@redhat.com> <15adb3a2a70b0d2973c30dd6d7da383ad62f413a.camel@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Wed, Nov 17, 2021 at 10:43:58PM +0000, Joseph Myers wrote: > On Wed, 17 Nov 2021, Prathamesh Kulkarni via Gcc-patches wrote: > > More generally, would it be a good idea to provide attributes for > > mod/ref anaylsis ? > > So sth like: > > void foo(void) __attribute__((modifies(errno))); > > which would state that foo modifies errno, but neither reads nor > > modifies any other global var. > > and > > void bar(void) __attribute__((reads(errno))) > > which would state that bar only reads errno, and doesn't modify or > > read any other global var. > > Many math.h functions are const except for possibly setting errno, > possibly raising floating-point exceptions (which might have other effects > when using alternate exception handling) and possibly reading the rounding > mode. To represent that, it might be useful for such attributes to be > able to describe state (such as the floating-point environment) that > doesn't correspond to a C identifier. (errno tends to be a macro, so > referring to it as such in an attribute may be awkward as well.) We need some way to describe these things in Gimple and RTL as well, and not just on function calls: also on other expressions. Adding attributes that allow to describe this (partially, only per function) in C source code does not bring us closer to where we need to be. Segher