From patchwork Sat Feb 9 22:29:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1039299 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-495641-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="rNj70AZn"; 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 43xmvc3Qplz9s5c for ; Sun, 10 Feb 2019 09:29:59 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=UpqNVbOjYtOBwW2FJuCRpYVRpueD/FCDJuwah10Yi8VboixmHHwTp Ax1FrriPw3PXtkXqVQQuOjDVUMCuxzS6nVNuA77XvyJpyoQ6//v1pX0ICNpFEyp4 AMZfe94miQW2cLsm9fT8dBjRH5CH3OCoFk0mq6JckLaW9Dm8IeB+es= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=GMgrof/ZZw3s9LfNd0/EA7cjQ20=; b=rNj70AZnSdBeDfYXHEH6 rdmLdREYgCKcUlMsKAPy8Z3G4REfFjCkFs3mZAg3grJKWieh8IGogVzyNtal0smL ODF4rbyc618y0MhKeaK8zIQ2BovazrC3t11Y4m2IlnNSnLqd8Y4pLype5tLIU0dt M5zzrokz7zexDTXdu5XZzeE= Received: (qmail 63916 invoked by alias); 9 Feb 2019 22:29:51 -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 63904 invoked by uid 89); 9 Feb 2019 22:29:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=DECL_EXTERNAL, decl_external X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Feb 2019 22:29:50 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 8F57D281EEA; Sat, 9 Feb 2019 23:29:46 +0100 (CET) Date: Sat, 9 Feb 2019 23:29:46 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Do not use TYPE_NEED_CONSTRUCTING in may_be_aliased Message-ID: <20190209222946.ahlhwklage3rp4fk@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, this patch drops test for TYPE_NEEDS_CONSTRUCTING in tree.h and instead sets TREE_READONLY to 0 for external vars of this type. For vars declared locally we drop TREE_READONLY while expanding constructor. Note that I have tried to drop TREE_READONLY always (not only for DECL_EXTERNAL) and it breaks a testcase where constructor is constexpr. So perhaps this is unnecesarily conservative for external vars having constexpr cotr and perhaps it is better done by frontend. Curiously enough, this does not fix the actual testcase in PR88677. Bootstrapped/regtested x86_64-linux, makes sense? PR lto/88777 * ipa-visibility.c (function_and_variable_visibility): Drop TREE_READONLY flag for variables where type needs constructing. * tree.h (may_be_aliased): Do not test TYPE_NEEDS_CONSTRUCTING. Index: ipa-visibility.c =================================================================== --- ipa-visibility.c (revision 268722) +++ ipa-visibility.c (working copy) @@ -810,6 +811,13 @@ function_and_variable_visibility (bool w || ! (ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (vnode->decl)))))) DECL_COMMON (vnode->decl) = 0; + /* For symbols declared locally we clear TREE_READONLY when emitting + the construtor (if one is needed). For external declarations we can + not safely assume that the type is readonly because we may be called + during its construction. */ + if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (vnode->decl)) + && DECL_EXTERNAL (vnode->decl)) + TREE_READONLY (vnode->decl) = 0; if (vnode->weakref) optimize_weakref (vnode); } Index: tree.h =================================================================== --- tree.h (revision 268722) +++ tree.h (working copy) @@ -5371,8 +5371,7 @@ may_be_aliased (const_tree var) || DECL_EXTERNAL (var) || TREE_ADDRESSABLE (var)) && !((TREE_STATIC (var) || TREE_PUBLIC (var) || DECL_EXTERNAL (var)) - && ((TREE_READONLY (var) - && !TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (var))) + && (TREE_READONLY (var) || (TREE_CODE (var) == VAR_DECL && DECL_NONALIASED (var))))); }