From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
Date: Wed, 20 Aug 2025 14:10:31 +0000 (UTC) [thread overview]
Message-ID: <1755699004.7839f4bfafb5241ffa4dac16d088572965626173.sam@gentoo> (raw)
commit: 7839f4bfafb5241ffa4dac16d088572965626173
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 20 14:10:04 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 20 14:10:04 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=7839f4bf
16.0.0: fix TLS ICE
Bug: https://gcc.gnu.org/PR121607
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch | 173 ++++++++++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 174 insertions(+)
diff --git a/16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch b/16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch
new file mode 100644
index 0000000..a156cb1
--- /dev/null
+++ b/16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch
@@ -0,0 +1,173 @@
+From e22c8a8cd7aef8938722e0ea6719dd1298d48812 Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Wed, 20 Aug 2025 06:59:48 -0700
+Subject: [PATCH] x86-64: Emit the TLS call after NOTE_INSN_BASIC_BLOCK
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+For a basic block with only a label:
+
+(code_label 78 11 77 3 14 (nil) [1 uses])
+(note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
+
+emit the TLS call after NOTE_INSN_BASIC_BLOCK, instead of before
+NOTE_INSN_BASIC_BLOCK, to avoid
+
+x.c: In function ‘aout_16_write_syms’:
+x.c:54:1: error: NOTE_INSN_BASIC_BLOCK is missing for block 3
+ 54 | }
+ | ^
+x.c:54:1: error: NOTE_INSN_BASIC_BLOCK 77 in middle of basic block 3
+during RTL pass: x86_cse
+x.c:54:1: internal compiler error: verify_flow_info failed
+
+gcc/
+
+ PR target/121607
+ * config/i386/i386-features.cc (ix86_emit_tls_call): Emit the
+ TLS call after NOTE_INSN_BASIC_BLOCK in a basic block with only
+ a label.
+
+gcc/testsuite/
+
+ PR target/121607
+ * gcc.target/i386/pr121607-1a.c: New test.
+ * gcc.target/i386/pr121607-1b.c: Likewise.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config/i386/i386-features.cc | 24 +++++++--
+ gcc/testsuite/gcc.target/i386/pr121607-1a.c | 59 +++++++++++++++++++++
+ gcc/testsuite/gcc.target/i386/pr121607-1b.c | 6 +++
+ 3 files changed, 86 insertions(+), 3 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121607-1a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121607-1b.c
+
+diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
+index 7869ee22b67..514d2a5d378 100644
+--- a/gcc/config/i386/i386-features.cc
++++ b/gcc/config/i386/i386-features.cc
+@@ -3795,7 +3795,18 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
+ while (insn && !NONDEBUG_INSN_P (insn))
+ {
+ if (insn == BB_END (bb))
+- break;
++ {
++ /* This must be a basic block with only a label:
++
++ (code_label 78 11 77 3 14 (nil) [1 uses])
++ (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
++
++ */
++ gcc_assert (NOTE_P (insn)
++ && NOTE_KIND (insn) == NOTE_INSN_BASIC_BLOCK);
++ insn = NULL;
++ break;
++ }
+ insn = NEXT_INSN (insn);
+ }
+
+@@ -3824,14 +3835,21 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
+
+ if (bitmap_empty_p (live_caller_saved_regs))
+ {
+- if (insn == BB_HEAD (bb) || insn == BB_END (bb))
++ if (insn == BB_HEAD (bb))
+ {
+ *before_p = insn;
+ tls_insn = emit_insn_before (tls_set, insn);
+ }
+ else
+ {
+- insn = PREV_INSN (insn);
++ /* Emit the TLS call after NOTE_INSN_BASIC_BLOCK in a
++ basic block with only a label:
++
++ (code_label 78 11 77 3 14 (nil) [1 uses])
++ (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
++
++ */
++ insn = insn ? PREV_INSN (insn) : BB_END (bb);
+ *after_p = insn;
+ tls_insn = emit_insn_after (tls_set, insn);
+ }
+diff --git a/gcc/testsuite/gcc.target/i386/pr121607-1a.c b/gcc/testsuite/gcc.target/i386/pr121607-1a.c
+new file mode 100644
+index 00000000000..4c047068e3a
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121607-1a.c
+@@ -0,0 +1,59 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu -fno-semantic-interposition -fstack-protector" } */
++
++typedef enum
++{
++ bfd_error_invalid_error_code
++} bfd_error_type;
++thread_local bfd_error_type bfd_error;
++int aout_16_write_syms___trans_tmp_1;
++short aout_16_write_syms_g_0_0;
++void xvec_0 (long, void *);
++
++typedef struct
++{
++ int output_section;
++} asection;
++
++void bfd_asymbol_section ();
++
++struct pdp11_external_nlist
++{
++ char e_desc[2];
++ char e_type[1];
++ char e_ovly[10];
++} translate_to_native_sym_flags (struct pdp11_external_nlist *sym_pointer)
++{
++ asection *sec;
++ sym_pointer->e_type[0] &= 5;
++ bfd_asymbol_section ();
++ if (sec == 0)
++ {
++ bfd_error_type error_tag;
++ bfd_error = error_tag;
++ }
++ if (sec->output_section)
++ {
++ bfd_error_type error_tag;
++ bfd_error = error_tag;
++ }
++}
++
++bool
++aout_16_write_syms (void *abfd)
++{
++ for (; aout_16_write_syms___trans_tmp_1;)
++ {
++ struct pdp11_external_nlist nsp;
++ if (abfd)
++ {
++ xvec_0 (aout_16_write_syms_g_0_0, nsp.e_desc);
++ nsp.e_ovly[0] = 0;
++ }
++ else
++ nsp.e_type[0] = 0;
++ translate_to_native_sym_flags (&nsp);
++ }
++}
++
++/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 2 { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121607-1b.c b/gcc/testsuite/gcc.target/i386/pr121607-1b.c
+new file mode 100644
+index 00000000000..366306702c7
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121607-1b.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu2 -fno-semantic-interposition -fstack-protector" } */
++
++#include "pr121607-1a.c"
++
++/* { dg-final { scan-assembler-times "call\[ \t\]\\*bfd_error@TLSCALL\\(%(?:r|e)ax\\)" 2 { target { ! ia32 } } } } */
+--
+2.50.1
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 45143c9..ff3cbb8 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,7 @@
12 ????
- 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+ + 88_all_PR121607-TLS-ICE.patch
11 20 August 2025
next reply other threads:[~2025-08-20 14:10 UTC|newest]
Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 14:10 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-10-13 2:49 [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/ Sam James
2025-10-09 7:31 Sam James
2025-10-09 2:26 Sam James
2025-10-09 2:26 Sam James
2025-10-05 23:05 Sam James
2025-10-05 22:50 Sam James
2025-10-02 11:05 Sam James
2025-10-02 11:04 Sam James
2025-10-02 4:55 Sam James
2025-10-02 1:18 Sam James
2025-10-02 0:40 Sam James
2025-10-02 0:36 Sam James
2025-10-02 0:30 Sam James
2025-09-17 18:41 Sam James
2025-09-17 3:04 Sam James
2025-09-16 19:23 Sam James
2025-09-14 11:26 Sam James
2025-09-13 13:16 Sam James
2025-09-07 22:42 Sam James
2025-09-06 2:42 Sam James
2025-09-05 12:44 Sam James
2025-09-01 8:04 Sam James
2025-08-31 22:43 Sam James
2025-08-30 14:06 Sam James
2025-08-30 8:05 Sam James
2025-08-30 6:57 Sam James
2025-08-30 0:12 Sam James
2025-08-29 21:26 Sam James
2025-08-29 21:02 Sam James
2025-08-29 20:24 Sam James
2025-08-29 20:18 Sam James
2025-08-29 18:38 Sam James
2025-08-29 12:15 Sam James
2025-08-28 17:57 Sam James
2025-08-28 5:27 Sam James
2025-08-27 4:19 Sam James
2025-08-26 23:42 Sam James
2025-08-26 4:48 Sam James
2025-08-26 0:56 Sam James
2025-08-25 3:55 Sam James
2025-08-24 23:42 Sam James
2025-08-21 16:11 Sam James
2025-08-20 20:45 Sam James
2025-08-20 1:16 Sam James
2025-08-20 1:10 Sam James
2025-08-19 16:30 Sam James
2025-08-18 23:52 Sam James
2025-08-18 23:08 Sam James
2025-08-17 22:45 Sam James
2025-08-17 21:01 Sam James
2025-08-17 16:30 Sam James
2025-08-17 15:44 Sam James
2025-08-17 15:10 Sam James
2025-08-16 23:06 Sam James
2025-08-05 0:23 Sam James
2025-07-30 22:35 Sam James
2025-07-30 0:44 Sam James
2025-07-30 0:44 Sam James
2025-07-25 18:49 Sam James
2025-07-23 11:22 Sam James
2025-07-22 23:56 Sam James
2025-07-21 14:02 Sam James
2025-07-21 1:12 Sam James
2025-07-14 16:03 Sam James
2025-07-14 4:09 Sam James
2025-07-14 2:55 Sam James
2025-07-14 2:55 Sam James
2025-07-14 2:40 Sam James
2025-07-13 23:11 Sam James
2025-07-13 1:09 Sam James
2025-07-12 15:24 Sam James
2025-07-12 15:23 Sam James
2025-07-10 12:34 Sam James
2025-07-10 1:22 Sam James
2025-07-10 0:50 Sam James
2025-07-07 20:49 Sam James
2025-07-06 22:41 Sam James
2025-07-03 1:29 Sam James
2025-06-30 6:26 Sam James
2025-06-29 0:29 Sam James
2025-06-19 16:59 Sam James
2025-06-19 0:58 Sam James
2025-06-19 0:58 Sam James
2025-06-18 21:17 Sam James
2025-06-18 9:53 Sam James
2025-06-18 9:06 Sam James
2025-06-13 12:03 Sam James
2025-06-12 20:34 Sam James
2025-06-12 14:05 Sam James
2025-06-12 7:27 Sam James
2025-06-12 5:46 Sam James
2025-06-11 5:05 Sam James
2025-06-11 3:19 Sam James
2025-06-01 22:39 Sam James
2025-05-31 18:48 Sam James
2025-05-11 22:52 Sam James
2025-05-10 15:28 Sam James
2025-05-09 23:29 Sam James
2025-05-05 14:39 Sam James
2025-05-05 13:05 Sam James
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1755699004.7839f4bfafb5241ffa4dac16d088572965626173.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox