From patchwork Wed May 22 07:43:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1103227 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-501408-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WG7YfW9z"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4584PN0m3Sz9s7h for ; Wed, 22 May 2019 17:43:19 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=oLeIEAi+0BOpG7GQ MdUa46sse0FCRjjUTO0YiqnaLRcOkjXpV5GB+WUiu77iLEwe4s1DCSKHOc/E8Fjn gK06AUn/NXogjNdlEcBewXhW0lVVzHGcHrjniof+TH4lIFa/MNkx6msGzwfYh3Fm 6muYhoDa2KZE9H8JWl1orEcrz/U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=ylfsrojzRa7GBMIN/nG2O0 arrIY=; b=WG7YfW9zteTLkwdxtfqweP49BCxKSQHnbaStU1wJpq2RvF1lQY7xdY O4WcbGqSUtkmrlFXGnTWJu0v4BNyVMFxjjW22FyuPrRTyuOujCqcIB/WSrF7w8jE eN2EYH8L1YfdtdEdwgxq1W6W4hBbF1ngzMq4RwszYn+reUgp8nias= Received: (qmail 106789 invoked by alias); 22 May 2019 07:43:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 106764 invoked by uid 89); 22 May 2019 07:43:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=decl2c, ebotcazouadacorecom, UD:decl2.c, ebotcazou@adacore.com X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 May 2019 07:43:09 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 48DA281392 for ; Wed, 22 May 2019 09:43:06 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UraT3hUQJOhm for ; Wed, 22 May 2019 09:43:06 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 2595781391 for ; Wed, 22 May 2019 09:43:06 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Backport fix for PR c++/85400 Date: Wed, 22 May 2019 09:43:03 +0200 Message-ID: <5377246.XNt1c5Qdm6@polaris> MIME-Version: 1.0 Jakub asked me to backport the fix for PR c++/85400 initially intended for SPARC/Solaris but which also helps on x86-64/Linux apparently. Tested on the latter platform, applied on the 8 branch. 2019-05-22 Eric Botcazou c-family/ Backport from mainline 2018-05-10 Eric Botcazou PR c++/85400 * c-attribs.c (handle_visibility_attribute): Do not set no_add_attrs. 2019-05-22 Eric Botcazou cp/ Backport from mainline 2018-05-10 Eric Botcazou PR c++/85400 * decl2.c (adjust_var_decl_tls_model): New static function. (comdat_linkage): Call it on a variable. (maybe_make_one_only): Likewise. 2019-05-22 Eric Botcazou * g++.dg/tls/pr85400.C: New test. Index: c-family/c-attribs.c =================================================================== --- c-family/c-attribs.c (revision 270883) +++ c-family/c-attribs.c (working copy) @@ -2310,14 +2310,13 @@ handle_visibility_attribute (tree *node, static tree handle_tls_model_attribute (tree *node, tree name, tree args, - int ARG_UNUSED (flags), bool *no_add_attrs) + int ARG_UNUSED (flags), + bool *ARG_UNUSED (no_add_attrs)) { tree id; tree decl = *node; enum tls_model kind; - *no_add_attrs = true; - if (!VAR_P (decl) || !DECL_THREAD_LOCAL_P (decl)) { warning (OPT_Wattributes, "%qE attribute ignored", name); Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 270883) +++ cp/decl2.c (working copy) @@ -1838,6 +1838,17 @@ mark_vtable_entries (tree decl) } } +/* Adjust the TLS model on variable DECL if need be, typically after + the linkage of DECL has been modified. */ + +static void +adjust_var_decl_tls_model (tree decl) +{ + if (CP_DECL_THREAD_LOCAL_P (decl) + && !lookup_attribute ("tls_model", DECL_ATTRIBUTES (decl))) + set_decl_tls_model (decl, decl_default_tls_model (decl)); +} + /* Set DECL up to have the closest approximation of "initialized common" linkage available. */ @@ -1888,6 +1899,9 @@ comdat_linkage (tree decl) if (TREE_PUBLIC (decl)) DECL_COMDAT (decl) = 1; + + if (VAR_P (decl)) + adjust_var_decl_tls_model (decl); } /* For win32 we also want to put explicit instantiations in @@ -1926,6 +1940,8 @@ maybe_make_one_only (tree decl) /* Mark it needed so we don't forget to emit it. */ node->forced_by_abi = true; TREE_USED (decl) = 1; + + adjust_var_decl_tls_model (decl); } } }