https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128437

--- Comment #19 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Uros Bizjak <[email protected]>:

https://gcc.gnu.org/g:45d15ffd7de445fdb993550dee54304d20b053d1

commit r17-6061-g45d15ffd7de445fdb993550dee54304d20b053d1
Author: Uros Bizjak <[email protected]>
Date:   Sat Nov 7 11:34:49 2026 +0000

    i386: Don't output dead TLS LD base sequences [PR128437]

    The fix for PR128437 removed dead 64-bit TLS local-dynamic base calls
    in ix86_reorg, but it relies on REG_UNUSED notes on the call, and these
    are often missing.  The call result can still be used by a dead spill
    store whose reload was deleted by DCE in sched2, DCE never deletes
    non-register stores, and the notes may not be recomputed at all when
    sched2 or DCE doesn't run.  The call is then left without any
    local-dynamic TLS symbol in the function, and '%&' in its template ICEs.

    Fix this by making the output independent of what other passes deleted.
    The only users of the local-dynamic base are the "base + sym@dtpoff"
    forms, and all of them contain the TLS symbol.  So if
    get_some_local_dynamic_name finds no symbol, nothing can use the base,
    and the insn only has to define its result register.  Output "xor"
    instead of the lea and call in this case, in both 64-bit patterns and in
    the 32-bit pattern, which can be kept alive by a dead spill store in the
    same way.  FLAGS_REG is clobbered by the call patterns, and explicitly by
    the 32-bit pattern.

    Remove ix86_remove_dead_tls_ld_base, which is not needed anymore.

    Assisted-by: Claude Sonnet 5.5

            PR target/128437

    gcc/ChangeLog:

            * config/i386/i386.cc (ix86_remove_dead_tls_ld_base): Remove.
            (ix86_reorg): Do not call it.
            * config/i386/i386.md (*tls_local_dynamic_base_32_gnu): Output
            xor of the result register when no local-dynamic TLS symbol
            is left.
            (*tls_local_dynamic_base_64_<mode>): Ditto.
            (*tls_local_dynamic_base_64_largepic): Ditto.

    gcc/testsuite/ChangeLog:

            * g++.target/i386/pr128437-1.C: New test.

Reply via email to