From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F0E1E39502D0; Tue, 2 May 2023 20:16:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0E1E39502D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683058569; bh=1zNH1Bh/JxoiMgf8+YvxCB4AoMonedToZlzikTx9uiM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sncIfbnaTC8DUM5b0tF+FQstGJggxbeqz3LpBhbbxTtmQ52/9pot8P39bsmcZad7S vd0dfpkJXMfkHc4GIWZ+LPAhJ2MEIxoFawGoYYE3RuBLPDNbGTlgCjDqf8Vue1jvue wjlYYHfsouHnclsLBBEz4ZjeP6qU7QNecKnRFE1A= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109164] wrong code with thread_local reference, loops and -ftree-pre Date: Tue, 02 May 2023 20:16:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109164 --- Comment #9 from CVS Commits --- The releases/gcc-11 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:6a4942ac236ce46499073daed7ebb8fa272aa7fa commit r11-10728-g6a4942ac236ce46499073daed7ebb8fa272aa7fa Author: Jakub Jelinek 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_READO= NLY 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 PR c++/109164 * cp-tree.h (var_needs_tls_wrapper): Declare. * decl2.c (var_needs_tls_wrapper): No longer static. * decl.c (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. (cherry picked from commit 0a846340b99675d57fc2f2923a0412134eed09d3)=