From patchwork Sat Mar 14 07:43:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1254819 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=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=NsONXYRE; 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 48fZMK1NLxz9sNg for ; Sat, 14 Mar 2020 18:44:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D5282387701E; Sat, 14 Mar 2020 07:44:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5282387701E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584171848; bh=7yICHXLlM6SA2DBx8u9Rbvtl+EtsUmhhUd0Xj8VnF8Y=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=NsONXYRElvKmve8MQfDe/UKY2WKDsh+gwQB8QvFAKY2IWtuay1+E/nhW4ZhUBXL/U oHxjru9FafKAg1CEqztjqZtdtY3tyJWV1yWOZWs1YDqJUpp2XQTBpzhne1Uv4n8W+6 +xaWnVuB1jagi6EWwOwoL4T8OVPtSkrCxEgqUTao= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 226F5385E828 for ; Sat, 14 Mar 2020 07:44:06 +0000 (GMT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-Rr4fzfzFMz6EPH2cPqhLQw-1; Sat, 14 Mar 2020 03:44:00 -0400 X-MC-Unique: Rr4fzfzFMz6EPH2cPqhLQw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EBE9B1005509; Sat, 14 Mar 2020 07:43:59 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F36473864; Sat, 14 Mar 2020 07:43:59 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 02E7hvL0022857; Sat, 14 Mar 2020 08:43:57 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 02E7huFM022856; Sat, 14 Mar 2020 08:43:56 +0100 Date: Sat, 14 Mar 2020 08:43:56 +0100 To: Richard Biener Subject: [PATCH] tree-inline: Fix a -fcompare-debug issue in the inliner [PR94167] Message-ID: <20200314074356.GB2156@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-10.2 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! The following testcase fails with -fcompare-debug. The problem is that bar is marked as address_taken only with -g and not without. I've tracked it down to insert_init_stmt calling gimple_regimplify_operands even on DEBUG_STMTs. That function will just insert normal stmts before the DEBUG_STMT if the DEBUG_STMT operand isn't gimple val or invariant. While DCE will turn those statements into debug temporaries, it can cause differences in SSA_NAMEs and more importantly, the ipa references are generated from those before the DCE happens. On the testcase, the DEBUG_STMT value is (int)bar. We could generate DEBUG_STMTs with debug temporaries instead, but I fail to see the reason to do that, DEBUG_STMTs allow other expressions and all we want to ensure is that the expressions aren't too large (arbitrarily complex), but during inlining/function versioning I don't see why something would queue a DEBUG_STMT with arbitrarily complex expressions in there. So, this patch just doesn't regimplify DEBUG_STMTs. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2020-03-14 Jakub Jelinek PR debug/94167 * tree-inline.c (insert_init_stmt): Don't gimple_regimplify_operands DEBUG_STMTs. * gcc.dg/pr94167.c: New test. Jakub --- gcc/tree-inline.c.jj 2020-03-04 12:58:35.033528551 +0100 +++ gcc/tree-inline.c 2020-03-13 16:19:04.129493354 +0100 @@ -3361,10 +3361,10 @@ insert_init_stmt (copy_body_data *id, ba gimple_assign_set_rhs1 (init_stmt, rhs); } gsi_insert_after (&si, init_stmt, GSI_NEW_STMT); - gimple_regimplify_operands (init_stmt, &si); - if (!is_gimple_debug (init_stmt)) { + gimple_regimplify_operands (init_stmt, &si); + tree def = gimple_assign_lhs (init_stmt); insert_init_debug_bind (id, bb, def, def, init_stmt); } --- gcc/testsuite/gcc.dg/pr94167.c.jj 2020-03-13 16:33:34.046632902 +0100 +++ gcc/testsuite/gcc.dg/pr94167.c 2020-03-13 16:33:08.353012748 +0100 @@ -0,0 +1,33 @@ +/* PR debug/94167 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +struct S { int g, h; signed char i; int j; signed char k; int l[4]; } a, c; +struct T { signed char g; } e; +int *b, d; +static void foo (); + +void +bar (void) +{ + while (d) + { + int k; + struct T f[3]; + foo (bar, a); + for (k = 0;; k++) + f[k] = e; + } +} + +static inline void +foo (int x, struct S y, struct T z) +{ + for (z.g = 2; z.g; z.g--) + { + c = a = y; + *b |= 6; + if (y.g) + break; + } +}