https://gcc.gnu.org/g:ea588988c193ee19b61bba5b99e039c9ca267abe

commit r16-2596-gea588988c193ee19b61bba5b99e039c9ca267abe
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Mon Jul 28 20:22:53 2025 -0700

    output: Move an special # (256) to a new macro
    
    This is a followup to the review of mergability of CSWTCH patch
    located at https://gcc.gnu.org/pipermail/gcc-patches/2025-July/690810.html.
    Moves the special # (256) to a macro so it is not used bare in the source
    and there is only the need to change it in one place.
    This special # was added with r0-37392-g201556f0e00580 which added the 
original mergeable
    section support to gcc.
    
    Pushed as obvious after build and test on x86_64.
    
    gcc/ChangeLog:
    
            * output.h (MAX_ALIGN_MERGABLE): New define.
            * tree-switch-conversion.cc (switch_conversion::build_one_array):
            Use MAX_ALIGN_MERGABLE instead of 256.
            * varasm.cc (mergeable_string_section): Likewise
            (mergeable_constant_section): Likewise
    
    Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>

Diff:
---
 gcc/output.h                  | 3 +++
 gcc/tree-switch-conversion.cc | 6 +++---
 gcc/varasm.cc                 | 6 +++---
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/gcc/output.h b/gcc/output.h
index 5cc72ebee378..51c2d36f8f66 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -545,6 +545,9 @@ extern GTY(()) section *bss_noswitch_section;
 extern GTY(()) section *in_section;
 extern GTY(()) bool in_cold_section_p;
 
+/* MAX bit alignment for mergable sections. */
+#define MAX_ALIGN_MERGABLE 256
+
 extern section *get_unnamed_section (unsigned int, void (*) (const char *),
                                     const char *);
 extern section *get_section (const char *, unsigned int, tree,
diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
index b3ae93d57e1e..04b357fca4c4 100644
--- a/gcc/tree-switch-conversion.cc
+++ b/gcc/tree-switch-conversion.cc
@@ -55,6 +55,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 
MA
 #include "hwint.h"
 #include "internal-fn.h"
 #include "diagnostic-core.h"
+#include "output.h"
 
 /* ??? For lang_hooks.types.type_for_mode, but is there a word_mode
    type in the GIMPLE type system that is language-independent?  */
@@ -1038,9 +1039,8 @@ switch_conversion::build_one_array (int num, tree 
arr_index_type,
       if (tree_to_uhwi (DECL_SIZE (decl)) > DECL_ALIGN (decl))
        {
          unsigned HOST_WIDE_INT s = tree_to_uhwi (DECL_SIZE (decl));
-         /* Only support up to 32bytes since that is what is
-            supported for merging. */
-         if (s <= 256)
+         /* Only support up to the max supported for merging. */
+         if (s <= MAX_ALIGN_MERGABLE)
            SET_DECL_ALIGN (decl, HOST_WIDE_INT_1U << ceil_log2 (s));
        }
 
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index 834cdefbe4f8..000ad9e26f6f 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -871,7 +871,7 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
   if (HAVE_GAS_SHF_MERGE && flag_merge_constants
       && TREE_CODE (decl) == STRING_CST
       && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
-      && align <= 256
+      && align <= MAX_ALIGN_MERGABLE
       && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
       && TREE_STRING_LENGTH (decl) == len)
     {
@@ -885,7 +885,7 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
 
       mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
       modesize = GET_MODE_BITSIZE (mode);
-      if (modesize >= 8 && modesize <= 256
+      if (modesize >= 8 && modesize <= MAX_ALIGN_MERGABLE
          && (modesize & (modesize - 1)) == 0)
        {
          if (align < modesize)
@@ -926,7 +926,7 @@ mergeable_constant_section (unsigned HOST_WIDE_INT 
size_bits,
   if (HAVE_GAS_SHF_MERGE && flag_merge_constants
       && size_bits <= align
       && align >= 8
-      && align <= 256
+      && align <= MAX_ALIGN_MERGABLE
       && (align & (align - 1)) == 0)
     {
       const char *prefix = function_mergeable_rodata_prefix ();

Reply via email to