From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106232 invoked by alias); 4 Dec 2018 18:42:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 106215 invoked by uid 89); 4 Dec 2018 18:42:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=2, 1, opened X-HELO: mail-qt1-f196.google.com Received: from mail-qt1-f196.google.com (HELO mail-qt1-f196.google.com) (209.85.160.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Dec 2018 18:42:42 +0000 Received: by mail-qt1-f196.google.com with SMTP id y20so19244505qtm.13 for ; Tue, 04 Dec 2018 10:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=CDPf9XhlmvqJHPShRK4Dq81p/+g5a2lUoYRPY5VJ4Bs=; b=J3Hi7tlMyXIhpKjqAWX70d3Xn6NlmSiQ2ld9gjGIUNsyfM+Kga2ZkSuTCgWFqtfLoC zRoHmMR3+MJQJ3LrnMjzLboMTl9152JZtVSp5YK0dpLw47VUZPK1DgpZOp1FwS4v3qYa XK3rFZ5VpeN5B5YnHrAl5qN7Xg6NrHeuuT7wus/a5ypHGubDvjC93/Uj7OPNBrnU7wz8 RAPVKNKpXZJtP/BhI/OhMfxE92hGE/pV3rB+ViCzLQmcpzpxdkakCPyCQWlmhAczZ5Nf EEx6Gj5koHhp7+OXxs5uSsiWUy3CN9fgiqHunROKYjQaE6e9Ogi6sX+w2GUwdbIKTm56 3Jew== Return-Path: Received: from localhost.localdomain (97-118-99-160.hlrn.qwest.net. [97.118.99.160]) by smtp.gmail.com with ESMTPSA id z30sm12600854qtz.26.2018.12.04.10.42.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 10:42:39 -0800 (PST) Subject: Re: [doc PATCH] document when GCC ignores attribute aligned To: Sandra Loosemore , Jeff Law , Gcc Patch List References: <1b7d7cd7-065b-48bf-1693-33b69263a53e@codesourcery.com> From: Martin Sebor Message-ID: <28f9005d-0ba1-09f6-750c-4b5369b39751@gmail.com> Date: Tue, 04 Dec 2018 18:42:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <1b7d7cd7-065b-48bf-1693-33b69263a53e@codesourcery.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg00223.txt.bz2 On 12/4/18 12:20 AM, Sandra Loosemore wrote: > On 12/3/18 8:23 PM, Martin Sebor wrote: >> Last week we agreed to clarify that attribute aligned on a function >> can decrease its alignment if it hasn't been previously declared >> with one.  Attached is this change. >> >> Besides the above, I also mention that the attribute specifies >> the alignment of the first instruction of the function (in case >> that wasn't obvious) , and that it has no effect in the absence >> of a definition. >> >> I wrote some tests to convince myself this actually works as >> I expected.  Where it does I add those tests to the testsuite >> via this patch.  Where it doesn't I opened a bug (PR 88345). >> >> Martin > >> Index: gcc/doc/extend.texi >> =================================================================== >> --- gcc/doc/extend.texi    (revision 266766) >> +++ gcc/doc/extend.texi    (working copy) >> @@ -2386,16 +2386,20 @@ and may not be available on all targets. >>  @itemx aligned (@var{alignment}) >>  @cindex @code{aligned} function attribute >>  The @code{aligned} attribute specifies a minimum alignment for >> -the function, measured in bytes.  When specified, @var{alignment} must >> -be an integer constant power of 2.  Specifying no @var{alignment} >> argument >> -implies the maximum alignment for the target, which is often, but by no >> -means always, 8 or 16 bytes. >> +the first instruction of the function, measured in bytes.  When >> specified, >> +@var{alignment} must be an integer constant power of 2.  Specifying no >> +@var{alignment} argument implies the ideal alignment for the target, >> +which is often, but by no means always, 8 or 16 bytes.  The attribute > > I think you might as well delete the end of the sentence starting with > "which is often...".  It adds words but no useful information.  (Maybe > it's 8 bytes, maybe it's 16 bytes, maybe it's something else....) I added those words in r265498. I was hoping to give people an idea of roughly what they might expect because I couldn't think of a good way to find out. But since then I realized that the __alignof__ operator can be used to query this alignment and I agree that the sentence isn't helpful anymore (maybe it never really was). I've replaced it with a reference to __alignof__ instead and checked in r266792. Martin > >> +has no effect when a definition for the function is not provided in >> +the same translation unit. >> >> -You cannot use this attribute to decrease the alignment of a function, >> -only to increase it.  However, when you explicitly specify a function >> -alignment this overrides the effect of the >> -@option{-falign-functions} (@pxref{Optimize Options}) option for this >> -function. >> +The attribute cannot be used to decrease the alignment of a function >> +previously declared with a more restrictive alignment; only to increase >> +it.  Attempts to do otherwise are diagnosed.  Some targets specify >> +a minimum default alignment for functions that is greater than 1.  On >> +such targets, specifying a less restrictive alignment is silently >> ignored. >> +Using the attribute overrides the effect of the >> @option{-falign-functions} >> +(@pxref{Optimize Options}) option for this function. >> >>  Note that the effectiveness of @code{aligned} attributes may be >>  limited by inherent limitations in the system linker > > This patch is OK with the above nit fixed. > > -Sandra