From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119737 invoked by alias); 22 Jun 2016 02:55:38 -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 119669 invoked by uid 89); 22 Jun 2016 02:55:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 22 Jun 2016 02:55:18 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3596F3B730; Wed, 22 Jun 2016 02:55:17 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-31.rdu2.redhat.com [10.10.116.31]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5M2tFji001663; Tue, 21 Jun 2016 22:55:16 -0400 Subject: Re: [PATCH 1/2] gcc: Remove unneeded global flag. To: Andrew Burgess , gcc-patches@gcc.gnu.org References: From: Jeff Law Message-ID: <512a967c-39c4-44f5-6f24-d75ef543979d@redhat.com> Date: Wed, 22 Jun 2016 02:55:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg01561.txt.bz2 On 06/10/2016 10:56 AM, Andrew Burgess wrote: > The global flag `user_defined_section_attribute' is set while parsing C > code when the section attribute is encountered. The flag is set when > anything has the section attribute applied to it, functions or data. > > The only place this global was used was within the gate function for > partitioning blocks (pass_partition_blocks::gate), however, the > partitioning is done during compilation, while the flag is set earlier, > during the parsing. The flag is then cleared again during the final > compilation pass. > > The result is that if any function or data has a section attribute then > the flag will be set to true during the file parse pass. The first > compiled function will then skip the partition-blocks pass, and the flag > will be set back to false during the final-pass on the first function. > After then, the flag is never set to true again. > > The guarding of the partition-blocks pass does not appear to be > necessary, given that applying a section attribute correctly > overrides the hot/cold section partitioning (this is taken care if in > varasm.c). > > gcc/ChangeLog: > > * gcc/bb-reorder.c: Remove 'toplev.h' include. > (pass_partition_blocks::gate): No longer check > user_defined_section_attribute. > * gcc/c-family/c-common.c (handle_section_attribute): No longer > set user_defined_section_attribute. > * gcc/final.c (rest_of_handle_final): Likewise. > * gcc/toplev.c: Remove definition of user_defined_section_attribute. > * gcc/toplev.h: Remove declaration of > user_defined_section_attribute. user_defined_section_attribute was introduced as part of the hot/cold partitioning changes. https://gcc.gnu.org/ml/gcc-patches/2004-07/msg01545.html What's supposed to happen is hot/cold partitioning is supposed to be turned off for the function which has the a user defined section attribute. So proper behaviour is to set the flag to true when the attribute is parsed and turn it off when we're finished with the current function. The gate for hot/cold partitioning should check the value of the flag and avoid hot/cold partitioning when the flag is true. So AFAICT everything is working as it should. Keep in mind that multiple functions might have user defined section attributes. So what might be better to do here is introduce a test to verify proper behavior. Jeff