This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[IPA ICF,RFC 1/5] New Identical Code Folding IPA pass


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  <thomas.preudhomme@arm.com>
 
 	PR tree-optimization/61375
-- 
1.8.4.5



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]