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/data-streamer.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/data-streamer.h')
-rw-r--r-- | gcc/data-streamer.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h index c91c5ab..d8c7e21 100644 --- a/gcc/data-streamer.h +++ b/gcc/data-streamer.h @@ -91,7 +91,7 @@ wide_int streamer_read_wide_int (class lto_input_block *); widest_int streamer_read_widest_int (class lto_input_block *); /* Returns a new bit-packing context for bit-packing into S. */ -static inline struct bitpack_d +inline struct bitpack_d bitpack_create (struct lto_output_stream *s) { struct bitpack_d bp; @@ -102,7 +102,7 @@ bitpack_create (struct lto_output_stream *s) } /* Pack the NBITS bit sized value VAL into the bit-packing context BP. */ -static inline void +inline void bp_pack_value (struct bitpack_d *bp, bitpack_word_t val, unsigned nbits) { bitpack_word_t word = bp->word; @@ -132,7 +132,7 @@ bp_pack_value (struct bitpack_d *bp, bitpack_word_t val, unsigned nbits) /* Pack VAL into the bit-packing context BP, using NBITS for each coefficient. */ -static inline void +inline void bp_pack_poly_value (struct bitpack_d *bp, const poly_int<NUM_POLY_INT_COEFFS, bitpack_word_t> &val, unsigned nbits) @@ -142,7 +142,7 @@ bp_pack_poly_value (struct bitpack_d *bp, } /* Finishes bit-packing of BP. */ -static inline void +inline void streamer_write_bitpack (struct bitpack_d *bp) { streamer_write_uhwi_stream ((struct lto_output_stream *) bp->stream, @@ -152,7 +152,7 @@ streamer_write_bitpack (struct bitpack_d *bp) } /* Returns a new bit-packing context for bit-unpacking from IB. */ -static inline struct bitpack_d +inline struct bitpack_d streamer_read_bitpack (class lto_input_block *ib) { struct bitpack_d bp; @@ -163,7 +163,7 @@ streamer_read_bitpack (class lto_input_block *ib) } /* Unpacks NBITS bits from the bit-packing context BP and returns them. */ -static inline bitpack_word_t +inline bitpack_word_t bp_unpack_value (struct bitpack_d *bp, unsigned nbits) { bitpack_word_t mask, val; @@ -191,7 +191,7 @@ bp_unpack_value (struct bitpack_d *bp, unsigned nbits) /* Unpacks a polynomial value from the bit-packing context BP in which each coefficient has NBITS bits. */ -static inline poly_int<NUM_POLY_INT_COEFFS, bitpack_word_t> +inline poly_int<NUM_POLY_INT_COEFFS, bitpack_word_t> bp_unpack_poly_value (struct bitpack_d *bp, unsigned nbits) { poly_int_pod<NUM_POLY_INT_COEFFS, bitpack_word_t> x; @@ -203,7 +203,7 @@ bp_unpack_poly_value (struct bitpack_d *bp, unsigned nbits) /* Write a character to the output block. */ -static inline void +inline void streamer_write_char_stream (struct lto_output_stream *obs, char c) { /* No space left. */ @@ -221,7 +221,7 @@ streamer_write_char_stream (struct lto_output_stream *obs, char c) /* Read byte from the input block. */ -static inline unsigned char +inline unsigned char streamer_read_uchar (class lto_input_block *ib) { if (ib->p >= ib->len) @@ -233,7 +233,7 @@ streamer_read_uchar (class lto_input_block *ib) to be compile time constant. Be host independent, limit range to 31bits. */ -static inline void +inline void streamer_write_hwi_in_range (struct lto_output_stream *obs, HOST_WIDE_INT min, HOST_WIDE_INT max, @@ -251,7 +251,7 @@ streamer_write_hwi_in_range (struct lto_output_stream *obs, /* Input VAL into OBS and verify it is in range MIN...MAX that is supposed to be compile time constant. PURPOSE is used for error reporting. */ -static inline HOST_WIDE_INT +inline HOST_WIDE_INT streamer_read_hwi_in_range (class lto_input_block *ib, const char *purpose, HOST_WIDE_INT min, @@ -272,7 +272,7 @@ streamer_read_hwi_in_range (class lto_input_block *ib, to be compile time constant. Be host independent, limit range to 31bits. */ -static inline void +inline void bp_pack_int_in_range (struct bitpack_d *bp, HOST_WIDE_INT min, HOST_WIDE_INT max, @@ -291,7 +291,7 @@ bp_pack_int_in_range (struct bitpack_d *bp, /* Input VAL into BP and verify it is in range MIN...MAX that is supposed to be compile time constant. PURPOSE is used for error reporting. */ -static inline HOST_WIDE_INT +inline HOST_WIDE_INT bp_unpack_int_in_range (struct bitpack_d *bp, const char *purpose, HOST_WIDE_INT min, @@ -332,7 +332,7 @@ bp_unpack_int_in_range (struct bitpack_d *bp, /* Output the start of a record with TAG to output block OB. */ -static inline void +inline void streamer_write_record_start (struct output_block *ob, enum LTO_tags tag) { streamer_write_enum (ob->main_stream, LTO_tags, LTO_NUM_TAGS, tag); @@ -340,7 +340,7 @@ streamer_write_record_start (struct output_block *ob, enum LTO_tags tag) /* Return the next tag in the input block IB. */ -static inline enum LTO_tags +inline enum LTO_tags streamer_read_record_start (class lto_input_block *ib) { return streamer_read_enum (ib, LTO_tags, LTO_NUM_TAGS); |