From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1647048-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id C1D0315802E
	for <garchives@archives.gentoo.org>; Wed, 26 Jun 2024 23:58:01 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id D89372BC05E;
	Wed, 26 Jun 2024 23:57:59 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id B5CB52BC05E
	for <gentoo-commits@lists.gentoo.org>; Wed, 26 Jun 2024 23:57:59 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id BAE2933BDF0
	for <gentoo-commits@lists.gentoo.org>; Wed, 26 Jun 2024 23:57:58 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 04B2B1CF7
	for <gentoo-commits@lists.gentoo.org>; Wed, 26 Jun 2024 23:57:57 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1719446272.e35c53788a928179ef26b76833bcbe297f84fe6a.sam@gentoo>
Subject: [gentoo-commits] proj/gcc-patches:master commit in: 15.0.0/gentoo/
X-VCS-Repository: proj/gcc-patches
X-VCS-Files: 15.0.0/gentoo/77_all_i386-fix-ix86_expand_move.patch 15.0.0/gentoo/78_all_i386-fix-recent-alias-set-change.patch
X-VCS-Directories: 15.0.0/gentoo/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: e35c53788a928179ef26b76833bcbe297f84fe6a
X-VCS-Branch: master
Date: Wed, 26 Jun 2024 23:57:57 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 17d2a192-429d-4dbb-86ac-abe8404e6bef
X-Archives-Hash: d76f573603fc961b335cb101ec8ca84b

commit:     e35c53788a928179ef26b76833bcbe297f84fe6a
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 26 23:57:28 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 26 23:57:52 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=e35c5378

15.0.0: workaround recent x86 changes

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

 .../gentoo/77_all_i386-fix-ix86_expand_move.patch  | 45 ++++++++++
 .../78_all_i386-fix-recent-alias-set-change.patch  | 95 ++++++++++++++++++++++
 2 files changed, 140 insertions(+)

diff --git a/15.0.0/gentoo/77_all_i386-fix-ix86_expand_move.patch b/15.0.0/gentoo/77_all_i386-fix-ix86_expand_move.patch
new file mode 100644
index 0000000..4b42ea9
--- /dev/null
+++ b/15.0.0/gentoo/77_all_i386-fix-ix86_expand_move.patch
@@ -0,0 +1,45 @@
+From ec0ead755e65ba51813aa8b66f4eb5574dd8437c Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Wed, 26 Jun 2024 13:19:42 +0100
+Subject: [PATCH 1/2] i386: fix ix86_expand_move
+
+Before r15-1599-g63512c72df09b4, legitimize_pe_coff_symbol would return NULL_RTX
+for non-PECOFF targets, so the else branch would get taken.
+
+(This is a hack which doesn't work for PECOFF targets but fixes miscompilations
+on ELF.)
+
+Bug: https://gcc.gnu.org/PR115635
+Bug: https://gcc.gnu.org/PR115661
+---
+ gcc/config/i386/i386-expand.cc | 10 ----------
+ 1 file changed, 10 deletions(-)
+
+diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
+index 5dfa7d49f58c..5e0173bc7a84 100644
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -412,20 +412,10 @@ ix86_expand_move (machine_mode mode, rtx operands[])
+ 	}
+       else
+ 	{
+-#if TARGET_PECOFF
+-	  tmp = legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
+-	  if (tmp)
+-	    {
+-	      op1 = tmp;
+-	      if (!addend)
+-		break;
+-	    }
+-	  else
+ 	    {
+ 	      op1 = operands[1];
+ 	      break;
+ 	    }
+-#endif
+ 	}
+ 
+       if (addend)
+-- 
+2.45.2
+

