From patchwork Mon Mar 2 05:34:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 444911 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 8E0CE1400EA for ; Mon, 2 Mar 2015 16:34:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ILfKCExL; dkim-adsp=none (unprotected policy); 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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=VpYXz3DfbaDvAymooXtb4Cnbmy57rODCwm+uwUtDEJqRrp klYWfPwHP05qQ5kVl7DKpxgSMvVEqWEgj8tx210s3k//YpyoNir9pAD9bUwI0mur MUi9/K1imgJbS+V+ZNgpZZevrk4za9tgqZ1u08wmUNsy0lz5btvM7s6WzH/IM= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=1VeeGs+93XknLy4R6pnIxaCnC7Q=; b=ILfKCExLx+olFH+D4BrL uRNujrtoCFmSGNvLgBRT463U6OzFwW2mYjejBNJ4GgOWYbhdqUEoqMOOwvANigVR UJ5a2ClYuUEITayCL2ugPLsEQc5OfO41BDTFUp37ApJpakMDU2+n4CMFV+tE+hnk IWSxurKipNrUC/Q3y+edqa4= Received: (qmail 16236 invoked by alias); 2 Mar 2015 05:34:05 -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 16222 invoked by uid 89); 2 Mar 2015 05:34:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 02 Mar 2015 05:34:03 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t225Y2Oe013391 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 2 Mar 2015 00:34:02 -0500 Received: from reynosa.quesejoda.com (vpn-59-8.rdu2.redhat.com [10.10.59.8]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t225Y0pY024940; Mon, 2 Mar 2015 00:34:00 -0500 Message-ID: <54F3F648.8090400@redhat.com> Date: Sun, 01 Mar 2015 21:34:00 -0800 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: gcc-patches , Jan Hubicka Subject: [patch/committed] PR middle-end/65233 make walk-ssa_copies handle empty PHIs As I mention in the PR... What's happening here is that the ipa_polymorphic_call_context constructor is calling walk_ssa_copies on a PHI node that has no arguments. This happens because finalize_jump_threads eventually removes some PHI arguments as it's redirecting some edges, leaving a PHI with no arguments: SR.33_23 = PHI <> This should get cleaned up later, but the IPA polymorphic code gets called during the actual CFG clean-up, and walk_ssa_copies cannot handle an empty PHI. Approved by Honza. Fully tested on x86-64 Linux and verified that the patch fixes the ICE on an x86-64 Linux cross aarch64-linux-gnu cc1plus. Committed to mainline. commit cdb5a8f26178f61d6a2fdb2543f6c8b4c7136c94 Author: Aldy Hernandez Date: Sun Mar 1 21:21:37 2015 -0800 PR middle-end/65233 * ipa-polymorphic-call.c (walk_ssa_copies): Handle empty PHIs. diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index aaa549e..13cc7f6 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -835,7 +835,10 @@ walk_ssa_copies (tree op, hash_set **global_visited = NULL) { gimple phi = SSA_NAME_DEF_STMT (op); - if (gimple_phi_num_args (phi) > 2) + if (gimple_phi_num_args (phi) > 2 + /* We can be called while cleaning up the CFG and can + have empty PHIs about to be removed. */ + || gimple_phi_num_args (phi) == 0) goto done; if (gimple_phi_num_args (phi) == 1) op = gimple_phi_arg_def (phi, 0);