x86-64: Emit the TLS call after debug marker

For a basic block with only a debug marker:

(note 3 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
(debug_insn 5 2 16 2 (debug_marker) "x.c":6:3 -1 (nil))

emit the TLS call after debug marker.

gcc/

	PR target/121668
	* config/i386/i386-features.cc (ix86_emit_tls_call): Emit the
	TLS call after debug marker.

gcc/testsuite/

	PR target/121668
	* gcc.target/i386/pr121668-1a.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
H.J. Lu
2025-08-26 15:29:25 -07:00
parent 775ecdb237
commit a9509987d1
2 changed files with 34 additions and 5 deletions

View File

@@ -3806,10 +3806,19 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
(code_label 78 11 77 3 14 (nil) [1 uses])
(note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
or a basic block with only a debug marker:
(note 3 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
(debug_insn 5 2 16 2 (debug_marker) "x.c":6:3 -1 (nil))
*/
gcc_assert (NOTE_P (insn)
&& (NOTE_KIND (insn) == NOTE_INSN_FUNCTION_BEG
|| NOTE_KIND (insn) == NOTE_INSN_BASIC_BLOCK));
gcc_assert (DEBUG_INSN_P (insn)
|| (NOTE_P (insn)
&& ((NOTE_KIND (insn)
== NOTE_INSN_FUNCTION_BEG)
|| (NOTE_KIND (insn)
== NOTE_INSN_BASIC_BLOCK))));
insn = NULL;
break;
}
@@ -3854,12 +3863,19 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
(note 4 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note 2 4 26 2 NOTE_INSN_FUNCTION_BEG)
or after NOTE_INSN_BASIC_BLOCK a basic block with only
a label:
or 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)
or after debug marker in a basic block with only a
debug marker:
(note 3 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
(debug_insn 5 2 16 2 (debug_marker) "x.c":6:3 -1 (nil))
*/
insn = insn ? PREV_INSN (insn) : BB_END (bb);
*after_p = insn;

View File

@@ -0,0 +1,13 @@
/* { dg-do compile { target *-*-linux* } } */
/* { dg-options "-Og -g -fpic -fplt -mtls-dialect=gnu" } */
typedef int caml_domain_state;
thread_local caml_domain_state caml_state;
void
caml_empty_mark_stack ()
{
while (caml_state)
caml_state = 0;
}
/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */