diff options
author | Patrick Palka <ppalka@redhat.com> | 2023-02-16 10:30:20 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2023-02-16 10:30:20 -0500 |
commit | cb3e0eac262e55774949b1717c64da383adbc621 (patch) | |
tree | a86ae96b5585e5f6d6c86bf152bc621ae76d632d /gcc/rtl.h | |
parent | a5de17d9120dde7e6598a05ea4d1556c2783c69b (diff) | |
download | gcc-cb3e0eac262e55774949b1717c64da383adbc621.zip gcc-cb3e0eac262e55774949b1717c64da383adbc621.tar.gz gcc-cb3e0eac262e55774949b1717c64da383adbc621.tar.bz2 |
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 whose use predates our 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
sed -i 's/^static inline/inline/g' gcc/*.h gcc/*/*.h
There's also a manual change to remove the redundant declarations
of is_ivar and lookup_category in gcc/objc/objc-act.cc which would
otherwise conflict with their modified definitions 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.
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.
Diffstat (limited to 'gcc/rtl.h')
-rw-r--r-- | gcc/rtl.h | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -1895,7 +1895,7 @@ inline void rtx_jump_insn::set_jump_target (rtx_code_label *target) #define LABEL_REFS(LABEL) XCEXP (LABEL, 3, CODE_LABEL) /* Get the label that a LABEL_REF references. */ -static inline rtx_insn * +inline rtx_insn * label_ref_label (const_rtx ref) { return as_a<rtx_insn *> (XCEXP (ref, 0, LABEL_REF)); @@ -1903,7 +1903,7 @@ label_ref_label (const_rtx ref) /* Set the label that LABEL_REF ref refers to. */ -static inline void +inline void set_label_ref_label (rtx ref, rtx_insn *label) { XCEXP (ref, 0, LABEL_REF) = label; @@ -1926,14 +1926,14 @@ set_label_ref_label (rtx ref, rtx_insn *label) (RTL_FLAG_CHECK1 ("ORIGINAL_REGNO", (RTX), REG)->u2.original_regno) /* Force the REGNO macro to only be used on the lhs. */ -static inline unsigned int +inline unsigned int rhs_regno (const_rtx x) { return REG_CHECK (x)->regno; } /* Return the final register in REG X plus one. */ -static inline unsigned int +inline unsigned int END_REGNO (const_rtx x) { return REGNO (x) + REG_NREGS (x); @@ -1941,7 +1941,7 @@ END_REGNO (const_rtx x) /* Change the REGNO and REG_NREGS of REG X to the specified values, bypassing the df machinery. */ -static inline void +inline void set_regno_raw (rtx x, unsigned int regno, unsigned int nregs) { reg_info *reg = REG_CHECK (x); @@ -2058,7 +2058,7 @@ const_vector_encoded_nelts (const_rtx x) /* Return true if CODE always has VOIDmode. */ -static inline bool +inline bool always_void_p (enum rtx_code code) { return code == SET; @@ -2073,7 +2073,7 @@ struct full_rtx_costs }; /* Initialize a full_rtx_costs structure C to the maximum cost. */ -static inline void +inline void init_costs_to_max (struct full_rtx_costs *c) { c->speed = MAX_COST; @@ -2081,7 +2081,7 @@ init_costs_to_max (struct full_rtx_costs *c) } /* Initialize a full_rtx_costs structure C to zero cost. */ -static inline void +inline void init_costs_to_zero (struct full_rtx_costs *c) { c->speed = 0; @@ -2090,7 +2090,7 @@ init_costs_to_zero (struct full_rtx_costs *c) /* Compare two full_rtx_costs structures A and B, returning true if A < B when optimizing for speed. */ -static inline bool +inline bool costs_lt_p (struct full_rtx_costs *a, struct full_rtx_costs *b, bool speed) { @@ -2104,7 +2104,7 @@ costs_lt_p (struct full_rtx_costs *a, struct full_rtx_costs *b, /* Increase both members of the full_rtx_costs structure C by the cost of N insns. */ -static inline void +inline void costs_add_n_insns (struct full_rtx_costs *c, int n) { c->speed += COSTS_N_INSNS (n); @@ -2168,7 +2168,7 @@ subreg_shape::unique_id () const /* Return the shape of a SUBREG rtx. */ -static inline subreg_shape +inline subreg_shape shape_of_subreg (const_rtx x) { return subreg_shape (GET_MODE (SUBREG_REG (x)), @@ -2919,7 +2919,7 @@ extern int currently_expanding_to_rtl; /* Return the cost of SET X. SPEED_P is true if optimizing for speed rather than size. */ -static inline int +inline int set_rtx_cost (rtx x, bool speed_p) { return rtx_cost (x, VOIDmode, INSN, 4, speed_p); @@ -2927,7 +2927,7 @@ set_rtx_cost (rtx x, bool speed_p) /* Like set_rtx_cost, but return both the speed and size costs in C. */ -static inline void +inline void get_full_set_rtx_cost (rtx x, struct full_rtx_costs *c) { get_full_rtx_cost (x, VOIDmode, INSN, 4, c); @@ -2937,7 +2937,7 @@ get_full_set_rtx_cost (rtx x, struct full_rtx_costs *c) of a register move. SPEED_P is true if optimizing for speed rather than size. */ -static inline int +inline int set_src_cost (rtx x, machine_mode mode, bool speed_p) { return rtx_cost (x, mode, SET, 1, speed_p); @@ -2945,7 +2945,7 @@ set_src_cost (rtx x, machine_mode mode, bool speed_p) /* Like set_src_cost, but return both the speed and size costs in C. */ -static inline void +inline void get_full_set_src_cost (rtx x, machine_mode mode, struct full_rtx_costs *c) { get_full_rtx_cost (x, mode, SET, 1, c); @@ -3947,7 +3947,7 @@ extern struct target_rtl *this_target_rtl; #ifndef GENERATOR_FILE /* Return the attributes of a MEM rtx. */ -static inline const class mem_attrs * +inline const class mem_attrs * get_mem_attrs (const_rtx x) { class mem_attrs *attrs; @@ -3996,7 +3996,7 @@ extern rtx gen_rtx_VAR_LOCATION (machine_mode, tree, rtx, #ifdef GENERATOR_FILE #define PUT_MODE(RTX, MODE) PUT_MODE_RAW (RTX, MODE) #else -static inline void +inline void PUT_MODE (rtx x, machine_mode mode) { if (REG_P (x)) |