From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95428 invoked by alias); 14 Aug 2015 08:02:54 -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 95357 invoked by uid 89); 14 Aug 2015 08:02:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 14 Aug 2015 08:02:50 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55438) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ZQ9wu-0008Nc-7t for gcc-patches@gnu.org; Fri, 14 Aug 2015 04:02:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQ9wt-0007Jv-2P for gcc-patches@gnu.org; Fri, 14 Aug 2015 04:02:47 -0400 Received: from mail-ig0-x22f.google.com ([2607:f8b0:4001:c05::22f]:36685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQ9ws-0007JQ-UH for gcc-patches@gnu.org; Fri, 14 Aug 2015 04:02:47 -0400 Received: by igxp17 with SMTP id p17so7244594igx.1 for ; Fri, 14 Aug 2015 01:02:46 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.128.169 with SMTP id np9mr1471837igb.37.1439539366486; Fri, 14 Aug 2015 01:02:46 -0700 (PDT) Received: by 10.107.32.140 with HTTP; Fri, 14 Aug 2015 01:02:46 -0700 (PDT) In-Reply-To: <55CD3EA1.1050104@gmail.com> References: <55CD3C87.40101@gmail.com> <55CD3EA1.1050104@gmail.com> Date: Fri, 14 Aug 2015 08:17:00 -0000 Message-ID: Subject: Re: [PATCH 2/2] Get rid of global state accesses in dominance.c From: Richard Biener To: Mikhail Maltsev Cc: gcc-patches , Jeff Law Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c05::22f X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00760.txt.bz2 On Fri, Aug 14, 2015 at 3:04 AM, Mikhail Maltsev wrote: > The second part removes all global state accesses (i.e. accesses to cfun and > it's members) from dominance.c. This requires to change lots of code, but I hope > that this is a step in right direction (if my understanding of ongoing > re-architecture w.r.t. to global state is correct). > > For now this second part lacks a changelog entry, but it's very "mechanical". I > will, of course, write it if the patch gets approved. So the last time I did similar refactoring I wondered if we can somehow avoid the "noise" in non-IPA passes. Ideas I came up with are a) Inherit gimple/rtl pass classes from a class which is initialized with the function the pass operates on and provides methods like bool dom_info_available_p (..) { return dom_info_available_p (fn, ...); } thus wraps APIs working on a specific function. b) Do sth similar but make it work with overloads and clever (no idea what!) C++ that disables them if this_fn cannot be looked up template bool dom_info_available_p (..., struct function *fn = this_fn); all of the above would of course require that passes make all their implementation be methods of their pass class. So even more refactoring. Note that we do not have any IPA pass which accesses dominators, so the implicit 'cfun' use was ok. The cases I refactored were those where we had to push/pop_cfun () in IPA passes (which can be expensive) because it used APIs with implicit cfun. Overall I'm not sure we want all APIs using 'cfun' to be refactored. It is after all useless noise to callers if all callers are effectively using 'cfun'. Refactoring APIs that are used from IPA and make push/pop_cfun necessary for them are another thing. (there are still plenty left I think) Richard. > -- > Regards, > Mikhail Maltsev