From patchwork Thu Jan 11 10:16:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 859005 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-470819-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="N5lho82i"; dkim-atps=neutral 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 3zHMH94J5kz9ryr for ; Thu, 11 Jan 2018 21:16:37 +1100 (AEDT) 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=RHmyZIwK9mboHjlm2/T5BM7s39HfHdKOw47tQmlI1D+ebyhIjdePa k3AOmyZYRRoDWh1LY3OH8x2WuqZMteEFOcLVa/VB+CBW7unVsOc1sPg3S4/S+qxZ OEjxt7da7feyGmMwHkYXeuuhPaTXXLTCO1hwAGgXlU7sWClcPZkpjQ= 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:subject:message-id:mime-version:content-type; s= default; bh=8NMXLCjLIKcD8/D2aoS07wuXAB4=; b=N5lho82iXzP/XA2Sz/EW lercJysTvvoTamYJRtFik+nfGzniko2L1ZSxdVD/J4Wv8CeRUUS/Dlcd+kxvCD2u r/87vWsb+jzFiHJ+WTPbJ5ASHg9f+9q4zPmPlHv5Nm/+7YOpi04m6fgxiQ+8O3q4 re4MyTAzgzBaj7M25OekJcc= Received: (qmail 59403 invoked by alias); 11 Jan 2018 10:16:23 -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 59329 invoked by uid 89); 11 Jan 2018 10:16:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Jan 2018 10:16:21 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id C82FF5473FE; Thu, 11 Jan 2018 11:16:18 +0100 (CET) Date: Thu, 11 Jan 2018 11:16:18 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix ICE in partial inlining profile scaling Message-ID: <20180111101618.GA96001@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Hi, ipa-fnsplit sometimes ICEs on profile update because profile_count::adjust_for_ipa_scaling is called too early. Bootstrapped/regtested x86_64-linux, will commit it shortly. PR middle-end/83718 * tree-inline.c (copy_cfg_body): Adjust num&den for scaling after they are computed. * g++.dg/torture/pr83718.C: New testcase. Index: tree-inline.c =================================================================== --- tree-inline.c (revision 256479) +++ tree-inline.c (working copy) @@ -2683,8 +2683,6 @@ copy_cfg_body (copy_body_data * id, profile_count den = ENTRY_BLOCK_PTR_FOR_FN (src_cfun)->count; profile_count num = entry_block_map->count; - profile_count::adjust_for_ipa_scaling (&num, &den); - cfun_to_copy = id->src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl); /* Register specific tree functions. */ @@ -2707,6 +2705,8 @@ copy_cfg_body (copy_body_data * id, ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = den; } + profile_count::adjust_for_ipa_scaling (&num, &den); + /* Must have a CFG here at this point. */ gcc_assert (ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (callee_fndecl))); Index: testsuite/g++.dg/torture/pr83718.C =================================================================== --- testsuite/g++.dg/torture/pr83718.C (revision 0) +++ testsuite/g++.dg/torture/pr83718.C (working copy) @@ -0,0 +1,115 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=c++11" } */ + +class a +{ +public: + int c (const char *); +}; +class B +{ + virtual int *d (a, bool); +}; + +bool e, f, g; + +class: B +{ + int ah; + int * + d (a, bool) + { + if (e) + return &ah; + a bj; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (g) + return &ah; + if (f) + return &ah; + e = a ().c(""); + return &ah; + } +} b; +