From patchwork Tue Jun 19 08:10:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 931461 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-479994-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="Gy6rmhPS"; 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 4190z21Mdsz9s2R for ; Tue, 19 Jun 2018 18:11:09 +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=xUt7h+iaesh5eiv7 0H5mBRVRwii2HHIEs0Xaixl5+dR1o1rkh+wdKBBXhzm2yZ8WxaHE4xx+zH48eB6Q KlIgL5RxeIfRSHofNQDo9WwJVMjnJDfnq/JLmhbgPaCbB4D4eQExgPWmuKE4laej XN0qJlpszyy9I7ELHFRk5SDYBaA= 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=m+r1csvq7QDGWH8xFWKAVc vun5k=; b=Gy6rmhPSbvjRdx4jiyhkAQKTbrXZQBtDvkRtLRD19gLgItJh4/6LQj LMSkbL4sgIX3XVoBqAR7Oyk3k4lxRmCRvTnYrNn84m0RrcuQas+/Xy2hngCgJHiJ CMCkkL6aYPt0MaxMOvKP1Wxe20YeXBcJVtpvl3UaKpghpcAdEU+10= Received: (qmail 62334 invoked by alias); 19 Jun 2018 08:11:02 -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 62320 invoked by uid 89); 19 Jun 2018 08:11:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Really, outcome 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; Tue, 19 Jun 2018 08:11:00 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 9BA7581397 for ; Tue, 19 Jun 2018 10:10:57 +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 oRMj90oZ6Fun for ; Tue, 19 Jun 2018 10:10:57 +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 65F2081395 for ; Tue, 19 Jun 2018 10:10:57 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix oversight in gimplifier Date: Tue, 19 Jun 2018 10:10:09 +0200 Message-ID: <27810203.vj4aXM48tj@polaris> MIME-Version: 1.0 Hi, as spotted by Richard B., there is an oversight in the implementation of CONSTRUCTOR_NO_CLEARING in the gimplifier: it may be overruled depending on the outcome of the clearing heuristics. Tested on x86-64/Linux, OK for the mainline? Can I put this on the 8 and 7 branches too (only the Ada compiler sets the flag at the moment)? 2018-06-19 Eric Botcazou * gimplify.c (gimplify_init_constructor): Really never clear for an incomplete constructor if CONSTRUCTOR_NO_CLEARING is set. 2018-06-19 Eric Botcazou * gnat.dg/aggr24.adb: New test. * gnat.dg/aggr24_pkg.ad[sb]: New helper. Index: gimplify.c =================================================================== --- gimplify.c (revision 261687) +++ gimplify.c (working copy) @@ -4795,7 +4795,7 @@ gimplify_init_constructor (tree *expr_p, objects. Initializers for such objects must explicitly set every field that needs to be set. */ cleared = false; - else if (!complete_p && !CONSTRUCTOR_NO_CLEARING (ctor)) + else if (!complete_p) /* If the constructor isn't complete, clear the whole object beforehand, unless CONSTRUCTOR_NO_CLEARING is set on it. @@ -4804,7 +4804,7 @@ gimplify_init_constructor (tree *expr_p, we'd need to *find* the elements that are not present, and that requires trickery to avoid quadratic compile-time behavior in large cases or excessive memory use in small cases. */ - cleared = true; + cleared = !CONSTRUCTOR_NO_CLEARING (ctor); else if (num_ctor_elements - num_nonzero_elements > CLEAR_RATIO (optimize_function_for_speed_p (cfun)) && num_nonzero_elements < num_ctor_elements / 4)