From patchwork Fri Jun 13 10:24:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 359701 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 768581400A3 for ; Sat, 14 Jun 2014 07:38:39 +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 :resent-from:resent-to:resent-date:resent-message-id:message-id :from:date:subject:to:cc; q=dns; s=default; b=i1uyBiVieyJyTV/Zn6 hWoDJKlTc/bTMpPudVz/einLHge/wADMDdTN9ioa8h/ZQPDyf6GptBSdt2bTOWuP +Az6zN+ZUwo97J8EDpVVW4+diAobpe6MmG+WoYLS1Q2QafzHLkRAjtELc7edky6T FahADSbHnM2L51HPVTDyY1Gco= 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 :resent-from:resent-to:resent-date:resent-message-id:message-id :from:date:subject:to:cc; s=default; bh=AWkiLl20ppx6xluU5JnXlg+Q QKg=; b=OHAaCF9flDdfIkDnmgpaXXQjvqpMmXFZBwnh+5b8e7iP+CUm8wUC6t7M MUk2/WHrAnkeCQUIOJtlP7/xAk7K7YeS7aois4uxztbkaYSLjqhTwKi7UEAIxrvW HsQf/ChU3/qRU+ksIftG+uEdY8kak4kthYdjus+3RxF7Gjb/Ddg= Received: (qmail 8766 invoked by alias); 13 Jun 2014 21:38:18 -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 8727 invoked by uid 89); 13 Jun 2014 21:38:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 13 Jun 2014 21:38:12 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 57488AB0C for ; Fri, 13 Jun 2014 21:38:09 +0000 (UTC) Resent-From: Martin =?UTF-8?B?TGnDhcKha2E=?= Resent-To: GCC Patches Resent-Date: Fri, 13 Jun 2014 23:40:03 +0200 Resent-Message-ID: <539B6FB3.6020503@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 Message-Id: From: mliska Date: Fri, 13 Jun 2014 12:24:47 +0200 Subject: [IPA ICF,RFC 1/5] New Identical Code Folding IPA pass To: gcc-patches@gnu.gcc.org Cc: hubicka@ucw.cz X-IsSubscribed: yes Hello, after working for quite a long time, I would like to introduce new IPA pass. Goal of the pass is to merge semantically equivalent functions and read-only variables. If we prove that a function A is an equivalent to a function B, depending on circumstances, an alias, thunk or a function redirection is created. The optimization is inspired by Microsoft /OPT:ICF optimization (http://msdn.microsoft.com/en-us/library/bxwfs976.aspx) that merges COMDAT sections with each function reside in a separate section. Apart from that, GOLD linker implemented equivalent implementation for GNU toolchain: SAFE ICF (http://research.google.com/pubs/pub36912.html). Both implementations suffer from a collection of functions where an address was taken for comparison purpose. GOLD linker adds more conservative --icf=safe option. You may ask, why the GNU GCC does need such a new optimization. The compiler, having simply better knowledge of a compiled source file, is capable of reaching better results, especially if Link-Time optimization is enabled. Apart from that, GCC implementation adds support for read-only variables like construction vtables (mentioned in: http://hubicka.blogspot.cz/2014/02/devirtualization-in-c-part-3-building.html). The pass is capable of building GIMP, Inkscape and Firefox with enabled LTO. Majority of issues connected to testsuite has been fixed, there is a few of IPA tests I need to consult with Jan, how to fix it correctly. Statistics about the pass: Inkscape: 11.95 MB -> 11.44 MB (-4.27%) Firefox: 70.12 MB -> 70.12 MB (-3.07%) SPEC 2K6 statistics show how many equivalent functions (and variables) are proved by GOLD and GCC ICF: +----------------+----------+---------+------------+------------------+--------------+--------------+-------------+ | SPEC | GOLD ICF | IPA ICF | difference | difference perc. | intersection | Just in GOLD | Just in ICF | +----------------+----------+---------+------------+------------------+--------------+--------------+-------------+ | 400.perlbench | 26 | 53 | 27 | 203.85% | 26 | 0 | 27 | | 401.bzip2 | 0 | 1 | 1 | 0.00% | 0 | 0 | 1 | | 403.gcc | 88 | 223 | 135 | 253.41% | 81 | 7 | 142 | | 410.bwaves | 0 | 0 | 0 | 0.00% | 0 | 0 | 0 | | 416.gamess | 9 | 23 | 14 | 255.56% | 9 | 0 | 14 | | 429.mcf | 0 | 0 | 0 | 0.00% | 0 | 0 | 0 | | 433.milc | 0 | 8 | 8 | 0.00% | 0 | 0 | 8 | | 434.zeusmp | 0 | 1 | 1 | 0.00% | 0 | 0 | 1 | | 436.cactusADM | 19 | 55 | 36 | 289.47% | 14 | 5 | 41 | | 437.leslie3d | 0 | 0 | 0 | 0.00% | 0 | 0 | 0 | | 444.namd | 0 | 0 | 0 | 0.00% | 0 | 0 | 0 | | 445.gobmk | 0 | 332 | 332 | 0.00% | 0 | 0 | 332 | | 453.povray | 73 | 93 | 20 | 127.40% | 60 | 13 | 33 | | 454.calculix | 3 | 6 | 3 | 200.00% | 3 | 0 | 3 | | 456.hmmer | 0 | 1 | 1 | 0.00% | 0 | 0 | 1 | | 458.sjeng | 0 | 1 | 1 | 0.00% | 0 | 0 | 1 | | 459.GemsFDTD | 0 | 0 | 0 | 0.00% | 0 | 0 | 0 | | 462.libquantum | 0 | 0 | 0 | 0.00% | 0 | 0 | 0 | | 464.h264ref | 0 | 4 | 4 | 0.00% | 0 | 0 | 4 | | 470.lbm | 0 | 0 | 0 | 0.00% | 0 | 0 | 0 | | 471.omnetpp | 134 | 179 | 45 | 133.58% | 127 | 7 | 52 | | 473.astar | 0 | 1 | 1 | 0.00% | 0 | 0 | 1 | | 481.wrf | 51 | 75 | 24 | 147.06% | 50 | 1 | 25 | | 482.sphinx3 | 0 | 1 | 1 | 0.00% | 0 | 0 | 1 | +----------------+----------+---------+------------+------------------+--------------+--------------+-------------+ | TOTAL | 403 | 1057 | 654 | 262.28% | 370 | 33 | 687 | +----------------+----------+---------+------------+------------------+--------------+--------------+-------------+ I've been testing the pass on a QEMU Gentoo virtual machine and I will bring stats as soon as possible. There are still unresolved issues connected to correct debugging. I am not familiar with DWARF extensions, but it looks there is a solution that can be applied to the pass: http://wiki.dwarfstd.org/index.php?title=ICF ? I tried to create equivalent functions foo and bar, merged by ICF GOLD. Function bar is removed from .text section, but gdb can put a breakpoint to the function, where content of function foo is displayed. I think this is acceptable behavior. I expect many comments related to pass, but I hope effort invested by me a Honza will be transformed to acceptation to trunk. Martin (please ignore this diff) --- gcc/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3ddd98c..4f9418e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,4 @@ + 2014-06-13 Thomas Preud'homme PR tree-optimization/61375