]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
output: Move an special # (256) to a new macro
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 29 Jul 2025 03:22:53 +0000 (20:22 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Tue, 29 Jul 2025 06:43:33 +0000 (23:43 -0700)
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_apinski@quicinc.com>
gcc/output.h
gcc/tree-switch-conversion.cc
gcc/varasm.cc

index 5cc72ebee378c6c58f44047f2a0ffc59cb371196..51c2d36f8f66d4a7d02d10940f33bda20367abf2 100644 (file)
@@ -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,
index b3ae93d57e1e4e290dfffd5f3f2d2979be539a1f..04b357fca4c438f52881bc303004f7c955585d52 100644 (file)
@@ -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));
        }
 
index 834cdefbe4f8cf62722350ac054703c4a152d701..000ad9e26f6fdb9d31cdcfcdfc682c001977a542 100644 (file)
@@ -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 ();