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/cfgloop.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/cfgloop.h')
-rw-r--r-- | gcc/cfgloop.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index e98ad06..e7ac2b5 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -280,21 +280,21 @@ public: #define LOOP_C_FINITE (1 << 1) /* Set C to the LOOP constraint. */ -static inline void +inline void loop_constraint_set (class loop *loop, unsigned c) { loop->constraints |= c; } /* Clear C from the LOOP constraint. */ -static inline void +inline void loop_constraint_clear (class loop *loop, unsigned c) { loop->constraints &= ~c; } /* Check if C is set in the LOOP constraint. */ -static inline bool +inline bool loop_constraint_set_p (class loop *loop, unsigned c) { return (loop->constraints & c) == c; @@ -508,7 +508,7 @@ extern void iv_analysis_done (void); extern class niter_desc *get_simple_loop_desc (class loop *loop); extern void free_simple_loop_desc (class loop *loop); -static inline class niter_desc * +inline class niter_desc * simple_loop_desc (class loop *loop) { return loop->simple_loop_desc; @@ -518,7 +518,7 @@ simple_loop_desc (class loop *loop) /* Returns the loop with index NUM from FNs loop tree. */ -static inline class loop * +inline class loop * get_loop (struct function *fn, unsigned num) { return (*loops_for_fn (fn)->larray)[num]; @@ -526,7 +526,7 @@ get_loop (struct function *fn, unsigned num) /* Returns the number of superloops of LOOP. */ -static inline unsigned +inline unsigned loop_depth (const class loop *loop) { return vec_safe_length (loop->superloops); @@ -535,7 +535,7 @@ loop_depth (const class loop *loop) /* Returns the immediate superloop of LOOP, or NULL if LOOP is the outermost loop. */ -static inline class loop * +inline class loop * loop_outer (const class loop *loop) { unsigned n = vec_safe_length (loop->superloops); @@ -548,7 +548,7 @@ loop_outer (const class loop *loop) /* Returns true if LOOP has at least one exit edge. */ -static inline bool +inline bool loop_has_exit_edges (const class loop *loop) { return loop->exits->next->e != NULL; @@ -569,7 +569,7 @@ get_loops (struct function *fn) /* Returns the number of loops in FN (including the removed ones and the fake loop that forms the root of the loop tree). */ -static inline unsigned +inline unsigned number_of_loops (struct function *fn) { struct loops *loops = loops_for_fn (fn); @@ -582,13 +582,13 @@ number_of_loops (struct function *fn) /* Returns true if state of the loops satisfies all properties described by FLAGS. */ -static inline bool +inline bool loops_state_satisfies_p (function *fn, unsigned flags) { return (loops_for_fn (fn)->state & flags) == flags; } -static inline bool +inline bool loops_state_satisfies_p (unsigned flags) { return loops_state_satisfies_p (cfun, flags); @@ -596,13 +596,13 @@ loops_state_satisfies_p (unsigned flags) /* Sets FLAGS to the loops state. */ -static inline void +inline void loops_state_set (function *fn, unsigned flags) { loops_for_fn (fn)->state |= flags; } -static inline void +inline void loops_state_set (unsigned flags) { loops_state_set (cfun, flags); @@ -610,13 +610,13 @@ loops_state_set (unsigned flags) /* Clears FLAGS from the loops state. */ -static inline void +inline void loops_state_clear (function *fn, unsigned flags) { loops_for_fn (fn)->state &= ~flags; } -static inline void +inline void loops_state_clear (unsigned flags) { if (!current_loops) @@ -627,7 +627,7 @@ loops_state_clear (unsigned flags) /* Check loop structure invariants, if internal consistency checks are enabled. */ -static inline void +inline void checking_verify_loop_structure (void) { /* VERIFY_LOOP_STRUCTURE essentially asserts that no loops need fixups. @@ -897,7 +897,7 @@ extern void move_loop_invariants (void); extern auto_vec<basic_block> get_loop_hot_path (const class loop *loop); /* Returns the outermost loop of the loop nest that contains LOOP.*/ -static inline class loop * +inline class loop * loop_outermost (class loop *loop) { unsigned n = vec_safe_length (loop->superloops); @@ -919,7 +919,7 @@ extern int bb_loop_depth (const_basic_block); /* Converts VAL to widest_int. */ -static inline widest_int +inline widest_int gcov_type_to_wide_int (gcov_type val) { HOST_WIDE_INT a[2]; |