From patchwork Wed Jan 11 09:00:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Ostapenko X-Patchwork-Id: 713633 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3tz2th55Fsz9t0q for ; Wed, 11 Jan 2017 20:01:15 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="aSQrB10P"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type :references; q=dns; s=default; b=KT6EY9X9P5+7QWgzrkeHXNHlEhobsix mohgaR+/Hi5Kax4OfKv2qUZdR4J7UT5ZNf2wdKAvurT46jDM5WK5RMqhA+KBd8+w GUPe9GXoqCYVQxOQtHq8Byr59Arc/kMWFq88axEYO4YeqBEp/dp3e2WIVfTn7erm Ox640VG5y494= 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 :subject:to:message-id:date:mime-version:content-type :references; s=default; bh=DjHeGdm1RQnP+nYBh59Ic81mYkU=; b=aSQrB 10P/SVhIysZVQxzA/F9r8syytUngaVXsSSLwRAy1AR4ixr7q1zq2xdqtp2GmZtWU AjDZ7ZvYHiQqghRRJss8nGSAuci0nKFNulOtPAb1GYgWTy6p/TxsgEvlxg5Y8oof RU7mQtW2sZ1SSjcC8tsCy9z231555gIq+U0qx4= Received: (qmail 36718 invoked by alias); 11 Jan 2017 09:01:07 -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 36704 invoked by uid 89); 11 Jan 2017 09:01:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=fiasco, Hx-spam-relays-external:sk:2017011, H*RU:sk:2017011, HContent-type:mixed X-HELO: mailout2.w1.samsung.com Received: from mailout2.w1.samsung.com (HELO mailout2.w1.samsung.com) (210.118.77.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Jan 2017 09:00:54 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OJL005BTYDCLI70@mailout2.w1.samsung.com> for gcc-patches@gcc.gnu.org; Wed, 11 Jan 2017 09:00:49 +0000 (GMT) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170111090049eucas1p21ac968a85d08212380e717feea1dbec9~YrA0NpXz12143421434eucas1p22 for ; Wed, 11 Jan 2017 09:00:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges4.samsung.com (EUCPMTA) with SMTP id AD.35.28517.044F5785; Wed, 11 Jan 2017 09:00:49 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170111090048eucas1p26b3a2c088f090ca203458f5be358f3ed~YrAzj3mX-2141321413eucas1p2A for ; Wed, 11 Jan 2017 09:00:48 +0000 (GMT) Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 32.00.06687.474F5785; Wed, 11 Jan 2017 09:01:40 +0000 (GMT) Received: from [106.109.129.18] by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OJL0055NYDB1X00@eusync2.samsung.com> for gcc-patches@gcc.gnu.org; Wed, 11 Jan 2017 09:00:48 +0000 (GMT) From: Maxim Ostapenko Subject: [PATCH][PR lto/79042] Propagate node->dynamically_initialized bit for varpool node to LTRANS stage. To: GCC Patches Message-id: <5875F43C.6080901@samsung.com> Date: Wed, 11 Jan 2017 12:00:44 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-version: 1.0 Content-type: multipart/mixed; boundary=------------070800000001060300070301 X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170111090048eucas1p26b3a2c088f090ca203458f5be358f3ed X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?TWFrc2ltIE9zdGFwZW5rbxtTUlItU1cgVG9vbHMgTGFiGw==?= =?UTF-8?B?7IK87ISx7KCE7J6QG0VuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?TWF4aW0gT3N0YXBlbmtvG1NSUi1TVyBUb29scyBMYWIbU2Ft?= =?UTF-8?B?c3VuZ8KgRWxlY3Ryb25pY3MbRW5naW5lZXI=?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1Nw==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170111090048eucas1p26b3a2c088f090ca203458f5be358f3ed X-RootMTR: 20170111090048eucas1p26b3a2c088f090ca203458f5be358f3ed References: X-IsSubscribed: yes Hi, as mentioned in PR, LTO doesn't propagate node->dynamically_initialized bit for varpool nodes that leads to ASan fails to detect initialization order fiasco even for trivial example (e.g. from here: https://github.com/google/sanitizers/wiki/AddressSanitizerExampleInitOrderFiasco). This trivial patch fixes the issue. Regtested on x86_64-unknown-linux-gnu, OK for mainline? -Maxim gcc/ChangeLog: 2017-01-11 Maxim Ostapenko PR lto/79042 * lto-cgraph.c (lto_output_varpool_node): Pack dynamically_initialized bit. (input_varpool_node): Unpack dynamically_initialized bit. diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index c0321f7..77605f7 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -626,6 +626,7 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, varpool_node *node, } bp_pack_value (&bp, node->tls_model, 3); bp_pack_value (&bp, node->used_by_single_function, 1); + bp_pack_value (&bp, node->dynamically_initialized, 1); bp_pack_value (&bp, node->need_bounds_init, 1); streamer_write_bitpack (&bp); @@ -1400,6 +1401,7 @@ input_varpool_node (struct lto_file_decl_data *file_data, node->alias_target = get_alias_symbol (node->decl); node->tls_model = (enum tls_model)bp_unpack_value (&bp, 3); node->used_by_single_function = (enum tls_model)bp_unpack_value (&bp, 1); + node->dynamically_initialized = bp_unpack_value (&bp, 1); node->need_bounds_init = bp_unpack_value (&bp, 1); group = read_identifier (ib); if (group)