Bug 92535 - [10 regression] ICF is relatively expensive and became less effective
Summary: [10 regression] ICF is relatively expensive and became less effective
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 10.0
: P2 normal
Target Milestone: 11.0
Assignee: Jan Hubicka
URL:
Keywords: compile-time-hog, memory-hog
Depends on:
Blocks:
 
Reported: 2019-11-15 18:02 UTC by Jan Hubicka
Modified: 2023-07-07 08:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 10.5.0
Last reconfirmed: 2019-11-16 00:00:00


Attachments
Memory use graph for linktime for GCC10 (70.22 KB, application/pdf)
2019-11-15 18:02 UTC, Jan Hubicka
Details
memory use of GCC10 with icf disabled (36.44 KB, application/pdf)
2019-11-15 18:02 UTC, Jan Hubicka
Details
Memory use of gcc9 (35.98 KB, application/pdf)
2019-11-15 18:03 UTC, Jan Hubicka
Details
Meory use of gcc9 with ICF disabled (69.49 KB, application/pdf)
2019-11-15 18:03 UTC, Jan Hubicka
Details
Memory use of GCC trunk (11) with ICF (247.22 KB, application/gzip)
2020-11-17 20:03 UTC, Jan Hubicka
Details
Memory use of GCC trunk (11) without ICF (218.28 KB, application/gzip)
2020-11-17 20:05 UTC, Jan Hubicka
Details
Memory use of GCC 10 release branch with ICF (225.37 KB, application/gzip)
2020-11-17 21:37 UTC, Jan Hubicka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Hubicka 2019-11-15 18:02:07 UTC
Created attachment 47274 [details]
Memory use graph for linktime for GCC10

ICF currently is very conservative optimizing libxul.so saving only about 1.5% of text segment:

$ bloaty libxul.so -- libxul.so.old2
     VM SIZE                          FILE SIZE
 ++++++++++++++ GROWING            ++++++++++++++
  +1.5% +1.21Mi .text              +1.21Mi  +1.5%
  +4.4%  +351Ki .eh_frame           +351Ki  +4.4%
  +6.0%  +102Ki .eh_frame_hdr       +102Ki  +6.0%
  [ = ]       0 .strtab            +62.4Ki  +0.2%
  +0.5% +52.6Ki .rela.dyn          +52.6Ki  +0.5%
  +0.1% +19.6Ki .rodata            +19.6Ki  +0.1%
  +0.4% +13.2Ki .data.rel.ro.local +13.2Ki  +0.4%
  +1.3% +9.97Ki .data.rel.ro       +9.97Ki  +1.3%
  +0.2%     +12 .gcc_except_table      +12  +0.2%

 -------------- SHRINKING          --------------
  [ = ]       0 .symtab            -10.0Ki  -0.1%
  -0.0%     -64 .data                  -64  -0.0%
  -0.0%     -16 .bss                     0  [ = ]

 -+-+-+-+-+-+-+ MIXED              +-+-+-+-+-+-+-
   +76%    +124 [Unmapped]         -3.04Ki -77.5%

  +1.3% +1.75Mi TOTAL              +1.79Mi  +0.9%

This used to be 7% in GCC5 (at Firefox from 2015)

At the same time it is relatively expensive memory wise and compile time wise.

It increases peak memory use from 6GB to 7.5GB and compile time from:
real    8m57.454s
user    91m8.020s
sys     6m20.372s

to

real    9m41.361s
user    91m47.076s
sys     6m16.760s

For GCC 9 the code size improvement is 2.3%, build time change is:
real    7m53.778s
user    76m10.368s
sys     6m55.324s

to

real    8m14.613s
user    72m57.932s
sys     6m32.792s

and peak memory use is from 8gm to 10gb.
Comment 1 Jan Hubicka 2019-11-15 18:02:50 UTC
Created attachment 47275 [details]
memory use of GCC10 with icf disabled
Comment 2 Jan Hubicka 2019-11-15 18:03:16 UTC
Created attachment 47276 [details]
Memory use of gcc9
Comment 3 Jan Hubicka 2019-11-15 18:03:50 UTC
Created attachment 47277 [details]
Meory use of gcc9 with ICF disabled
Comment 4 Jan Hubicka 2019-11-15 18:04:43 UTC
Forgot bloaty report for GCC9 and disabling ICF
$ bloaty libxul.so -- libxul.so.old 
     VM SIZE                          FILE SIZE
 ++++++++++++++ GROWING            ++++++++++++++
  +2.3% +1.87Mi .text              +1.87Mi  +2.3%
  +5.4%  +423Ki .eh_frame           +423Ki  +5.4%
  +7.1%  +122Ki .eh_frame_hdr       +122Ki  +7.1%
  +0.6% +61.3Ki .rela.dyn          +61.3Ki  +0.6%
  +0.2% +29.8Ki .rodata            +29.8Ki  +0.2%
  +0.4% +14.1Ki .data.rel.ro.local +14.1Ki  +0.4%
  +1.5% +12.0Ki .data.rel.ro       +12.0Ki  +1.5%
  +0.1%    +224 .data                 +224  +0.1%

 -------------- SHRINKING          --------------
  [ = ]       0 .strtab             -291Ki  -0.7%
  [ = ]       0 .symtab            -46.6Ki  -0.3%
 -69.6%    -240 [Unmapped]         -3.12Ki -73.1%
  -0.0%    -120 .bss                     0  [ = ]

  +1.8% +2.51Mi TOTAL              +2.18Mi  +1.1%
Comment 5 Jakub Jelinek 2020-05-07 11:56:17 UTC
GCC 10.1 has been released.
Comment 6 Richard Biener 2020-07-23 06:51:44 UTC
GCC 10.2 is released, adjusting target milestone.
Comment 7 Jan Hubicka 2020-11-17 19:49:03 UTC
With today trunk (after icf memory handling patches) I get 
     VM SIZE                          FILE SIZE
 ++++++++++++++ GROWING            ++++++++++++++
  +1.3% +1.21Mi .text              +1.21Mi  +1.3%
  +5.2%  +440Ki .eh_frame           +440Ki  +5.2%
  +7.1%  +126Ki .eh_frame_hdr       +126Ki  +7.1%
  +0.4% +74.8Ki .rodata            +74.8Ki  +0.4%
  +0.6% +61.0Ki .rela.dyn          +61.0Ki  +0.6%
  +0.4% +15.4Ki .data.rel.ro.local +15.4Ki  +0.4%
  +1.1% +11.1Ki .data.rel.ro       +11.1Ki  +1.1%
  [ = ]       0 .symtab            +2.55Ki  +0.0%
  +0.0%     +64 .data                  +64  +0.0%
  +0.0%     +24 .rela.plt              +24  +0.0%
  +0.0%     +16 .plt                   +16  +0.0%
  +0.2%     +12 .gcc_except_table      +12  +0.2%
  +0.0%      +8 .got.plt                +8  +0.0%

 -------------- SHRINKING          --------------
  [ = ]       0 .strtab            -29.6Ki  -0.1%
  -0.0%     -32 .bss                     0  [ = ]
  -0.0%      -8 .got                    -8  -0.0%

 -+-+-+-+-+-+-+ MIXED              +-+-+-+-+-+-+-
   +17%     +44 [Unmapped]         -3.74Ki -90.8%

  +1.3% +1.92Mi TOTAL              +1.89Mi  +0.9%

time report of WPA with ICF:
 ipa lto gimple in                  :   6.45 (  4%)   2.65 ( 16%)   9.04 (  5%)   810M ( 12%)
 ipa lto gimple out                 :   1.87 (  1%)   0.80 (  5%)   2.72 (  1%)     0  (  0%)
 ipa lto decl in                    :  18.63 ( 11%)   1.26 (  7%)  20.02 ( 10%)  2682M ( 41%)
 ipa lto decl out                   :   4.64 (  3%)   0.20 (  1%)   4.84 (  3%)     0  (  0%)
 ipa icf                            :  17.58 ( 10%)   0.59 (  4%)  18.22 (  9%)    24M (  0%)
 TOTAL                              : 176.22         16.82        193.31         6617M

compared to:
 ipa lto gimple in                  :   0.48 (  0%)   0.11 (  1%)   0.77 (  1%)  2905k (  0%)
 ipa lto gimple out                 :   1.01 (  1%)   0.84 (  8%)   1.84 (  1%)     0  (  0%)
 ipa lto decl in                    :  18.74 ( 14%)   1.31 ( 12%)  19.90 ( 13%)  2682M ( 47%)
 ipa lto decl out                   :   4.34 (  3%)   0.47 (  4%)   4.79 (  3%)     0  (  0%)
 TOTAL                              : 138.62         10.61        149.39         5715M

