commit:     2de0fee68af0099b1e038e62b41756f098e70cb7
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 12 04:40:04 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Nov 12 04:40:13 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=2de0fee6

16.0.0: add fix for firefox+lto ICE

Bug: https://gcc.gnu.org/PR122620
Signed-off-by: Sam James <sam <AT> gentoo.org>

 16.0.0/gentoo/88_all_PR122620-firefox.patch | 86 +++++++++++++++++++++++++++++
 16.0.0/gentoo/README.history                |  4 ++
 2 files changed, 90 insertions(+)

diff --git a/16.0.0/gentoo/88_all_PR122620-firefox.patch 
b/16.0.0/gentoo/88_all_PR122620-firefox.patch
new file mode 100644
index 0000000..12c258d
--- /dev/null
+++ b/16.0.0/gentoo/88_all_PR122620-firefox.patch
@@ -0,0 +1,86 @@
+From 8f3242ce5c03c30f806f54ceaff2a15d6e5b5ee6 Mon Sep 17 00:00:00 2001
+From: Jakub Jelinek <[email protected]>
+Date: Tue, 11 Nov 2025 08:29:22 +0100
+Subject: gimplify-me: Fix regimplification of gimple-reg-type clobbers
+ [PR122620]
+
+Since r11-2238-ge443d8213864ac337c29092d4767224f280d2062 the C++ FE
+emits clobbers like *_1 = {CLOBBER}; where *_1 MEM_REF has some scalar
+type like int for -flifetime-dse={1,2} and most of the compiler manages
+to cope with that.
+If we are very unlucky, we trigger an ICE while trying to regimplify it
+(at least during inlining), as happens with GCC 15.2 on firefox-145.0
+built with LTO+PGO.
+I haven't managed to reduce that to a small testcase that would ICE though,
+the clobber certainly appears in code like
+template <typename T>
+struct S {
+  T *p;
+  union { char a; T b; };
+  static S foo (T *x) { S s; s.p = x; s.b.~T (); return s; }
+  ~S ();
+};
+
+void
+bar ()
+{
+  int i = 42;
+  S <int> s = S <int>::foo (&i);
+}
+but convincing inliner that it should id->regimplify = true; on exactly
+that stmt has been difficult.
+
+The ICE is because we try (in two spots) to regimplify the rhs of the
+gimple_clobber_p stmt if gimple-reg-type type (i.e. the TREE_CLOBBER),
+because it doesn't satisfy the is_gimple_mem_rhs_or_call predicate
+returned by rhs_predicate_for for the MEM_REF lhs.  And regimplify it
+by trying to gimplify SSA_NAME = {CLOBBER}; INIT_EXPR and in there reach
+a special case which stores that freshly made SSA_NAME into memory and
+loads it from memory, so uses a SSA_NAME without SSA_NAME_DEF_STMT.
+
+Fixed thusly by saying clobbers are ok even for the gimple-reg-types.
+
+2025-11-11  Jakub Jelinek  <[email protected]>
+
+       PR lto/122620
+       * gimplify-me.cc (gimple_regimplify_operands): Don't try to regimplify
+       TREE_CLOBBER on rhs of gimple_clobber_p if it has gimple_reg_type.
+---
+ gcc/gimplify-me.cc | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/gimplify-me.cc b/gcc/gimplify-me.cc
+index 5b4b98763731..1e5056b7e579 100644
+--- a/gcc/gimplify-me.cc
++++ b/gcc/gimplify-me.cc
+@@ -233,9 +233,13 @@ gimple_regimplify_operands (gimple *stmt, 
gimple_stmt_iterator *gsi_p)
+         else if (i == 2
+                  && gimple_assign_single_p (stmt)
+                  && num_ops == 2)
+-          gimplify_expr (&op, &pre, NULL,
+-                         rhs_predicate_for (gimple_assign_lhs (stmt)),
+-                         fb_rvalue);
++          {
++            if (gimple_clobber_p (stmt))
++              continue;
++            gimplify_expr (&op, &pre, NULL,
++                           rhs_predicate_for (gimple_assign_lhs (stmt)),
++                           fb_rvalue);
++          }
+         else if (i == 2 && is_gimple_call (stmt))
+           {
+             if (TREE_CODE (op) == FUNCTION_DECL)
+@@ -254,8 +258,9 @@ gimple_regimplify_operands (gimple *stmt, 
gimple_stmt_iterator *gsi_p)
+       {
+         bool need_temp = false;
+ 
+-        if (gimple_assign_single_p (stmt)
+-            && num_ops == 2)
++        if (gimple_clobber_p (stmt))
++          ;
++        else if (gimple_assign_single_p (stmt) && num_ops == 2)
+           gimplify_expr (gimple_assign_rhs1_ptr (stmt), &pre, NULL,
+                          rhs_predicate_for (gimple_assign_lhs (stmt)),
+                          fb_rvalue);
+-- 
+cgit

diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index a805ab4..563bab6 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+22     12 November 2025
+
+       + 88_all_PR122620-firefox.patch
+
 21     9 November 2025
 
        - 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch

Reply via email to