From patchwork Wed Apr 20 16:50:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1619669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=GrZYGdW8; dkim-atps=neutral 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kk6CX3GYfz9sFq for ; Thu, 21 Apr 2022 02:52:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A4EFB385736D for ; Wed, 20 Apr 2022 16:52:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4EFB385736D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1650473525; bh=CMF+tQUwGH8snNhcyWR5BapNcbIvsSW8Kp00dauNIXE=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=GrZYGdW8IyeT/YbwtP17jcjpJW+ZUfVToVJxoCgQpT6l5hou4aa8bdiklNdtu3lfy k7fcXHIDhKnMnkoIUHvWv2Gq/fmbeDb+6fX8k+v7C+4ixPqwcsUpVi30eHPWELZPMd N260m9JiY0ka6b8kdTEvkeHs7EJIR9YuYs6EXEKE= 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 E3BB93857378 for ; Wed, 20 Apr 2022 16:50:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E3BB93857378 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-197-Rfgp6813MeCxdMKc9VrhEQ-1; Wed, 20 Apr 2022 12:50:46 -0400 X-MC-Unique: Rfgp6813MeCxdMKc9VrhEQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A13F1014A61; Wed, 20 Apr 2022 16:50:44 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2687C40D0166; Wed, 20 Apr 2022 16:50:44 +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 23KGofYX2405361 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 20 Apr 2022 18:50:41 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 23KGoeOr2405360; Wed, 20 Apr 2022 18:50:40 +0200 Date: Wed, 20 Apr 2022 18:50:40 +0200 To: Richard Biener , Jeff Law Subject: [PATCH] emit-rtl: Fix -fcompare-debug bug with label references in debug insns [PR105203] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! When we compute LABEL_NUSES from scratch, mark_all_labels doesn't call mark_jump_label on DEBUG_INSNs: if (NONDEBUG_INSN_P (insn)) mark_jump_label (PATTERN (insn), insn, 0); and so doesn't increment LABEL_NUSES from references in DEBUG_INSNs. But, when we call emit_copy_of_insn_after e.g. when duplicating some DEBUG_INSNs, we call it even on those, which then results in LABEL_NUSES differences and -fcompare-debug failures. The following patch makes sure we don't call it on DEBUG_INSNs. Bootstrapped/regtested on powerpc64le-linux, ok for trunk? 2022-04-20 Jakub Jelinek PR debug/105203 * emit-rtl.cc (emit_copy_of_insn_after): Don't call mark_jump_label on DEBUG_INSNs. * gfortran.dg/g77/pr105203.f: New test. Jakub --- gcc/emit-rtl.cc.jj 2022-02-23 09:17:04.805125253 +0100 +++ gcc/emit-rtl.cc 2022-04-20 10:26:44.972198107 +0200 @@ -6440,7 +6440,8 @@ emit_copy_of_insn_after (rtx_insn *insn, } /* Update LABEL_NUSES. */ - mark_jump_label (PATTERN (new_rtx), new_rtx, 0); + if (NONDEBUG_INSN_P (insn)) + mark_jump_label (PATTERN (new_rtx), new_rtx, 0); INSN_LOCATION (new_rtx) = INSN_LOCATION (insn); --- gcc/testsuite/gfortran.dg/g77/pr105203.f.jj 2022-04-20 10:29:44.830696254 +0200 +++ gcc/testsuite/gfortran.dg/g77/pr105203.f 2022-04-20 10:31:13.532463772 +0200 @@ -0,0 +1,20 @@ +C Test case for PR debug/105203 +C Origin: kmccarty@princeton.edu +C +C { dg-do compile } +C { dg-options "-O2 -fcompare-debug -ftracer -w" } +C { dg-additional-options "-fPIC" { target fpic } } + SUBROUTINE FOO (B) + + 10 CALL BAR (A) + ASSIGN 20 TO M + IF (100.LT.A) GOTO 10 + GOTO 40 +C + 20 IF (B.LT.ABS(A)) GOTO 10 + ASSIGN 30 TO M + GOTO 40 +C + 30 ASSIGN 10 TO M + 40 GOTO M,(10,20,30) + END