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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:0a846340b99675d57fc2f2923a0412134eed09d3

commit r13-6764-g0a846340b99675d57fc2f2923a0412134eed09d3
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Mon Mar 20 20:29:47 2023 +0100

    c++: Drop TREE_READONLY on vars (possibly) initialized by tls wrapper
[PR109164]

    The following two testcases are miscompiled, because we keep TREE_READONLY
    on the vars even when they are (possibly) dynamically initialized by a TLS
    wrapper function.  Normally cp_finish_decl drops TREE_READONLY from vars
    which need dynamic initialization, but for TLS we do this kind of
    initialization upon every access to those variables.  Keeping them
    TREE_READONLY means e.g. PRE can hoist loads from those before loops
    which contain the TLS wrapper calls, so we can access the TLS variables
    before they are initialized.

    2023-03-20  Jakub Jelinek  <ja...@redhat.com>

            PR c++/109164
            * cp-tree.h (var_needs_tls_wrapper): Declare.
            * decl2.cc (var_needs_tls_wrapper): No longer static.
            * decl.cc (cp_finish_decl): Clear TREE_READONLY on TLS variables
            for which a TLS wrapper will be needed.

            * g++.dg/tls/thread_local13.C: New test.
            * g++.dg/tls/thread_local13-aux.cc: New file.
            * g++.dg/tls/thread_local14.C: New test.
            * g++.dg/tls/thread_local14-aux.cc: New file.

Reply via email to