From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 588433858023 for ; Mon, 8 Aug 2022 07:59:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 588433858023 Received: by mail-ed1-x532.google.com with SMTP id o22so10244148edc.10 for ; Mon, 08 Aug 2022 00:59:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RpGKxWdfsfTI45cUOYRmdYHk8LmT31TwxkhBVAClt44=; b=7A+yOzN60XQinrHwgCDFboc3vJrcCCDqajNHpqaRSbZ5jwVXAPJJ6Quww3Am731na2 h2bweu6tYbixgMxvFILDa1CkqN9TvWqmBOkheabaP0Jxmq6YVrJHHRkrXb+sFQ/etLDe vcUqi+hGsnzyDgg5CqEFtBL1oUI56uy7EJxz6YHAXGZF/fw7L1M/RWL2zVwNo4NuYpGO OqWtIh7SHEcG/Ga4XXC64aj+Igb0dcgbXF9CDb5Gqfkv05HkS7Y4xRA5kr9ahhoYFO4C hV2xiecvBtnv4tzNW4MVl925wt1MB8U38d8KVj0L1KxlnctJtNSGPkVyJq4sO2HxRIZv bjUw== X-Gm-Message-State: ACgBeo2fILuxf2Gp6BBk44wHv99xY3amSNoihN4LLMtAU7kaRe26/Sol 4a+cgVOTiyw5J8LQDwop0CG3CRwb821OIbPrlNM= X-Google-Smtp-Source: AA6agR6ehcIUeKA1YG+xWYAm1XcbDu3tLOhSRrlnHsLX2XcNX4r6PD3MaM5Dx51QgoaW34eYYWuRbmXuGlxUBCa6bCE= X-Received: by 2002:aa7:d6da:0:b0:43f:99fb:f3aa with SMTP id x26-20020aa7d6da000000b0043f99fbf3aamr12657218edr.370.1659945573030; Mon, 08 Aug 2022 00:59:33 -0700 (PDT) MIME-Version: 1.0 References: <1659929826-10136-1-git-send-email-apinski@marvell.com> In-Reply-To: <1659929826-10136-1-git-send-email-apinski@marvell.com> From: Richard Biener Date: Mon, 8 Aug 2022 09:59:20 +0200 Message-ID: Subject: Re: [PATCH] Fix middle-end/103645: empty struct store not removed when using compound literal To: Andrew Pinski Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-List-Received-Date: Mon, 08 Aug 2022 07:59:36 -0000 On Mon, Aug 8, 2022 at 5:38 AM apinski--- via Gcc-patches wrote: > > From: Andrew Pinski > > For compound literals empty struct stores are not removed as they go down a > different path of the gimplifier; trying to optimize the init constructor. > This fixes the problem by not adding the gimple assignment at the end > of gimplify_init_constructor if it was an empty type. > > Note this updates gcc.dg/pr87052.c where we had: > const char d[0] = { }; > And was expecting a store to d but after this, there is no store > as the decl's type is zero in size. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. OK. > gcc/ChangeLog: > > PR middle-end/103645 > * gimplify.c (gimplify_init_constructor): Don't build/add > gimple assignment of an empty type. > > testsuite/ChangeLog: > * gcc.dg/pr87052.c: Update d var to expect nothing. > --- > gcc/gimplify.cc | 7 +++++-- > gcc/testsuite/gcc.dg/pr87052.c | 6 +++--- > 2 files changed, 8 insertions(+), 5 deletions(-) > > diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc > index 2ac7ca0855e..f0fbdb48012 100644 > --- a/gcc/gimplify.cc > +++ b/gcc/gimplify.cc > @@ -5488,8 +5488,11 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, > if (ret == GS_ERROR) > return GS_ERROR; > /* If we have gimplified both sides of the initializer but have > - not emitted an assignment, do so now. */ > - if (*expr_p) > + not emitted an assignment, do so now. */ > + if (*expr_p > + /* If the type is an empty type, we don't need to emit the > + assignment. */ > + && !is_empty_type (TREE_TYPE (TREE_OPERAND (*expr_p, 0)))) > { > tree lhs = TREE_OPERAND (*expr_p, 0); > tree rhs = TREE_OPERAND (*expr_p, 1); > diff --git a/gcc/testsuite/gcc.dg/pr87052.c b/gcc/testsuite/gcc.dg/pr87052.c > index 18e092c4674..796fe6440c1 100644 > --- a/gcc/testsuite/gcc.dg/pr87052.c > +++ b/gcc/testsuite/gcc.dg/pr87052.c > @@ -23,8 +23,7 @@ void test (void) > > const char d[0] = { }; > > - /* Expect the following: > - d = ""; */ > + /* Expect nothing. */ > > const char e[0] = ""; > > @@ -36,6 +35,7 @@ void test (void) > /* { dg-final { scan-tree-dump-times "a = \"\\\\x00ab\";" 1 "gimple" } } > { dg-final { scan-tree-dump-times "b = \"a\\\\x00bc\";" 1 "gimple" } } > { dg-final { scan-tree-dump-times "c = \"\";" 1 "gimple" } } > - { dg-final { scan-tree-dump-times "d = { *};" 1 "gimple" } } > + { dg-final { scan-tree-dump-times "d = " 1 "gimple" } } > + { dg-final { scan-tree-dump-times "d = {CLOBBER\\(eol\\)}" 1 "gimple" } } > { dg-final { scan-tree-dump-times "e = " 1 "gimple" } } > { dg-final { scan-tree-dump-times "e = {CLOBBER\\(eol\\)}" 1 "gimple" } } */ > -- > 2.27.0 >