From patchwork Sun Sep 1 16:39:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 271625 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 "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B8D342C0091 for ; Mon, 2 Sep 2013 02:39:53 +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=PdLHD5hqEhQvGLhhk gLWN+ToZn6pFk+iOAO6gg67kCOol/qNizOnsrn0zYDtggqTZ8wELHgqAICUy9vJ6 9KZMCpTvVV95kmJetlhQnqHUoAjDCxlIMp7XC+ezJPXWef+P4lCtek3Km3bJN6L0 K1oA84Nlf4NG9CO29AOMNCRCvM= 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=6FiORm4RuJcfrqhYk6kahbb TlSQ=; b=ab3mmkuxYtLVeu08oB/ZKlGudnAthSHSjQtMNcAeF4BVVD1duiWGiY/ WTckRBildvcZrTBtGKqE9voy9BVOQC/oeqma+6Zr7wvddf/U5UMipv/aFlxbTwwp dlyXiDmbBJ8cm8OEi4oMsd9ZYZ4cGOSH+fYMG7Za9IxOqsc2l6QM= Received: (qmail 15507 invoked by alias); 1 Sep 2013 16:39:47 -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 15498 invoked by uid 89); 1 Sep 2013 16:39:46 -0000 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 (AES256-SHA encrypted) ESMTPS; Sun, 01 Sep 2013 16:39:46 +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, NO_RELAYS autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 5B8F2541416; Sun, 1 Sep 2013 18:39:39 +0200 (CEST) Date: Sun, 1 Sep 2013 18:39:39 +0200 From: Jan Hubicka To: Xinliang David Li Cc: Jan Hubicka , GCC Patches , Jason Merrill , Nathan Froyd , Taras Glek , Mike Hommey , Martin =?iso-8859-2?Q?Li=B9ka?= Subject: Re: Type inheritance graph analysis & speculative devirtualization, part 7/7 (speculative devirtualizatoin) Message-ID: <20130901163939.GC23527@kam.mff.cuni.cz> References: <20130901135714.GA23527@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) > Missing test cases? Good point. The testcases I have needs rest of the patches from the series to hit the mainline. For now I have added the following to test the basic scenario * g++.dg/ipa/devirt-15.C: New testcase. > > Have you tested the optimization with SPEC2k and SPEC06? There are a > couple of benchmarks benefit greatly from devirtualization, such as > eon, povray etc. I believe astar will probably improve with this > optimization at O2 (it has hot virtual functions that are not > overridden at all). For eon, the assumption at O2 for speculative > devirt may not work well. I trusted Martin (Jambor) that only interesting testcase for devirtualization in SPEC in xalancbmk. We will definitely see tomorrow. Concerning eon, I think it includes all the classes for individual objects so it should not get devirtualized the wrong way. I will double check. Wrong guess in general should not be terribly expensive. Many speculative calls are eliminated by inlining and other will just end up with the extra conditinal+jump (to jump). For firefox the code growth for all those 30000 devirtualization is about 1.8%. Here about 70% of them survive till final executable since they use virtual functions for very cheap accessors that gets inlined well. There is an accounting bug in ipa-cp that makes us to mistakely remove references to some virutal functions as dead after devirtualization, so I disabled tracking of described references for virtual calls. Once this is fixed, the code size may get better. Honza Index: g++.dg/ipa/devirt-15.C =================================================================== --- g++.dg/ipa/devirt-15.C (revision 0) +++ g++.dg/ipa/devirt-15.C (working copy) @@ -0,0 +1,40 @@ +/* Check that we speculatively devirutalize call to FOO to A::foo becuase + B is noreturn. */ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-ipa-devirt" } */ +class A { +public: + virtual int foo(void) + { + throw (1); + return 0; + } +}; + + +class B : public A { +public: + virtual int foo(void); +}; + +int +B::foo(void) +{ + return 1; +} +class A a, *b=&a; +void +m(void) +{ + b->foo(); +} +main() +{ + m(); +} + +/* { dg-final { scan-ipa-dump "Speculatively devirtualizing call" "devirt"} } */ +/* { dg-final { cleanup-ipa-dump "devirt" } } */ +/* Match if (PROF_6 == foo) to verify that the speculation survived. */ +/* { dg-final { scan-tree-dump "== foo" "optimized"} } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */