From patchwork Tue May 5 08:26:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1283323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=adacore-com.20150623.gappssmtp.com header.i=@adacore-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=O6kyQW9f; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49GXsq3ZKsz9sP7 for ; Tue, 5 May 2020 18:27:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1706A388B030; Tue, 5 May 2020 08:27:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 6E12C3887019 for ; Tue, 5 May 2020 08:27:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E12C3887019 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=botcazou@adacore.com Received: by mail-wm1-x333.google.com with SMTP id r26so1300170wmh.0 for ; Tue, 05 May 2020 01:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=CI7VQyWzlKFuKzztLPqqQf1qD6TpsF9Qq3xmPon+DrM=; b=O6kyQW9fZktLzI7DIlXr6n9/lADTKx4u1emKeSrxQJdSoxkmkvDCaVFd1iJdVndRi3 uRKQd52TZtxWQ7f2SfIV0AHdO09H1lAu7PskYkHvUiArOJBZe4aCbKs1wNFOpM4kIwiM eF6DVRBHDFH7i06ayG2Nd6ibx6+9BY3+0di8hEHf1CD+gCcHAuVhwGvA4q3RqWedBE/R D4AaaHiQa0poldui9s3KdQfB1/Pb1ALf+hX6EMae9AQcs7hsqYLv4JGo15nIadXC3FpZ I4IqppwMjX+aog9qV2vabqgMapQdT7pX0wN3unxIXyVp9UQuoBbX0+6qznLiycNi59na iBow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=CI7VQyWzlKFuKzztLPqqQf1qD6TpsF9Qq3xmPon+DrM=; b=cIGyStolXrc5BIez2kBA/OGzg4l5sNTdLx+uVlEx7KHXUqwa+aIgCAf9KFgTluwfj+ 6eu3XaSG9xkhfo0Qix2ztIYbDXnqemxkMzLthwNqFZqm+smd77XI1cbR1zINrsqYxw0y mezMy776EJVzJceScDDBEl40V/gpYa2umWEgO1Cq2DF8spEV6YeGgax2E2Z8VEEez9QM t8G0/JjJyX1bU9/PGgEKnB0AzrZi2kZgFOIVLrlODm7EttunxAltQUBXE9M/xKngFcDy CVMwcZ8R+8/0L4HGVwgmc79RJ2arLZ2lIOUafmhnpJMPunilwfqnLheUid4DpPrvTjeD WflA== X-Gm-Message-State: AGi0PuYIxsi7FH5fXtKoS+2ZWpwHI959jy9oyzQEEDYXeHy4Te5dyDLH Z31YPwmCbtHDBA4ybglcs6cHSlEwP0Do2g== X-Google-Smtp-Source: APiQypIZNaaric1p+IVRL3mx3EUS5crdxmzL7IIvqy4oxluB5fGKzb6r/i1lCJmDmZXG8TFk4Jvc/w== X-Received: by 2002:a1c:9e43:: with SMTP id h64mr1948660wme.0.1588667270122; Tue, 05 May 2020 01:27:50 -0700 (PDT) Received: from polaris.localnet ([2a01:e0a:41b:9230:1a03:73ff:fe45:373a]) by smtp.gmail.com with ESMTPSA id n9sm1848097wrv.43.2020.05.05.01.27.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 01:27:48 -0700 (PDT) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: (patch] Do not put incomplete CONSTRUCTORs into static memory Date: Tue, 05 May 2020 10:26:59 +0200 Message-ID: <1673884.m2ZVKc5Joq@polaris> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, the CONSTRUCTOR_NO_CLEARING flag was invented to avoid generating a memset for CONSTRUCTORS that lack elements, but it turns out that the gimplifier can generate a memcpy for them instead, which is even worse performance-wise, so this prevents it from doing that for them. Tested on x86-64/Linux, OK for the mainline? 2020-05-05 Eric Botcazou * gimplify.c (gimplify_init_constructor): Do not put the constructor into static memory if it is not complete. 2020-05-05 Eric Botcazou * gnat.dg/aggr29.adb: New test. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 2f2c51b2d89..7807e30fb2e 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4995,8 +4995,8 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, all-zero initializers (which aren't big enough to merit clearing), and don't try to make bitwise copies of TREE_ADDRESSABLE types. */ - if (valid_const_initializer + && complete_p && !(cleared || num_nonzero_elements == 0) && !TREE_ADDRESSABLE (type)) {