riscv_ext_info_t::implied_exts() returns its std::vector member by
value, but all three callers (check_implied_ext, handle_combine_ext,
riscv_minimal_hwprobe_feature_bits) only iterate over the result and
never need ownership.  Every invocation therefore copies the entire
implied-extension vector.  During option parsing this runs once per
compiled source file; at -O0 the optimisation passes are skipped so
option-parsing overhead dominates, causing a 6.7% compile-time
regression on CSIBE -O0 benchmarks.

Return a const reference instead.  The underlying m_implied_exts
member lives in a static global map entry and outlives every caller,
so no dangling-reference risk exists.

gcc/ChangeLog:

        * common/config/riscv/riscv-common.cc
        (riscv_ext_info_t::implied_exts): Return const reference
        instead of by-value copy.
---
 gcc/common/config/riscv/riscv-common.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/common/config/riscv/riscv-common.cc 
b/gcc/common/config/riscv/riscv-common.cc
index 2d56ba59f0e..6bbbacab8df 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -135,7 +135,7 @@ public:
   /* Return true if any change.  */
   bool apply_implied_ext (riscv_subset_list *subset_list) const;
 
-  const std::vector<riscv_implied_info_t> implied_exts () const
+  const std::vector<riscv_implied_info_t> &implied_exts () const
   {
     return m_implied_exts;
   }
-- 
2.52.0

Reply via email to