H.J. Lu 2ecaeee924 x86: Place the TLS call before all register setting BBs
We can't place a TLS call before a conditional jump in a basic block like

(code_label 13 11 14 4 2 (nil) [1 uses])
(note 14 13 16 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(jump_insn 16 14 17 4 (set (pc)
        (if_then_else (le (reg:CCNO 17 flags)
                (const_int 0 [0]))
            (label_ref 27)
            (pc))) "x.c":10:21 discrim 1 1462 {*jcc}
     (expr_list:REG_DEAD (reg:CCNO 17 flags)
        (int_list:REG_BR_PROB 628353713 (nil)))
 -> 27)

since the TLS call will clobber flags register nor place a TLS call in a
basic block if any live caller-saved registers aren't dead at the end of
the basic block:

;; live  in      6 [bp] 7 [sp] 16 [argp] 17 [flags] 19 [frame] 104
;; live  gen     0 [ax] 102 106 108 116 117 118 120
;; live  kill    5 [di]

Instead, we should place such call before all register setting basic
blocks which dominate the current basic block.

Keep track the replaced GNU and GNU2 TLS instructions.  Use these info to
place the __tls_get_addr call and mark FLAGS register as dead.

gcc/

	PR target/121572
	* config/i386/i386-features.cc (replace_tls_call): Add a bitmap
	argument and put the updated TLS instruction in the bitmap.
	(ix86_get_dominator_for_reg): New.
	(ix86_check_flags_reg): Likewise.
	(ix86_emit_tls_call): Likewise.
	(ix86_place_single_tls_call): Add 2 bitmap arguments for updated
	GNU and GNU2 TLS instructions.  Call ix86_emit_tls_call to emit
	TLS instruction.  Correct debug dump for before instruction.

gcc/testsuite/

	PR target/121572
	* gcc.target/i386/pr121572-1a.c: New test.
	* gcc.target/i386/pr121572-1b.c: Likewise.
	* gcc.target/i386/pr121572-2a.c: Likewise.
	* gcc.target/i386/pr121572-2b.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-19 18:04:45 -07:00
2025-08-11 00:16:52 +00:00
2025-08-18 00:18:52 +00:00
2025-08-16 00:19:12 +00:00
2025-08-17 00:19:17 +00:00
2025-08-16 00:19:12 +00:00
2025-08-14 00:20:55 +00:00
2025-08-14 00:20:55 +00:00
2025-08-07 00:20:46 +00:00
2025-08-07 00:20:46 +00:00
2025-08-06 00:21:26 +00:00
2025-08-17 00:19:17 +00:00
2025-08-20 00:19:40 +00:00
2025-08-19 00:20:02 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.7%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.4%