So still pretty bad.
Comment 8 Jan Hubicka 2020-11-17 20:03:28 UTC
Created attachment 49577 [details]
Memory use of GCC trunk (11) with ICF
Comment 9 Jan Hubicka 2020-11-17 20:05:07 UTC
Created attachment 49578 [details]
Memory use of GCC trunk (11) without ICF
Comment 10 Jan Hubicka 2020-11-17 20:21:12 UTC
Here are main reason for miscompares:
   1125 libxul.so.wpa.076i.icf:  false returned: 'variables types are different' in equals at ../../gcc/ipa-icf.c:1697
   1171 libxul.so.wpa.076i.icf:  false returned: 'DECL_CXX_CONSTRUCTOR mismatch' in equals_wpa at ../../gcc/ipa-icf.c:562
   2211 libxul.so.wpa.076i.icf:  false returned: 'different decl attributes' in equals_wpa at ../../gcc/ipa-icf.c:662
   3362 libxul.so.wpa.076i.icf:  false returned: 'ctor polymorphic type mismatch' in equals_wpa at ../../gcc/ipa-icf.c:585
   3627 libxul.so.wpa.076i.icf:  false returned: 'GIMPLE LHS type mismatch' in compare_gimple_assign at ../../gcc/ipa-icf-gimple.c:695
   5297 libxul.so.wpa.076i.icf:  false returned: '' in compare_decl at ../../gcc/ipa-icf-gimple.c:157
   5304 libxul.so.wpa.076i.icf:  false returned: '' in compare_variable_decl at ../../gcc/ipa-icf-gimple.c:422
   5304 libxul.so.wpa.076i.icf:  false returned: '' in operand_equal_p at ../../gcc/ipa-icf-gimple.c:291
   8588 libxul.so.wpa.076i.icf:  false returned: 'parameter type is not compatible' in compatible_parm_types_p at ../../gcc/ipa-icf.c:512
  10188 libxul.so.wpa.076i.icf:  false returned: 'inline attributes are different' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:350
  16218 libxul.so.wpa.076i.icf:  false returned: 'parameter types are not compatible' in equals_wpa at ../../gcc/ipa-icf.c:639
  26076 libxul.so.wpa.076i.icf:  false returned: 'references to virtual tables cannot be merged' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:373
  28813 libxul.so.wpa.076i.icf:  false returned: 'decl_or_type flags are different' in equals_wpa at ../../gcc/ipa-icf.c:572
  32478 libxul.so.wpa.076i.icf:  false returned: 'different tree types' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:206
  60520 libxul.so.wpa.076i.icf:  false returned: 'call function types are not compatible' in compare_gimple_call at ../../gcc/ipa-icf-gimple.c:635
 106399 libxul.so.wpa.076i.icf:  false returned: 'types are not compatible' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:212
 120240 libxul.so.wpa.076i.icf:  false returned: 'result types are different' in equals_wpa at ../../gcc/ipa-icf.c:621
 269745 libxul.so.wpa.076i.icf:  false returned: 'compare_ao_refs failed (semantic difference)' in compare_operand at ../../gcc/ipa-icf-gimple.c:336
 355772 libxul.so.wpa.076i.icf:  false returned: '' in compare_gimple_call at ../../gcc/ipa-icf-gimple.c:607
 456913 libxul.so.wpa.076i.icf:  false returned: 'THIS pointer ODR type mismatch' in equals_wpa at ../../gcc/ipa-icf.c:677
 460252 libxul.so.wpa.076i.icf:  false returned: 'types are not same for ODR' in compatible_polymorphic_types_p at ../../gcc/ipa-icf-gimple.c:197
1391954 libxul.so.wpa.076i.icf:  false returned: 'GIMPLE assignment operands are different' in compare_gimple_assign at ../../gcc/ipa-icf-gimple.c:699
1477890 libxul.so.wpa.076i.icf:  false returned: 'operand_equal_p failed' in compare_operand at ../../gcc/ipa-icf-gimple.c:356
1840986 libxul.so.wpa.076i.icf:  false returned: '' in equals_private at ../../gcc/ipa-icf.c:886

So compare_ao_refs is not really a top even though it can be improved.  I suppose it is time to improve the hash.

Common problem is
OBJ_TYPE_REF(_7;(struct nsServerSocket)_1->2) (_1);                             
OBJ_TYPE_REF(_7;(struct nsJSProtocolHandler)_1->2) (_1);                        
this happens 350645 (24% of the operand_equal_p failures) so I guess one can start from there.

here clearly we want to hash ODR name of the OTR type.
Comment 11 Jan Hubicka 2020-11-17 21:37:48 UTC
Created attachment 49582 [details]
Memory use of GCC 10 release branch with ICF
Comment 12 Jan Hubicka 2020-11-18 07:33:10 UTC
With ODR name hashing fix and fix to streaming the access types we now get:

    957   false returned: 'different references' in compare_symbol_references at ../../gcc/ipa-icf.c:465
    961   false returned: 'size mismatch' in equals_wpa at ../../gcc/ipa-icf.c:1651
   1171   false returned: 'DECL_CXX_CONSTRUCTOR mismatch' in equals_wpa at ../../gcc/ipa-icf.c:562
   1360   false returned: '' in compare_gimple_call at ../../gcc/ipa-icf-gimple.c:607
   2209   false returned: 'different decl attributes' in equals_wpa at ../../gcc/ipa-icf.c:662
   3362   false returned: 'ctor polymorphic type mismatch' in equals_wpa at ../../gcc/ipa-icf.c:585
   8399   false returned: 'parameter type is not compatible' in compatible_parm_types_p at ../../gcc/ipa-icf.c:512
  10161   false returned: 'inline attributes are different' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:350
  16217   false returned: 'parameter types are not compatible' in equals_wpa at ../../gcc/ipa-icf.c:639
  26071   false returned: 'references to virtual tables cannot be merged' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:373
  28812   false returned: 'decl_or_type flags are different' in equals_wpa at ../../gcc/ipa-icf.c:572
  29308   false returned: 'different tree types' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:206
  99308   false returned: 'types are not compatible' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:212
 119994   false returned: 'result types are different' in equals_wpa at ../../gcc/ipa-icf.c:621
 128276   false returned: 'compare_ao_refs failed (semantic difference)' in compare_operand at ../../gcc/ipa-icf-gimple.c:336
 242454   false returned: 'operand_equal_p failed' in compare_operand at ../../gcc/ipa-icf-gimple.c:356
 369360   false returned: 'GIMPLE assignment operands are different' in compare_gimple_assign at ../../gcc/ipa-icf-gimple.c:699
 370952   false returned: '' in equals_private at ../../gcc/ipa-icf.c:886
 456907   false returned: 'THIS pointer ODR type mismatch' in equals_wpa at ../../gcc/ipa-icf.c:677
 460246   false returned: 'types are not same for ODR' in compatible_polymorphic_types_p at ../../gcc/ipa-icf-gimple.c:197

so ODR types of THIS pointers come next.
Comment 13 Jan Hubicka 2020-11-18 08:26:56 UTC
Actually, I did not wait long enough for ICF to finish dumping. Here is the correct output. Still nice improvement for OBJ_TYPE_REF

   8399   false returned: 'parameter type is not compatible' in compatible_parm_types_p at ../../gcc/ipa-icf.c:512
  10187   false returned: 'inline attributes are different' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:350
  16217   false returned: 'parameter types are not compatible' in equals_wpa at ../../gcc/ipa-icf.c:639
  26071   false returned: 'references to virtual tables cannot be merged' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:373
  28812   false returned: 'decl_or_type flags are different' in equals_wpa at ../../gcc/ipa-icf.c:572
  32287   false returned: 'different tree types' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:206
  60520   false returned: 'call function types are not compatible' in compare_gimple_call at ../../gcc/ipa-icf-gimple.c:635
 103684   false returned: 'types are not compatible' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:212
 119994   false returned: 'result types are different' in equals_wpa at ../../gcc/ipa-icf.c:621
 134888   false returned: '' in compare_gimple_call at ../../gcc/ipa-icf-gimple.c:607
 264624   false returned: 'compare_ao_refs failed (semantic difference)' in compare_operand at ../../gcc/ipa-icf-gimple.c:336
 456907   false returned: 'THIS pointer ODR type mismatch' in equals_wpa at ../../gcc/ipa-icf.c:677
 460246   false returned: 'types are not same for ODR' in compatible_polymorphic_types_p at ../../gcc/ipa-icf-gimple.c:197
 881974   false returned: 'operand_equal_p failed' in compare_operand at ../../gcc/ipa-icf-gimple.c:356
1011296   false returned: 'GIMPLE assignment operands are different' in compare_gimple_assign at ../../gcc/ipa-icf-gimple.c:699
1239444   false returned: '' in equals_private at ../../gcc/ipa-icf.c:886
Comment 14 Jan Hubicka 2020-11-19 13:57:34 UTC
I fixed some issues
 1) merging of OBJ_TYPE_REF was broken
 2) last version of my COMPONENT_REF patch clears incorrectly OEP_ADDRESS_OF
 3) gimple clobbers mismatches for no good reason
 4) volatile memory references can are never considered equal
 5) alignment of memory accesses is not hashed and may cause late mismatch (common in vector code)

With this I get
    141   false returned: 'Declaration mismatch' in equals at ../../gcc/ipa-icf.c:1817
    162   false returned: 'DECL_CXX_DESTRUCTOR mismatch' in equals_wpa at ../../gcc/ipa-icf.c:565
    169   false returned: '' in compare_decl at ../../gcc/ipa-icf-gimple.c:162
    246   false returned: 'final flag mismatch' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:401
    380   false returned: '' in compare_phi_node at ../../gcc/ipa-icf.c:1595
    380   false returned: 'PHI node comparison returns false' in equals_private at ../../gcc/ipa-icf.c:916
    513   false returned: 'different decl attributes' in equals_wpa at ../../gcc/ipa-icf.c:662
    571   false returned: 'compare_ao_refs failed (dependence clique difference)' in compare_operand at ../../gcc/ipa-icf-gimple.c:368
    811   false returned: 'GIMPLE call operands are different' in compare_gimple_call at ../../gcc/ipa-icf-gimple.c:676
    912   false returned: 'different references' in compare_symbol_references at ../../gcc/ipa-icf.c:465
    961   false returned: 'size mismatch' in equals_wpa at ../../gcc/ipa-icf.c:1666
   1125   false returned: 'variables types are different' in equals at ../../gcc/ipa-icf.c:1712
   1129   false returned: 'DECL_CXX_CONSTRUCTOR mismatch' in equals_wpa at ../../gcc/ipa-icf.c:562
   1453   false returned: 'operand_equal_p failed' in compare_operand at ../../gcc/ipa-icf-gimple.c:376
   2917   false returned: 'compare_ao_refs failed (semantic difference)' in compare_operand at ../../gcc/ipa-icf-gimple.c:356
   3362   false returned: 'ctor polymorphic type mismatch' in equals_wpa at ../../gcc/ipa-icf.c:585
   3527   false returned: '' in compare_decl at ../../gcc/ipa-icf-gimple.c:157
   3535   false returned: '' in compare_variable_decl at ../../gcc/ipa-icf-gimple.c:442
   3535   false returned: '' in operand_equal_p at ../../gcc/ipa-icf-gimple.c:307
   3563   false returned: 'GIMPLE assignment operands are different' in compare_gimple_assign at ../../gcc/ipa-icf-gimple.c:719
   4604   false returned: 'GIMPLE LHS type mismatch' in compare_gimple_assign at ../../gcc/ipa-icf-gimple.c:715
   6577   false returned: 'parameter type is not compatible' in compatible_parm_types_p at ../../gcc/ipa-icf.c:512
   8441   false returned: 'inline attributes are different' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:350
  11259   false returned: 'parameter types are not compatible' in equals_wpa at ../../gcc/ipa-icf.c:639
  25276   false returned: 'different tree types' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:206
  26073   false returned: 'references to virtual tables cannot be merged' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:373
  26693   false returned: 'decl_or_type flags are different' in equals_wpa at ../../gcc/ipa-icf.c:572
  61657   false returned: 'call function types are not compatible' in compare_gimple_call at ../../gcc/ipa-icf-gimple.c:655
  70880   false returned: '' in equals_private at ../../gcc/ipa-icf.c:881
 104034   false returned: 'types are not compatible' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:212
 113477   false returned: 'result types are different' in equals_wpa at ../../gcc/ipa-icf.c:621
 410680   false returned: 'THIS pointer ODR type of cdtor mismatch' in equals_wpa at ../../gcc/ipa-icf.c:673
 414222   false returned: 'types are not same for ODR' in compatible_polymorphic_types_p at ../../gcc/ipa-icf-gimple.c:197

and more code size savings
     VM SIZE                          FILE SIZE
 ++++++++++++++ GROWING            ++++++++++++++
  [ = ]       0 .strtab             +439Ki  +1.0%
  [ = ]       0 .symtab            +73.4Ki  +0.4%
  +0.0%     +32 .data                  +32  +0.0%

 -------------- SHRINKING          --------------
  -2.9% -2.67Mi .text              -2.67Mi  -2.9%
  -6.3%  -555Ki .eh_frame           -555Ki  -6.3%
  -7.8%  -148Ki .eh_frame_hdr       -148Ki  -7.8%
  -0.4% -78.2Ki .rodata            -78.2Ki  -0.4%
  -0.5% -58.8Ki .rela.dyn          -58.8Ki  -0.5%
  -0.4% -15.0Ki .data.rel.ro.local -15.0Ki  -0.4%
  -1.0% -10.4Ki .data.rel.ro       -10.4Ki  -1.0%
  -0.0%     -64 .bss                     0  [ = ]
  -0.4%     -32 .gcc_except_table      -32  -0.4%

 -+-+-+-+-+-+-+ MIXED              +-+-+-+-+-+-+-
   +14%     +40 [Unmapped]         -1.40Ki -42.6%

  -2.3% -3.51Mi TOTAL              -3.01Mi  -1.4%

ICF still take quite some memory:
 ipa lto gimple in                  :   5.82 (  4%)   2.10 ( 15%)   8.05 (  5%)   776M ( 12%)
 ipa lto gimple out                 :   1.52 (  1%)   0.69 (  5%)   2.23 (  1%)     0  (  0%)
 ipa icf                            :  11.64 (  7%)   0.51 (  4%)  12.23 (  7%)    43M (  1%)
 TOTAL                              : 163.47         13.69        177.49         6537M

So about 100 reduction and ICF got faster. It also improved the chance that functions read in are actually merged.
The times are not 100% comparable to my previous report since my earlier build was with profiledbootstrap while now I bootstrapped the normal way. 

There are still quite many nonsences.  In particular
 1) we could enable merging different polymorphic ODR types of this pointers.
    Late devitualization is not that important, but we would need to have way
    to notice such merges. This is discussed in thread
    https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559573.html
 2) result types, operand types and ODR types can be hashed in before the equals_wpa process start to avoid refining the partitions (that should get rid of good part of ipa-icf time that now seems to be dominated by equal_wpa and fibonaci heap)
 3) we should be able to do something about call operand types compare - it is way too sensitive.
 4) gimple LHS type test is overactive.  I see it is needed for conversions but it is not needed otherwise.
 5) we do bad job on hashing SSA_NAMES.  In Firefox there seems to be quite few functions that differs only by permutation of parameters or permutation of parameters of callee which we do not see as a difference in hash functions
