From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D47A93854811 for ; Thu, 16 Feb 2023 13:50:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D47A93854811 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676555417; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=vYUdykQwZ4GWtbLKY+ZMFwbSMdy1vsAksn0yp4seabM=; b=dIUQ+ChL58j9oQf5HigDvTFKiRe7HWjfprL5d3LIk5WtgER74LgUUZrnY0e0jMyCfz37RL GHZS8NoAgk2T6rkRl0inHHOBIdfW6kVGQ3VjXLhXSOtDsRynjP1H0MTmNsXQtxAQpUasBc x2Yfh/sBbzfnLLzK3NtzJQ7S7imskLE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-452--IrMj7KwMYGiXbyO-7DMdA-1; Thu, 16 Feb 2023 08:50:13 -0500 X-MC-Unique: -IrMj7KwMYGiXbyO-7DMdA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D918F185A794; Thu, 16 Feb 2023 13:50:12 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.211]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 956D1C15BA0; Thu, 16 Feb 2023 13:50:12 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 31GDo99S2906004 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 14:50:10 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 31GDo9Vg2906002; Thu, 16 Feb 2023 14:50:09 +0100 Date: Thu, 16 Feb 2023 14:50:08 +0100 From: Jakub Jelinek To: Patrick Palka Cc: Richard Biener , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] don't declare header-defined functions both static and inline Message-ID: Reply-To: Jakub Jelinek References: <20230131033707.2597685-1-ppalka@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Feb 16, 2023 at 08:37:34AM -0500, Patrick Palka wrote: > I can confirm that this patch only modifies headers that reside in > $prefix/lib/gcc/x86_64-pc-linux-gnu/13.0.1/plugin/include/ > (with --enable-languages=c,c++,fortran,objc,obj-c++ --enable-jit make install) > > Good point, I was able to scrape the functions modified by this patch > with the below shell script which outputs the name of each function that > has at least two overloads/definitions (possibly in different headers), > followed by the headers in which it's defined: > > I manually verified that none of these function definitions conflict > with each other. > Bootstrapping with objc enabled revealed a minor manual changed was > needed in gcc/objc/objc-act.cc to avoid a redeclaration mismatch error. > > -- >8 -- > > Subject: [PATCH] don't declare header-defined functions both static and inline > > Many functions defined in our headers are declared 'static inline' which > is a C idiom that predates GCC's move to C++ as the implementation > language. But in C++ the inline keyword is more than just a compiler > hint, and is sufficient to give the function the intended semantics. > In fact declaring a function both static and inline is a pessimization > since static effectively disables the desired definition merging > behavior enabled by inline, and is also a source of (harmless) ODR > violations when a static inline function gets called from a non-static > inline one (such as tree_operand_check calling tree_operand_length). > > This patch mechanically fixes the vast majority of occurrences of this > anti-pattern throughout the compiler's headers via the command line > > echo gcc/*.h gcc/*/*.h | xargs sed -i 's/^static inline/inline/g' > > The patch also manually removes the redundant declarations of is_ivar > and lookup_category in gcc/objc/objc-act.cc which would otherwise > conflict with those in objc-act.h (due to the difference in staticness). > > Besides fixing some ODR violations, this speeds up stage1 cc1plus by > about 2% and reduces the size of its text segment by 1.5MB. Thanks for doing the extra work, LGTM for trunk then. > gcc/ChangeLog: > > * addresses.h: Mechanically drop 'static' from 'static inline' > functions via s/^static inline/inline/g. > * asan.h: Likewise. > * attribs.h: Likewise. > * basic-block.h: Likewise. > * bitmap.h: Likewise. > * cfghooks.h: Likewise. > * cfgloop.h: Likewise. > * cgraph.h: Likewise. > * cselib.h: Likewise. > * data-streamer.h: Likewise. > * debug.h: Likewise. > * df.h: Likewise. > * diagnostic.h: Likewise. > * dominance.h: Likewise. > * dumpfile.h: Likewise. > * emit-rtl.h: Likewise. > * except.h: Likewise. > * expmed.h: Likewise. > * expr.h: Likewise. > * fixed-value.h: Likewise. > * gengtype.h: Likewise. > * gimple-expr.h: Likewise. > * gimple-iterator.h: Likewise. > * gimple-predict.h: Likewise. > * gimple-range-fold.h: Likewise. > * gimple-ssa.h: Likewise. > * gimple.h: Likewise. > * graphite.h: Likewise. > * hard-reg-set.h: Likewise. > * hash-map.h: Likewise. > * hash-set.h: Likewise. > * hash-table.h: Likewise. > * hwint.h: Likewise. > * input.h: Likewise. > * insn-addr.h: Likewise. > * internal-fn.h: Likewise. > * ipa-fnsummary.h: Likewise. > * ipa-icf-gimple.h: Likewise. > * ipa-inline.h: Likewise. > * ipa-modref.h: Likewise. > * ipa-prop.h: Likewise. > * ira-int.h: Likewise. > * ira.h: Likewise. > * lra-int.h: Likewise. > * lra.h: Likewise. > * lto-streamer.h: Likewise. > * memmodel.h: Likewise. > * omp-general.h: Likewise. > * optabs-query.h: Likewise. > * optabs.h: Likewise. > * plugin.h: Likewise. > * pretty-print.h: Likewise. > * range.h: Likewise. > * read-md.h: Likewise. > * recog.h: Likewise. > * regs.h: Likewise. > * rtl-iter.h: Likewise. > * rtl.h: Likewise. > * sbitmap.h: Likewise. > * sched-int.h: Likewise. > * sel-sched-ir.h: Likewise. > * sese.h: Likewise. > * sparseset.h: Likewise. > * ssa-iterators.h: Likewise. > * system.h: Likewise. > * target-globals.h: Likewise. > * target.h: Likewise. > * timevar.h: Likewise. > * tree-chrec.h: Likewise. > * tree-data-ref.h: Likewise. > * tree-iterator.h: Likewise. > * tree-outof-ssa.h: Likewise. > * tree-phinodes.h: Likewise. > * tree-scalar-evolution.h: Likewise. > * tree-sra.h: Likewise. > * tree-ssa-alias.h: Likewise. > * tree-ssa-live.h: Likewise. > * tree-ssa-loop-manip.h: Likewise. > * tree-ssa-loop.h: Likewise. > * tree-ssa-operands.h: Likewise. > * tree-ssa-propagate.h: Likewise. > * tree-ssa-sccvn.h: Likewise. > * tree-ssa.h: Likewise. > * tree-ssanames.h: Likewise. > * tree-streamer.h: Likewise. > * tree-switch-conversion.h: Likewise. > * tree-vectorizer.h: Likewise. > * tree.h: Likewise. > * wide-int.h: Likewise. > > gcc/c-family/ChangeLog: > > * c-common.h: Mechanically drop static from static inline > functions via s/^static inline/inline/g. > > gcc/c/ChangeLog: > > * c-parser.h: Mechanically drop static from static inline > functions via s/^static inline/inline/g. > > gcc/cp/ChangeLog: > > * cp-tree.h: Mechanically drop static from static inline > functions via s/^static inline/inline/g. > > gcc/fortran/ChangeLog: > > * gfortran.h: Mechanically drop static from static inline > functions via s/^static inline/inline/g. > > gcc/jit/ChangeLog: > > * jit-dejagnu.h: Mechanically drop static from static inline > functions via s/^static inline/inline/g. > * jit-recording.h: Likewise. > > gcc/objc/ChangeLog: > > * objc-act.h: Mechanically drop static from static inline > functions via s/^static inline/inline/g. > * objc-map.h: Likewise. > * objc-act.cc: Remove the redundant redeclarations of is_ivar > and lookup_category. Jakub