From patchwork Wed Mar 16 08:13:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 598158 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 3qQ45j6JbMz9t3V for ; Wed, 16 Mar 2016 19:14:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=p96ogNXX; 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 :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=AD+7QPOlaxbcWSSEegmIr5Kwc2OgETUwy5zUHjjYd6zisYx1AHH1O EEDMt94e64RyeUCofAfMofn8Cw0SqqYsS8H+Bg/EUjx9jH9OKd6AosEy5LCiSr4y L6+e796RpvnK0AKRdKN4nXHWhw3UiwGBGOiaQuUJEDBPDxj8Aq50dE= 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 :subject:to:message-id:date:mime-version:content-type; s= default; bh=TWN9QUFg23ahdhLtPxD0OUmuBNw=; b=p96ogNXXpGABRRYoujeJ uoaaBRRv891BQcKRyo77qeQvFLjSvnbknEEn7CHJwQiw7ICZ3iiFo+t+BK9CMmYc GPA9z0L0L6LA/Wb+biW0sEsMhJdo0NBGDA/g8H34N9BT448RlkdHM6CroC8hlOl4 DUzd2Q4FrudQEFp8nyjPuQ0= Received: (qmail 109513 invoked by alias); 16 Mar 2016 08:14:20 -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 109495 invoked by uid 89); 16 Mar 2016 08:14:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Safely, Hx-languages-length:1684, 2016-03-16, 20160316 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 16 Mar 2016 08:14:10 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-03.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ag6ak-0000S3-CD from Tom_deVries@mentor.com ; Wed, 16 Mar 2016 01:14:06 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-03.mgc.mentorg.com (137.202.0.108) with Microsoft SMTP Server id 14.3.224.2; Wed, 16 Mar 2016 08:14:04 +0000 From: Tom de Vries Subject: [PATCH, PR70187] Safely use nodes[0] in possible_polymorphic_call_targets To: GCC Patches , Jan Hubicka Message-ID: <56E915B8.5090503@mentor.com> Date: Wed, 16 Mar 2016 09:13:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 Hi, this patch fixes lto PR70187, a 6 regression. We run into an ICE in in possible_polymorphic_call_targets when accessing nodes[0]->decl because nodes == vNULL: ... if (!outer_type->all_derivations_known) { if (!speculative && final_warning_records && TREE_CODE (TREE_TYPE (nodes[0]->decl)) == METHOD_TYPE) { if (complete && nodes.length () == 1 && warn_suggest_final_types && !outer_type->derived_types.length ()) { ... The patch fixes this by moving the 'nodes.length () == 1' test to before the use of nodes[0]. Bootstrapped and reg-tested on x86_64. OK for stage4 trunk? Thanks, - Tom Safely use nodes[0] in possible_polymorphic_call_targets 2016-03-16 Tom de Vries PR lto/70187 * ipa-devirt.c (possible_polymorphic_call_targets): Move nodes.length () == 1 test to before first nodes[0] access. --- gcc/ipa-devirt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index e4fb562..4df171b 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -3178,10 +3178,10 @@ possible_polymorphic_call_targets (tree otr_type, if (!outer_type->all_derivations_known) { if (!speculative && final_warning_records + && nodes.length () == 1 && TREE_CODE (TREE_TYPE (nodes[0]->decl)) == METHOD_TYPE) { if (complete - && nodes.length () == 1 && warn_suggest_final_types && !outer_type->derived_types.length ()) { @@ -3197,7 +3197,6 @@ possible_polymorphic_call_targets (tree otr_type, } if (complete && warn_suggest_final_methods - && nodes.length () == 1 && types_same_for_odr (DECL_CONTEXT (nodes[0]->decl), outer_type->type)) {