From patchwork Wed May 13 08:27:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1289104 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=o+f91g6T; 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 49MSTY41s4z9sRK for ; Wed, 13 May 2020 18:27:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11C2C388A823; Wed, 13 May 2020 08:27:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11C2C388A823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589358446; bh=VqlcgOZFxufO3PUpkQB25s7mO90xJ8UQaHJYOsNCwFs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=o+f91g6TO4mp66Cbu1ellVAepO+HVY5UG+lSTNryrIUcLceuc70hg7SuvWUypgoDy mD7GiOyz6nsMLMV7GhNImrcJfRp/MB7kqf80cws4rIdYzgjKsyrNxs0Tkqu1jMcDje WOPchBS0SRK77HXCNP9/wK/XNkS1XF3oAFDUhOpM= 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 [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 3A13B3851C29 for ; Wed, 13 May 2020 08:27:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3A13B3851C29 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-385-FiUE5eTHM1qStyBxbyg1dQ-1; Wed, 13 May 2020 04:27:22 -0400 X-MC-Unique: FiUE5eTHM1qStyBxbyg1dQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47AAB1009454; Wed, 13 May 2020 08:27:21 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-83.ams2.redhat.com [10.36.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BFA7F1036B4B; Wed, 13 May 2020 08:27:20 +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 04D8RHJU020025; Wed, 13 May 2020 10:27:17 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 04D8RGFx020024; Wed, 13 May 2020 10:27:16 +0200 Date: Wed, 13 May 2020 10:27:16 +0200 To: Richard Biener , Jeff Law Subject: [PATCH] Fix -fcompare-debug issue in purge_dead_edges [PR95080] Message-ID: <20200513082716.GN8462@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: Alexandre Oliva , 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 bug used to be latent since introduction of -fcompare-debug. The loop at the start of purge_dead_edges behaves differently between -g0 and -g - if the last insn is a DEBUG_INSN, then it skips not just DEBUG_INSNs but also NOTEs until it finds some other real insn (or bb head), while with -g0 it will not skip any NOTEs, so if we have real_insn note debug_insn // not present with -g0 then with -g it might remove useless REG_EH_REGION from real_insn, while with -g0 it will not. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Yet another option would be not skipping NOTE_P in the loop; I couldn't find in history rationale for why it is done. 2020-05-13 Jakub Jelinek PR debug/95080 * cfgrtl.c (purge_dead_edges): Skip over debug and note insns even if the last insn is a note. * g++.dg/opt/pr95080.C: New test. Jakub --- gcc/cfgrtl.c.jj 2020-04-17 10:32:58.589780140 +0200 +++ gcc/cfgrtl.c 2020-05-12 21:02:09.808395583 +0200 @@ -3100,7 +3100,7 @@ purge_dead_edges (basic_block bb) bool found; edge_iterator ei; - if (DEBUG_INSN_P (insn) && insn != BB_HEAD (bb)) + if ((DEBUG_INSN_P (insn) || NOTE_P (insn)) && insn != BB_HEAD (bb)) do insn = PREV_INSN (insn); while ((DEBUG_INSN_P (insn) || NOTE_P (insn)) && insn != BB_HEAD (bb)); --- gcc/testsuite/g++.dg/opt/pr95080.C.jj 2020-05-12 21:01:09.804295824 +0200 +++ gcc/testsuite/g++.dg/opt/pr95080.C 2020-05-12 21:00:52.738551862 +0200 @@ -0,0 +1,41 @@ +// PR debug/95080 +// { dg-do compile } +// { dg-options "-Og -fcse-follow-jumps -fnon-call-exceptions -fcompare-debug" } + +char *a; + +void baz (); + +static inline bool +bar () +{ + int j = a[0] - 1; + switch (j) + { + case 0: + case 2: + return true; + default: + return false; + } +} + +static inline bool +foo () +{ + if (bar ()) + baz (); + return 0; +} + +struct S +{ + int h; + ~S (); +}; + +S::~S () +{ + if (a[0] == 0) + foo () != h; +}