From patchwork Wed Mar 29 18:23:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 744901 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vtbkN2Cy1z9s2Q for ; Thu, 30 Mar 2017 05:23:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="pLMqyIar"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=bSEycbOK0OG2 A4zfTn/Id66Txji+n+bBI6H40uket396k1iB8qY83OLo1VMj0VDUHdkX0PlA8WSf Mp+BWaMr5j1X5kBlF00Oscwr7BLCN2gLxmNLKuYLVmavJkszeStrwDMy3NsLb9+r Mjj1ABYl5j4dAUAsl5G9l3Pw8ws2EO8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=M/RCQQhS2dOWJ7Is4N ukJ89xbY4=; b=pLMqyIarBZVru7CZg8NBkJA7KhOMYMxkx9J5W0NWpT0bJxb6zW GjO5R2U2fovVZKikVQvoAsDSamuMPaMMPk52J6t1T7Z9aG4PBGQ59xM8FYWmfxiB NlmtLOl9VyqSe/v1T1DFUprdw0DjlGIXtqXM1z7iQigSnLhT88VTVUgcQ= Received: (qmail 78784 invoked by alias); 29 Mar 2017 18:23:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 78683 invoked by uid 89); 29 Mar 2017 18:23:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Mar 2017 18:23:42 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id BE8B31C0687; Wed, 29 Mar 2017 18:23:38 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool , jakub@redhat.com Subject: [PATCH] combine: Fix PR80233 Date: Wed, 29 Mar 2017 18:23:33 +0000 Message-Id: X-IsSubscribed: yes If combine has added an unconditional trap there will be a new basic block as well. It will then end up considering the NOTE_INSN_BASIC_BLOCK as the last_combined_insn, but then it tries to take the DF_INSN_LUID of that and that dereferences a NULL pointer (since such a note is not an INSN_P). This fixes it by not taking non-insns as last_combined_insn. Bootstrapped and tested on powerpc64-linux {-m32,-m64}. Segher 2017-03-29 Segher Boessenkool PR rtl-optimization/80233 * combine.c (combine_instructions): Only take NONDEBUG_INSN_P insns as last_combined_insn. Do not test for BARRIER_P separately. gcc/testsuite/ PR rtl-optimization/80233 * gcc.c-torture/compile/pr80233.c: New testcase. --- gcc/combine.c | 4 ++-- gcc/testsuite/gcc.c-torture/compile/pr80233.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr80233.c diff --git a/gcc/combine.c b/gcc/combine.c index 87e9670..88ac475 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -1250,10 +1250,10 @@ combine_instructions (rtx_insn *f, unsigned int nregs) continue; while (last_combined_insn - && last_combined_insn->deleted ()) + && (!NONDEBUG_INSN_P (last_combined_insn) + || last_combined_insn->deleted ())) last_combined_insn = PREV_INSN (last_combined_insn); if (last_combined_insn == NULL_RTX - || BARRIER_P (last_combined_insn) || BLOCK_FOR_INSN (last_combined_insn) != this_basic_block || DF_INSN_LUID (last_combined_insn) <= DF_INSN_LUID (insn)) last_combined_insn = insn; diff --git a/gcc/testsuite/gcc.c-torture/compile/pr80233.c b/gcc/testsuite/gcc.c-torture/compile/pr80233.c new file mode 100644 index 0000000..eb9b4a4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr80233.c @@ -0,0 +1,22 @@ +/* PR rtl-optimization/80233 */ + +int xg; + +void +t4 (int o9) +{ + int it; + + if (o9 == 0) + { + int fx; + + xg *= it; + if (xg == 0) + it /= 0; + + fx = (it != 0) ? (xg < 0) : (xg / o9); + if (fx != 0) + xg = 0; + } +}