https://gcc.gnu.org/g:5080840d8fbf25a321dd27543a1462d393d338bc

commit r15-2140-g5080840d8fbf25a321dd27543a1462d393d338bc
Author: LIU Hao <lh_mo...@126.com>
Date:   Mon Jul 15 16:55:52 2024 +0800

    Do not use caller-saved registers for COMDAT functions
    
    A reference to a COMDAT function may be resolved to another definition
    outside the current translation unit, so it's not eligible for `-fipa-ra`.
    
    In `decl_binds_to_current_def_p()` there is already a check for weak
    symbols. This commit checks for COMDAT functions that are not implemented
    as weak symbols, for example, on *-*-mingw32.
    
    gcc/ChangeLog:
    
            PR rtl-optimization/115049
            * varasm.cc (decl_binds_to_current_def_p): Add a check for COMDAT
            declarations too, like weak ones.

Diff:
---
 gcc/varasm.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index beb88709033f..4426e7ce6c65 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -7813,6 +7813,8 @@ decl_binds_to_current_def_p (const_tree decl)
      for all other declaration types.  */
   if (DECL_WEAK (decl))
     return false;
+  if (DECL_COMDAT_GROUP (decl))
+    return false;
   if (DECL_COMMON (decl)
       && (DECL_INITIAL (decl) == NULL
          || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node)))

Reply via email to