From patchwork Thu May 19 08:12:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 54196 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 377613870C03 for ; Thu, 19 May 2022 08:13:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 377613870C03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652947981; bh=O1IC3xlmO35PGy5l0PZTOsCTFJCaVbiG96rWfLRk8lw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ObqTKyQx9odBcL8YQaTCXSyzIdHeaYaTQEHlT3+vycV+Kv9Lw+mkK+Pcgytpi55Wq PL05GmedRSRajhU3EiAmA843GbvhesFKfwUXn3Id+a8a4CJJEMLptoOlAcvUltvV6a bhBEV033eDS9/xL7JqEhNW92IJ84VIUcUY/29GEI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 03C2638515F3 for ; Thu, 19 May 2022 08:12:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 03C2638515F3 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-9PImK9bAPieTeLMjbVoNNA-1; Thu, 19 May 2022 04:12:30 -0400 X-MC-Unique: 9PImK9bAPieTeLMjbVoNNA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CC413294EDD2; Thu, 19 May 2022 08:12:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8DC23400E400; Thu, 19 May 2022 08:12:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 24J8CRRg071428 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 19 May 2022 10:12:27 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 24J8CQdL071427; Thu, 19 May 2022 10:12:26 +0200 Date: Thu, 19 May 2022 10:12:26 +0200 To: Richard Biener Subject: [PATCH] cfgexpand: Yet another spot with debug insns references to global vars without varpool nodes [PR105630] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! This is similar to the earlier patch to avoid having MEM_EXPRs referencing global vars without varpool nodes, but this time the difference is that during gimplification some hashing actually created DECL_RTLs for the n VAR_DECL and the previous change was in the if above this when DECL_RTL is NULL and we are considering creating it. The following patch drops on the floor references to vars where we've optimized away the varpool node even when it has DECL_RTL. Bootstrapped/regtested on x86_64-linux and i686-linux, plus bootstrapped on those without the cfgexpand.cc change, reapplied it and rebuilt stage3 cc1/cc1plus, the resulting cc1/cc1plus binaries on both targets were identical except for the 16-byte executable_checksum (I've done the second bootstraps in the same directory as the first one after moving the previous one elsewhere, so pathnames were the same, just checksum hasn't been regenerated). So, at least on those binaries this patch doesn't affect debug info at all. Ok for trunk? 2022-05-19 Jakub Jelinek PR debug/105630 * cfgexpand.cc (expand_debug_expr): For VAR_DECL, punt for global vars without symtab node even when they have DECL_RTL set. * gcc.dg/pr105630.c: New test. Jakub --- gcc/cfgexpand.cc.jj 2022-05-09 09:09:20.005477502 +0200 +++ gcc/cfgexpand.cc 2022-05-18 13:53:49.622983222 +0200 @@ -4575,6 +4575,10 @@ expand_debug_expr (tree exp) || SYMBOL_REF_DECL (XEXP (op0, 0)) != exp) return NULL; } + else if (VAR_P (exp) + && is_global_var (exp) + && symtab_node::get (exp) == NULL) + return NULL; else op0 = copy_rtx (op0); --- gcc/testsuite/gcc.dg/pr105630.c.jj 2022-05-18 14:02:18.426050242 +0200 +++ gcc/testsuite/gcc.dg/pr105630.c 2022-05-18 14:02:07.103204525 +0200 @@ -0,0 +1,22 @@ +/* PR debug/105630 */ +/* { dg-do compile { target pthread } } */ +/* { dg-options "-O1 -ftree-parallelize-loops=2 -fcompare-debug" } */ + +int m; +static int n; + +void +foo (void) +{ + int *arr[] = { &n, &n, &n }; + int unused = n; + + m = 0; +} + +void +bar (int *arr, int i) +{ + while (i < 1) + arr[i++] = 1; +}