diff --git a/15.0.0/gentoo/78_all_i386-fix-recent-alias-set-change.patch b/15.0.0/gentoo/78_all_i386-fix-recent-alias-set-change.patch
new file mode 100644
index 0000000..6776fdd
--- /dev/null
+++ b/15.0.0/gentoo/78_all_i386-fix-recent-alias-set-change.patch
@@ -0,0 +1,95 @@
+From 72a4d2d437782afa975f9b29c3ab4a1826ad0cd6 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Wed, 26 Jun 2024 12:54:55 +0100
+Subject: [PATCH 2/2] i386: fix recent alias set change
+
+Before r15-1599-g63512c72df09b4, we would create a new alias set, but now
+we use -1. Go back to using ix86_GOT_alias_set.
+
+(This is a hack which isn't the cleanest way of fixing it.)
+
+Bug: https://gcc.gnu.org/PR115635
+Bug: https://gcc.gnu.org/PR115661
+---
+ gcc/config/i386/i386-expand.cc |  2 +-
+ gcc/config/i386/i386-expand.h  |  1 +
+ gcc/config/i386/i386.cc        | 17 ++++++++++++++---
+ 3 files changed, 16 insertions(+), 4 deletions(-)
+
+diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
+index 5e0173bc7a84..3345f40ad85d 100644
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -408,7 +408,7 @@ ix86_expand_move (machine_mode mode, rtx operands[])
+ 				 : UNSPEC_GOT));
+ 	  op1 = gen_rtx_CONST (Pmode, op1);
+ 	  op1 = gen_const_mem (Pmode, op1);
+-	  set_mem_alias_set (op1, GOT_ALIAS_SET);
++	  set_mem_alias_set (op1, ix86_GOT_alias_set ());
+ 	}
+       else
+ 	{
+diff --git a/gcc/config/i386/i386-expand.h b/gcc/config/i386/i386-expand.h
+index 5e02df1706df..56bee29253ba 100644
+--- a/gcc/config/i386/i386-expand.h
++++ b/gcc/config/i386/i386-expand.h
+@@ -34,6 +34,7 @@ struct expand_vec_perm_d
+ };
+ 
+ rtx legitimize_tls_address (rtx x, enum tls_model model, bool for_mov);
++alias_set_type ix86_GOT_alias_set (void);
+ rtx legitimize_pic_address (rtx orig, rtx reg);
+ 
+ bool insn_defines_reg (unsigned int regno1, unsigned int regno2,
+diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
+index 1f71ed04be67..62fca080f2f5 100644
+--- a/gcc/config/i386/i386.cc
++++ b/gcc/config/i386/i386.cc
+@@ -11823,6 +11823,17 @@ constant_address_p (rtx x)
+ }
+ 
+ 
++/* Return a unique alias set for the GOT.  */
++
++alias_set_type
++ix86_GOT_alias_set (void)
++{
++  static alias_set_type set = -1;
++  if (set == -1)
++    set = new_alias_set ();
++  return set;
++}
++
+ /* Return a legitimate reference for ORIG (an address) using the
+    register REG.  If REG is 0, a new pseudo is generated.
+ 
+@@ -11925,7 +11936,7 @@ legitimize_pic_address (rtx orig, rtx reg)
+ 				    UNSPEC_GOTPCREL);
+ 	  new_rtx = gen_rtx_CONST (Pmode, new_rtx);
+ 	  new_rtx = gen_const_mem (Pmode, new_rtx);
+-	  set_mem_alias_set (new_rtx, GOT_ALIAS_SET);
++	  set_mem_alias_set (new_rtx, ix86_GOT_alias_set ());
+ 	}
+       else
+ 	{
+@@ -11947,7 +11958,7 @@ legitimize_pic_address (rtx orig, rtx reg)
+ 	    new_rtx = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new_rtx);
+ 
+ 	  new_rtx = gen_const_mem (Pmode, new_rtx);
+-	  set_mem_alias_set (new_rtx, GOT_ALIAS_SET);
++	  set_mem_alias_set (new_rtx, ix86_GOT_alias_set ());
+ 	}
+ 
+       new_rtx = copy_to_suggested_reg (new_rtx, reg, Pmode);
+@@ -12324,7 +12335,7 @@ legitimize_tls_address (rtx x, enum tls_model model, bool for_mov)
+       if (pic)
+ 	off = gen_rtx_PLUS (tp_mode, pic, off);
+       off = gen_const_mem (tp_mode, off);
+-      set_mem_alias_set (off, GOT_ALIAS_SET);
++      set_mem_alias_set (off, ix86_GOT_alias_set ());
+ 
+       if (TARGET_64BIT || TARGET_ANY_GNU_TLS)
+ 	{
+-- 
+2.45.2
+