From owner-freebsd-hackers@freebsd.org Mon Jun 5 04:08:49 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD4EEBF60EC for ; Mon, 5 Jun 2017 04:08:49 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm2-vm5.bullet.mail.ne1.yahoo.com (nm2-vm5.bullet.mail.ne1.yahoo.com [98.138.91.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9101F6FA74 for ; Mon, 5 Jun 2017 04:08:49 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1496635723; bh=Q3d68+5Z53Jry3Ab2nsu9Wp3qVNc95dK0a0mMcQuo5s=; h=To:From:Subject:Cc:Date:From:Subject; b=i0YhoevY1BUNF3kF3BJgNbB5Fx/hG8UqICsk2Eu8zV1IGwhJRrw86QRbrc4BI88Km6NB1Nafu+/igFS/wIfGP2MbCt4854PPfqslWiQdDAhfjpMC56g2Mr4+i2VibjeXGjsl3iQI5zFFGx2MnRYXQCjbYQFmyclYqF62fOTtc1aXYQ1o52dPfNmkYtQ3SvGW/YbpGqvT+vZB72i21D5gi5AZHQ09I0V1NRdFT95fxGnhE89GBKAZa7sB67WResjpgEJWD6uNFfK5AYtqom+Kj0QkDOyLGyD2WL+reSmdYS2TxDBcz+EHbyG6g384XWuliD6+k/tp34Q4URw3g7KFEw== Received: from [98.138.100.115] by nm2.bullet.mail.ne1.yahoo.com with NNFMP; 05 Jun 2017 04:08:43 -0000 Received: from [98.138.84.46] by tm106.bullet.mail.ne1.yahoo.com with NNFMP; 05 Jun 2017 04:08:43 -0000 Received: from [127.0.0.1] by smtp114.mail.ne1.yahoo.com with NNFMP; 05 Jun 2017 04:08:43 -0000 X-Yahoo-Newman-Id: 466092.92973.bm@smtp114.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: yP8ewOYVM1ntN5MnLpPqPBuw9hF3dMO0EjW1rT8FJSHZcL3 _u11WKdNXC84kiIRdHoROKtwFW7bsmSH29rtYWLqc0bwbxqjkFgG3MzNsjAn bnslAo9b8p9Ejn4ANjw3iulV1zqS8BIOPV.y3BRD8OyHD15dQ523KajXHVbY ge1AJa05HFyGgmzgYuD9ESHOEi8PFWcvt53IQzqrMw5iEETMcyCn0mfHc4Uv z2BUZpQgricDeodW_ckahUmGo9b58QATXskHcjTgyYn.CrRzhH.0zNXjP3M3 F38lrLTi6ZClIuxBUFSlE.D.1E6Rs7SDtX4nwz7mnYEhyykucLmXruqI_xgw QyDMqS76xmfamx4iy8cKMVCiWDP_DjleDr.q.X7z5nYBORoAtS8kTEI1Iawc 0zdompJ3s.uPHyMmbULS_wXdladur.7YpZnYrkWwoVT9hebEursCsmGuARml Wv1O5zDtdEodxPL.i40RuyXhs29E.wzNTn1Wlp4yjWEvgSWAjxHhCDXORSuh gk30YFF9BT7t8tuPcmdJk4tFMg3QdaDGVcx8M30bn_CrN X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf To: Eric van Gyzen From: Pedro Giffuni Subject: Re: Function attribute for optimization level Organization: FreeBSD Project Cc: FreeBSD Hackers Message-ID: Date: Sun, 4 Jun 2017 23:08:42 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jun 2017 04:08:49 -0000 Hi Eric; It is a good idea : the nonopt attribute is useful in parts of the boot loader and probably in security-related functions. > diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h > index 9cdc03c861cb..e370f6d6459e 100644 > --- a/sys/sys/cdefs.h > +++ b/sys/sys/cdefs.h > @@ -396,6 +396,14 @@ > #define __unreachable() ((void)0) > #endif > > +#if __has_attribute(optnone) > +#define __no_optimization __attribute__((optnone)) > +#elif __has_attribute(optimize) > +#define __no_optimization __attribute__((optimize(0))) > +#else > +#define __no_optimization > +#endif I think the second one is wrong though: 'optimize' doesn't appear to be a valid clang attribute. GCC uses an optimize("O0") pragma, but it is not an attribute and __has_attribute doesn't work for GCC anyways. AFAICT there is no equivalent declaration in either Darwin or bionic: the rest of the BSDs are still GCC-centric. The location of the declaration is fine, although being a clang-only attribute you could place it later in the header, perhaps just before the nullability attributes. Regards, Pedro.