]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Do not use caller-saved registers for COMDAT functions
authorLIU Hao <lh_mouse@126.com>
Mon, 15 Jul 2024 08:55:52 +0000 (16:55 +0800)
committerJonathan Yong <10walls@gmail.com>
Fri, 19 Jul 2024 09:50:29 +0000 (09:50 +0000)
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.

(cherry picked from commit 5080840d8fbf25a321dd27543a1462d393d338bc)

gcc/varasm.cc

index dc9f733791ab0d26b90ded45d5e29d7878832a38..9fa3a42bf45481684814c286665facc679347180 100644 (file)
@@ -7621,6 +7621,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)))