From patchwork Wed Oct 26 13:52:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 11282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp279913wru; Wed, 26 Oct 2022 06:53:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6FVGtQMzQwYhikI3aWQMv8uOCj8B3GOUxoegVaWd8v5rx/vSI4mWUhgf8GtkmB7r1FadlQ X-Received: by 2002:a17:907:3da5:b0:78e:793:4084 with SMTP id he37-20020a1709073da500b0078e07934084mr38522145ejc.285.1666792429791; Wed, 26 Oct 2022 06:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666792429; cv=none; d=google.com; s=arc-20160816; b=l4UWDMf0mZ2onMXXqnxUO6U+uaFwBMyf7ZCmY9lqLVcmJK4Q6oB2ThkqoqSIrmt9HL b3ioNwOz8tIIAIiHwnTgcidg0KKBgUbdsOzRt59K14pLGcCitpZ/K3TcWEO9fgYI3bwp LXU4pDxbFmQfrayPy5gw3EfFG/MaMq9QjgqapzKNKcGfEVXYvgBlruDDnyv4VTR5MW5I A52vLiHRDopQIlOujPVbpua+5I6qwjp6BFWlzuyOh4GK65YX3MMe5rgVO9BPYay+8ad4 lw/U8lURehCcJ3MIkhxD1daI1lZUhABJR0vc7vt9OpyWx4UShpfQd6p775gBF7rQlx2u CDhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-filter :dmarc-filter:delivered-to; bh=V4xSKzkvftuN6/VX+uOeo/1LTyVpSJO4mxBVqW/aiyk=; b=Q39F838Bu+0+KBsmHisqY2HCMTtzvcwA2FPpKBasWxMxkdWpw9vtYdBLka15AeoCak Ejcjk+2oFNxAlonX6921j0mVCydXkJhwB8/5ou7PeK9NcpILU/IcBCT3DUlbvI0FKfpp 5W7tBPAl4Ejf8B2GLTSpGLNGHucWrPLwt9UNGAyVhJldeE/yjYcqyJD3aMHVmU8PGs/a LJcDRWT0/u5TI75yCWLcxQ6cXMi1tPRiK4EbF5PP8fgyb+B6s+fTyl7i4oa8C3/+yeaw LeSFpaGJqeT0dU/cVRMM+DaUaEpVyTPQa/LIaSMfqypiesvzN1tDyGo8Uufai1zuE+Lg koMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qo14-20020a170907874e00b007a0d3365aa9si1306708ejc.136.2022.10.26.06.53.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 06:53:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 10753385F022 for ; Wed, 26 Oct 2022 13:53:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id 19E38385D0DA for ; Wed, 26 Oct 2022 13:52:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 19E38385D0DA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ispras.ru Received: from localhost.intra.ispras.ru (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTP id A98DD40D403D; Wed, 26 Oct 2022 13:52:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru A98DD40D403D From: Alexander Monakov To: gcc-patches@gcc.gnu.org Subject: [PATCH] ipa-visibility: remove assert in TLS optimization [PR107353] Date: Wed, 26 Oct 2022 16:52:38 +0300 Message-Id: <20221026135238.24678-1-amonakov@ispras.ru> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Hubicka , Alexander Monakov , Artem Klimov Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747758538700446394?= X-GMAIL-MSGID: =?utf-8?q?1747758538700446394?= When upgrading TLS access model based on optimized symbol visibility status, we attempted to assert that recomputing the model would not weaken it. It turns out that C, C++, and Fortran front-ends all can (unintentionally) assign a stronger model than what can be derived from the declaration. Let's act conservatively instead of asserting, at least as long as such pre-existing issues remain. gcc/ChangeLog: PR other/107353 * ipa-visibility.cc (function_and_variable_visibility): Conditionally upgrade TLS model instead of asserting. --- gcc/ipa-visibility.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/ipa-visibility.cc b/gcc/ipa-visibility.cc index 3ed2b7cf6..238f7eb84 100644 --- a/gcc/ipa-visibility.cc +++ b/gcc/ipa-visibility.cc @@ -886,8 +886,12 @@ function_and_variable_visibility (bool whole_program) && vnode->ref_list.referring.length ()) { enum tls_model new_model = decl_default_tls_model (decl); - gcc_checking_assert (new_model >= decl_tls_model (decl)); - set_decl_tls_model (decl, new_model); + STATIC_ASSERT (TLS_MODEL_GLOBAL_DYNAMIC < TLS_MODEL_LOCAL_DYNAMIC); + STATIC_ASSERT (TLS_MODEL_INITIAL_EXEC < TLS_MODEL_LOCAL_EXEC); + /* We'd prefer to assert that recomputed model is not weaker than + what the front-end assigned, but cannot: see PR 107353. */ + if (new_model >= decl_tls_model (decl)) + set_decl_tls_model (decl, new_model); } } }