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/tree-vectorizer.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/tree-vectorizer.h')
-rw-r--r-- | gcc/tree-vectorizer.h | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 4ba6537..9cf2fb2 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -969,7 +969,7 @@ public: stack. */ typedef opt_pointer_wrapper <loop_vec_info> opt_loop_vec_info; -static inline loop_vec_info +inline loop_vec_info loop_vec_info_for_loop (class loop *loop) { return (loop_vec_info) loop->aux; @@ -1641,7 +1641,7 @@ vector_costs::suggested_unroll_factor () const && TYPE_PRECISION (TYPE) == 1 \ && TYPE_UNSIGNED (TYPE))) -static inline bool +inline bool nested_in_vect_loop_p (class loop *loop, stmt_vec_info stmt_info) { return (loop->inner @@ -1652,7 +1652,7 @@ nested_in_vect_loop_p (class loop *loop, stmt_vec_info stmt_info) Return the initial value of the variable on entry to the containing loop. */ -static inline tree +inline tree vect_phi_initial_value (gphi *phi) { basic_block bb = gimple_bb (phi); @@ -1664,7 +1664,7 @@ vect_phi_initial_value (gphi *phi) /* Return true if STMT_INFO should produce a vector mask type rather than a normal nonmask type. */ -static inline bool +inline bool vect_use_mask_type_p (stmt_vec_info stmt_info) { return stmt_info->mask_precision && stmt_info->mask_precision != ~0U; @@ -1673,7 +1673,7 @@ vect_use_mask_type_p (stmt_vec_info stmt_info) /* Return TRUE if a statement represented by STMT_INFO is a part of a pattern. */ -static inline bool +inline bool is_pattern_stmt_p (stmt_vec_info stmt_info) { return stmt_info->pattern_stmt_p; @@ -1692,7 +1692,7 @@ vect_orig_stmt (stmt_vec_info stmt_info) /* Return the later statement between STMT1_INFO and STMT2_INFO. */ -static inline stmt_vec_info +inline stmt_vec_info get_later_stmt (stmt_vec_info stmt1_info, stmt_vec_info stmt2_info) { if (gimple_uid (vect_orig_stmt (stmt1_info)->stmt) @@ -1715,7 +1715,7 @@ vect_stmt_to_vectorize (stmt_vec_info stmt_info) /* Return true if BB is a loop header. */ -static inline bool +inline bool is_loop_header_bb_p (basic_block bb) { if (bb == (bb->loop_father)->header) @@ -1726,7 +1726,7 @@ is_loop_header_bb_p (basic_block bb) /* Return pow2 (X). */ -static inline int +inline int vect_pow2 (int x) { int i, res = 1; @@ -1739,7 +1739,7 @@ vect_pow2 (int x) /* Alias targetm.vectorize.builtin_vectorization_cost. */ -static inline int +inline int builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, tree vectype, int misalign) { @@ -1749,7 +1749,7 @@ builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, /* Get cost by calling cost target builtin. */ -static inline +inline int vect_get_stmt_cost (enum vect_cost_for_stmt type_of_cost) { return builtin_vectorization_cost (type_of_cost, NULL, 0); @@ -1757,7 +1757,7 @@ int vect_get_stmt_cost (enum vect_cost_for_stmt type_of_cost) /* Alias targetm.vectorize.init_cost. */ -static inline vector_costs * +inline vector_costs * init_cost (vec_info *vinfo, bool costing_for_scalar) { return targetm.vectorize.create_costs (vinfo, costing_for_scalar); @@ -1769,7 +1769,7 @@ extern void dump_stmt_cost (FILE *, int, enum vect_cost_for_stmt, /* Alias targetm.vectorize.add_stmt_cost. */ -static inline unsigned +inline unsigned add_stmt_cost (vector_costs *costs, int count, enum vect_cost_for_stmt kind, stmt_vec_info stmt_info, slp_tree node, @@ -1784,7 +1784,7 @@ add_stmt_cost (vector_costs *costs, int count, return cost; } -static inline unsigned +inline unsigned add_stmt_cost (vector_costs *costs, int count, enum vect_cost_for_stmt kind, enum vect_cost_model_location where) { @@ -1795,7 +1795,7 @@ add_stmt_cost (vector_costs *costs, int count, enum vect_cost_for_stmt kind, /* Alias targetm.vectorize.add_stmt_cost. */ -static inline unsigned +inline unsigned add_stmt_cost (vector_costs *costs, stmt_info_for_cost *i) { return add_stmt_cost (costs, i->count, i->kind, i->stmt_info, i->node, @@ -1804,7 +1804,7 @@ add_stmt_cost (vector_costs *costs, stmt_info_for_cost *i) /* Alias targetm.vectorize.finish_cost. */ -static inline void +inline void finish_cost (vector_costs *costs, const vector_costs *scalar_costs, unsigned *prologue_cost, unsigned *body_cost, unsigned *epilogue_cost, unsigned *suggested_unroll_factor = NULL) @@ -1845,7 +1845,7 @@ extern int dr_misalignment (dr_vec_info *dr_info, tree vectype, #define SET_DR_MISALIGNMENT(DR, VAL) set_dr_misalignment (DR, VAL) /* Only defined once DR_MISALIGNMENT is defined. */ -static inline const poly_uint64 +inline const poly_uint64 dr_target_alignment (dr_vec_info *dr_info) { if (STMT_VINFO_GROUPED_ACCESS (dr_info->stmt)) @@ -1854,7 +1854,7 @@ dr_target_alignment (dr_vec_info *dr_info) } #define DR_TARGET_ALIGNMENT(DR) dr_target_alignment (DR) -static inline void +inline void set_dr_target_alignment (dr_vec_info *dr_info, poly_uint64 val) { dr_info->target_alignment = val; @@ -1864,7 +1864,7 @@ set_dr_target_alignment (dr_vec_info *dr_info, poly_uint64 val) /* Return true if data access DR_INFO is aligned to the targets preferred alignment for VECTYPE (which may be less than a full vector). */ -static inline bool +inline bool aligned_access_p (dr_vec_info *dr_info, tree vectype) { return (dr_misalignment (dr_info, vectype) == 0); @@ -1874,7 +1874,7 @@ aligned_access_p (dr_vec_info *dr_info, tree vectype) respect to the targets preferred alignment for VECTYPE, and FALSE otherwise. */ -static inline bool +inline bool known_alignment_for_access_p (dr_vec_info *dr_info, tree vectype) { return (dr_misalignment (dr_info, vectype) != DR_MISALIGNMENT_UNKNOWN); @@ -1883,7 +1883,7 @@ known_alignment_for_access_p (dr_vec_info *dr_info, tree vectype) /* Return the minimum alignment in bytes that the vectorized version of DR_INFO is guaranteed to have. */ -static inline unsigned int +inline unsigned int vect_known_alignment_in_bytes (dr_vec_info *dr_info, tree vectype) { int misalignment = dr_misalignment (dr_info, vectype); @@ -1898,7 +1898,7 @@ vect_known_alignment_in_bytes (dr_vec_info *dr_info, tree vectype) (which for outer loop vectorization might not be the behavior recorded in DR_INFO itself). */ -static inline innermost_loop_behavior * +inline innermost_loop_behavior * vect_dr_behavior (vec_info *vinfo, dr_vec_info *dr_info) { stmt_vec_info stmt_info = dr_info->stmt; @@ -1936,7 +1936,7 @@ get_dr_vinfo_offset (vec_info *vinfo, /* Return the vect cost model for LOOP. */ -static inline enum vect_cost_model +inline enum vect_cost_model loop_cost_model (loop_p loop) { if (loop != NULL @@ -1947,7 +1947,7 @@ loop_cost_model (loop_p loop) } /* Return true if the vect cost model is unlimited. */ -static inline bool +inline bool unlimited_cost_model (loop_p loop) { return loop_cost_model (loop) == VECT_COST_MODEL_UNLIMITED; @@ -1957,7 +1957,7 @@ unlimited_cost_model (loop_p loop) if the first iteration should use a partial mask in order to achieve alignment. */ -static inline bool +inline bool vect_use_loop_mask_for_alignment_p (loop_vec_info loop_vinfo) { return (LOOP_VINFO_FULLY_MASKED_P (loop_vinfo) @@ -1968,7 +1968,7 @@ vect_use_loop_mask_for_alignment_p (loop_vec_info loop_vinfo) NUNITS elements. NUNITS should be based on the vectorization factor, so it is always a known multiple of the number of elements in VECTYPE. */ -static inline unsigned int +inline unsigned int vect_get_num_vectors (poly_uint64 nunits, tree vectype) { return exact_div (nunits, TYPE_VECTOR_SUBPARTS (vectype)).to_constant (); @@ -1979,7 +1979,7 @@ vect_get_num_vectors (poly_uint64 nunits, tree vectype) vectorization factor divided by the number of elements in VECTYPE and is always known at compile time. */ -static inline unsigned int +inline unsigned int vect_get_num_copies (loop_vec_info loop_vinfo, tree vectype) { return vect_get_num_vectors (LOOP_VINFO_VECT_FACTOR (loop_vinfo), vectype); @@ -1988,7 +1988,7 @@ vect_get_num_copies (loop_vec_info loop_vinfo, tree vectype) /* Update maximum unit count *MAX_NUNITS so that it accounts for NUNITS. *MAX_NUNITS can be 1 if we haven't yet recorded anything. */ -static inline void +inline void vect_update_max_nunits (poly_uint64 *max_nunits, poly_uint64 nunits) { /* All unit counts have the form vec_info::vector_size * X for some @@ -2001,7 +2001,7 @@ vect_update_max_nunits (poly_uint64 *max_nunits, poly_uint64 nunits) the number of units in vector type VECTYPE. *MAX_NUNITS can be 1 if we haven't yet recorded any vector types. */ -static inline void +inline void vect_update_max_nunits (poly_uint64 *max_nunits, tree vectype) { vect_update_max_nunits (max_nunits, TYPE_VECTOR_SUBPARTS (vectype)); @@ -2012,7 +2012,7 @@ vect_update_max_nunits (poly_uint64 *max_nunits, tree vectype) Pick a reasonable estimate if the vectorization factor isn't known at compile time. */ -static inline unsigned int +inline unsigned int vect_vf_for_cost (loop_vec_info loop_vinfo) { return estimated_poly_value (LOOP_VINFO_VECT_FACTOR (loop_vinfo)); @@ -2022,7 +2022,7 @@ vect_vf_for_cost (loop_vec_info loop_vinfo) Pick a reasonable estimate if the exact number isn't known at compile time. */ -static inline unsigned int +inline unsigned int vect_nunits_for_cost (tree vec_type) { return estimated_poly_value (TYPE_VECTOR_SUBPARTS (vec_type)); @@ -2030,7 +2030,7 @@ vect_nunits_for_cost (tree vec_type) /* Return the maximum possible vectorization factor for LOOP_VINFO. */ -static inline unsigned HOST_WIDE_INT +inline unsigned HOST_WIDE_INT vect_max_vf (loop_vec_info loop_vinfo) { unsigned HOST_WIDE_INT vf; @@ -2160,7 +2160,7 @@ extern unsigned record_stmt_cost (stmt_vector_for_cost *, int, /* Overload of record_stmt_cost with VECTYPE derived from STMT_INFO. */ -static inline unsigned +inline unsigned record_stmt_cost (stmt_vector_for_cost *body_cost_vec, int count, enum vect_cost_for_stmt kind, stmt_vec_info stmt_info, int misalign, enum vect_cost_model_location where) |