Comment 15 Jan Hubicka 2020-11-19 18:10:21 UTC
Current  mainline with 
 1) fix to COMPONENT_REFs described above
 2) improvement of ODR type having for THIS pointers
 3) gimple_clobber fix (already approved)
 4) compare_ao_refs fix for volatile accesses
 5) compare_decs change so it does not test type compatibility of automatic vars (since these types have little meaning)

      1   false returned: '' in compare_decl at ../../gcc/ipa-icf-gimple.c:163                                                                                                                  1   false returned: 'replaceable operator flags are different' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:359                                                         4   false returned: '' in compare_bb at ../../gcc/ipa-icf-gimple.c:606                                                                                                                    7   false returned: 'Mismatched number of parameters' in equals_wpa at ../../gcc/ipa-icf.c:651                                                                                            9   false returned: '' in compare_variable_decl at ../../gcc/ipa-icf-gimple.c:447                                                                                                         9   false returned: '' in operand_equal_p at ../../gcc/ipa-icf-gimple.c:312                                                                                                              10   false returned: 'INTEGER_CST precision mismatch' in equals at ../../gcc/ipa-icf.c:1807                                                                                               11   false returned: 'case low values are different' in compare_gimple_switch at ../../gcc/ipa-icf-gimple.c:808                                                                           23   false returned: '' in operand_equal_p at ../../gcc/ipa-icf-gimple.c:303                                                                                                              23   false returned: 'one type is not polymorphic' in compatible_polymorphic_types_p at ../../gcc/ipa-icf-gimple.c:208                                                                    23   false returned: 'THIS pointer ODR type mismatch' in equals_wpa at ../../gcc/ipa-icf.c:678                                                                                            29   false returned: 'ASM strings are different' in compare_gimple_asm at ../../gcc/ipa-icf-gimple.c:909
     46   false returned: 'GIMPLE call operands are different' in compare_gimple_call at ../../gcc/ipa-icf-gimple.c:681
    141   false returned: 'Declaration mismatch' in equals at ../../gcc/ipa-icf.c:1803
    169   false returned: '' in compare_decl at ../../gcc/ipa-icf-gimple.c:175
    182   false returned: 'DECL_CXX_DESTRUCTOR mismatch' in equals_wpa at ../../gcc/ipa-icf.c:565
    246   false returned: 'final flag mismatch' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:401
    391   false returned: '' in compare_phi_node at ../../gcc/ipa-icf.c:1581
    391   false returned: 'PHI node comparison returns false' in equals_private at ../../gcc/ipa-icf.c:922
    571   false returned: 'compare_ao_refs failed (dependence clique difference)' in compare_operand at ../../gcc/ipa-icf-gimple.c:373
    676   false returned: 'compare_ao_refs failed (semantic difference)' in compare_operand at ../../gcc/ipa-icf-gimple.c:361
    676   false returned: 'METHOD_TYPE and FUNCTION_TYPE mismatch' in equals_wpa at ../../gcc/ipa-icf.c:674
    707   false returned: 'operand_equal_p failed' in compare_operand at ../../gcc/ipa-icf-gimple.c:381
    957   false returned: 'different references' in compare_symbol_references at ../../gcc/ipa-icf.c:465
    961   false returned: 'size mismatch' in equals_wpa at ../../gcc/ipa-icf.c:1652
   1125   false returned: 'variables types are different' in equals at ../../gcc/ipa-icf.c:1698
   1171   false returned: 'DECL_CXX_CONSTRUCTOR mismatch' in equals_wpa at ../../gcc/ipa-icf.c:562
   1321   false returned: 'GIMPLE assignment operands are different' in compare_gimple_assign at ../../gcc/ipa-icf-gimple.c:724
   2209   false returned: 'different decl attributes' in equals_wpa at ../../gcc/ipa-icf.c:663
   4643   false returned: 'GIMPLE LHS type mismatch' in compare_gimple_assign at ../../gcc/ipa-icf-gimple.c:720
   8400   false returned: 'parameter type is not compatible' in compatible_parm_types_p at ../../gcc/ipa-icf.c:512
  10187   false returned: 'inline attributes are different' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:350
  16210   false returned: 'parameter types are not compatible' in equals_wpa at ../../gcc/ipa-icf.c:640
  26071   false returned: 'references to virtual tables cannot be merged' in compare_referenced_symbol_properties at ../../gcc/ipa-icf.c:373
  28810   false returned: 'decl_or_type flags are different' in equals_wpa at ../../gcc/ipa-icf.c:572
  32971   false returned: 'different tree types' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:219
  61665   false returned: 'call function types are not compatible' in compare_gimple_call at ../../gcc/ipa-icf-gimple.c:660
  96652   false returned: '' in equals_private at ../../gcc/ipa-icf.c:887
 101194   false returned: 'types are not compatible' in compatible_types_p at ../../gcc/ipa-icf-gimple.c:225
 119996   false returned: 'result types are different' in equals_wpa at ../../gcc/ipa-icf.c:622

many of call function types are not compatible are indirect calls with mismatched number of parameters.  This is because we hash SSA_NAME as nothing. That is easy to fix.
Comment 16 Richard Biener 2021-04-08 12:02:01 UTC
GCC 10.3 is being released, retargeting bugs to GCC 10.4.
Comment 17 Jan Hubicka 2021-04-15 09:38:09 UTC
For GCC 11 we now get faster build times with ICF than without on cc1plus, Firefox and clang LTO build.  So I think we can consider it no longer regression while ICF can always be improved (and I have some changes queues for next stage1).

I have no plan to backport this to gcc10, so unasigning.
Comment 18 Jakub Jelinek 2022-06-28 10:38:52 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 19 Richard Biener 2023-07-07 08:40:30 UTC
Fixed in GCC 11 then.
Comment 20 Richard Biener 2023-07-07 08:41:52 UTC
.