From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id 1D9383857C74 for ; Fri, 7 May 2021 10:21:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1D9383857C74 Received: by mail-ed1-x52d.google.com with SMTP id h10so9570694edt.13 for ; Fri, 07 May 2021 03:21:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EgMhnDlJ5ayfuuXx1cdNychyCNkq1ssfIl1KO22zfO8=; b=rhVoIAzXU6CQmpxTdNBbcr+gZncrY5m75S3GxFI5BbXqaD+KoFlDEBJAXnZbY10LK8 NL0hUf1uIX8Kj34a+2Av5Y4NztVpQJYRxS6TytuRa2+66hDMJ/sh/JlkAW3EiDf9i8qB bgJDDyFCSQBg76V6WFv9qbmh0thPdV05NQabbhDyuZqkOfWbANJsHoUoi/fWVL85V+EL 5cu2zo8tUoDbKaidXnmeODH2em7BTOScoK7bI6SOYAirDs8c/UiKIQV4ahHE0wNX/uEM Y6VyMwDria3a1ra/2Y+8wTIF1Q/XL8wjosgFoWzMBwGPdToTBf5fwTv+nGgih4hmxbY+ WIug== X-Gm-Message-State: AOAM532qTG7FwHarxF9a4l3LnTWsFUvGfOJwp28Izv+xfQDOPXjUjoho OccMg+cOAcRD/Nn05i8t1yzEkjkkv34g7x3o+yI= X-Google-Smtp-Source: ABdhPJzFmNPCHa5E3VR3wKQxX16q3fMUvba1YGgOc3NKYuQp5X9+6scHRoA6wPRLYppuf+8bhwbiXAPQnw/6h9cTx3s= X-Received: by 2002:aa7:c44b:: with SMTP id n11mr10258821edr.214.1620382874146; Fri, 07 May 2021 03:21:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Fri, 7 May 2021 12:21:03 +0200 Message-ID: Subject: Re: [PATCH] middle-end/100464 - avoid spurious TREE_ADDRESSABLE in folding debug stmts To: Richard Biener Cc: GCC Patches , Jason Merrill Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.6 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 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: , X-List-Received-Date: Fri, 07 May 2021 10:21:16 -0000 On Fri, May 7, 2021 at 12:17 PM Richard Biener wrote: > > canonicalize_constructor_val was setting TREE_ADDRESSABLE on bases > of ADDR_EXPRs but that's futile when we're dealing with CTOR values > in debug stmts. This rips out the code which was added for Java > and should have been an assertion when we didn't have debug stmts. > > Bootstrapped and tested on x86_64-unknown-linux-gnu for all languages > which revealed PR100468 for which I added the cp/class.c hunk below. > Re-testing with that in progress. > > OK for trunk and branch? It looks like this C++ code is new in GCC 11. I mislooked, the code is old. This hunk also breaks (or fixes) g++.dg/tree-ssa/array-temp1.C where the gimplifier previously passes the && (flag_merge_constants >= 2 || !TREE_ADDRESSABLE (object)) check guarding it against unifying addresses of different instances of variables. Clearly in the case of the testcase there are addresses to this variable as part of the initializer list construction. So the hunk fixes wrong-code, but it breaks the testcase. Any comments? I can of course change the testcase accordingly. Thanks, Richard. > Thanks, > Richard. > > 2021-05-07 Richard Biener > > PR middle-end/100464 > PR c++/100468 > gcc/ > * gimple-fold.c (canonicalize_constructor_val): Do not set > TREE_ADDRESSABLE. > > gcc/cp/ > * call.c (set_up_extended_ref_temp): Mark the temporary > addressable if the TARGET_EXPR was. > > gcc/testsuite/ > * gcc.dg/pr100464.c: New testcase. > --- > gcc/cp/call.c | 2 ++ > gcc/gimple-fold.c | 4 +++- > gcc/testsuite/gcc.dg/pr100464.c | 16 ++++++++++++++++ > 3 files changed, 21 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/pr100464.c > > diff --git a/gcc/cp/call.c b/gcc/cp/call.c > index 57bac05fe70..ea97be22f07 100644 > --- a/gcc/cp/call.c > +++ b/gcc/cp/call.c > @@ -12478,6 +12478,8 @@ set_up_extended_ref_temp (tree decl, tree expr, vec **cleanups, > VAR. */ > if (TREE_CODE (expr) != TARGET_EXPR) > expr = get_target_expr (expr); > + else if (TREE_ADDRESSABLE (expr)) > + TREE_ADDRESSABLE (var) = 1; > > if (TREE_CODE (decl) == FIELD_DECL > && extra_warnings && !TREE_NO_WARNING (decl)) > diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c > index aa33779b753..768ef89d876 100644 > --- a/gcc/gimple-fold.c > +++ b/gcc/gimple-fold.c > @@ -245,7 +245,9 @@ canonicalize_constructor_val (tree cval, tree from_decl) > if (TREE_TYPE (base) == error_mark_node) > return NULL_TREE; > if (VAR_P (base)) > - TREE_ADDRESSABLE (base) = 1; > + /* ??? We should be able to assert that TREE_ADDRESSABLE is set, > + but since the use can be in a debug stmt we can't. */ > + ; > else if (TREE_CODE (base) == FUNCTION_DECL) > { > /* Make sure we create a cgraph node for functions we'll reference. > diff --git a/gcc/testsuite/gcc.dg/pr100464.c b/gcc/testsuite/gcc.dg/pr100464.c > new file mode 100644 > index 00000000000..46cc37dff54 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr100464.c > @@ -0,0 +1,16 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O3 -fcompare-debug" } */ > + > +int *a; > +static int b, c, d, e, g, h; > +int f; > +void i() { > + int *j[] = {&e, &b, &b, &d, &b, &b, &g, &e, &g, &b, &b, > + &b, &b, &g, &e, &e, &b, &b, &d, &b, &b, &e, > + &e, &g, &b, &b, &b, &b, &g, &e, &g, &c, &e}; > + int **k = &j[5]; > + for (; f;) > + b |= *a; > + *k = &h; > +} > +int main() {} > -- > 2.26.2