From patchwork Thu Jun 6 14:11:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 249429 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B655F2C007C for ; Fri, 7 Jun 2013 00:11:34 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=Y8OV4frr3R4ijDucz IKHredSMsa9p+Am8Yes0HVsL9aIxYXNaUlPYgmyIzVq714ZzL7VGBTuT58LpIYSp MLKNnl0NuyL9vMuy+rEYVbwlSKdaq/m/O9bREQWVjwzPHf0KOpLZgq3/LAFgQuMY m5NV/J2BY9OoIlQRWRbSgdCJUs= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=lsEzu5dXBm4ndGOA/KnXRkW u5ck=; b=giFtMB3y3Vxd49uaRu3qaFY44YiT6LL0XOzYn/ZckmNJkWu1QfnyLE6 r7xoQ4+SKSvSXcnDt3ZstLLXsRc+cfTlFEEJ9O9XVpMI3c3M6EGZFmP15Ws7GTnk dTZI/gyTN59CnxEBDRldW+kbaA6ymy0mRiLg92D6uFHujWNRXHRA= Received: (qmail 4780 invoked by alias); 6 Jun 2013 14:11:28 -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 4769 invoked by uid 89); 6 Jun 2013 14:11:27 -0000 X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.1 Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 06 Jun 2013 14:11:27 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CE6AAA55F4; Thu, 6 Jun 2013 16:11:24 +0200 (CEST) Date: Thu, 6 Jun 2013 16:11:24 +0200 From: Martin Jambor To: Dehao Chen Cc: Xinliang David Li , Richard Biener , Duncan Sands , GCC Patches Subject: Re: [GOOGLE] More strict checking for call args Message-ID: <20130606141124.GB30912@virgil.suse> Mail-Followup-To: Dehao Chen , Xinliang David Li , Richard Biener , Duncan Sands , GCC Patches References: <51A85C16.1030505@free.fr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Hi, On Tue, Jun 04, 2013 at 05:19:02PM -0700, Dehao Chen wrote: > attached is a testcase that would cause problem when source has changed: > > $ g++ test.cc -O2 -fprofile-generate -DOLD > $ ./a.out > $ g++ test.cc -O2 -fprofile-use > test.cc:34:1: internal compiler error: in operator[], at vec.h:815 > } > ^ > 0x512740 vec::operator[](unsigned int) > ../../gcc/vec.h:815 > 0x512740 vec::operator[](unsigned int) > ../../gcc/vec.h:1244 > 0xf24464 vec::operator[](unsigned int) > ../../gcc/vec.h:815 > 0xf24464 vec::operator[](unsigned int) > ../../gcc/vec.h:1244 > 0xf24464 ipa_get_indirect_edge_target_1 > ../../gcc/ipa-cp.c:1535 > 0x971b9a estimate_edge_devirt_benefit > ../../gcc/ipa-inline-analysis.c:2757 Hm, this seems rather like an omission in ipa_get_indirect_edge_target_1. Since it is called also from inlining, we can have parameter count mismatches... and in fact in non-virtual paths of that function we do check that we don't. Because all callers have to pass known_vals describing all formal parameters of the inline tree root, we should apply the fix below (I've only just started running a bootstrap and testsuite on x86_64, though). OTOH, while I understand that FDO can change inlining sufficiently so that this error occurs, IMHO this should not be caused by outdated profiles but there is somewhere a parameter mismatch in the source. Dehao, can you please check that this patch helps? Richi, if it does and the patch passes bootstrap and tests, is it OK for trunk and 4.8 branch? Thanks and sorry for the trouble, Martin 2013-06-06 Martin Jambor * ipa-cp.c (ipa_get_indirect_edge_target_1): Check that param_index is within bounds at the beginning of the function. Index: src/gcc/ipa-cp.c =================================================================== --- src.orig/gcc/ipa-cp.c +++ src/gcc/ipa-cp.c @@ -1481,7 +1481,8 @@ ipa_get_indirect_edge_target_1 (struct c tree otr_type; tree t; - if (param_index == -1) + if (param_index == -1 + || known_vals.length () <= (unsigned int) param_index) return NULL_TREE; if (!ie->indirect_info->polymorphic) @@ -1516,8 +1517,7 @@ ipa_get_indirect_edge_target_1 (struct c t = NULL; } else - t = (known_vals.length () > (unsigned int) param_index - ? known_vals[param_index] : NULL); + t = NULL; if (t && TREE_CODE (t) == ADDR_EXPR