Andreas Klebinger pushed to branch wip/apk/expose-overloaded-unfoldings at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • changelog.d/T13090-expose-overloaded-unfoldings
    1
    +section: compiler
    
    2
    +issues: #13090
    
    3
    +mrs: !16684
    
    4
    +synopsis:
    
    5
    +  Enable :ghc-flag:`-fexpose-overloaded-unfoldings` by default with :ghc-flag:`-O` or higher.
    
    6
    +

  • compiler/GHC/Driver/DynFlags.hs
    ... ... @@ -1337,6 +1337,7 @@ optLevelFlags -- see Note [Documenting optimisation flags]
    1337 1337
         , ([1,2],   Opt_Specialise)
    
    1338 1338
         , ([1,2],   Opt_PolymorphicSpecialisation)  -- Now on by default (#23559)
    
    1339 1339
         , ([1,2],   Opt_CrossModuleSpecialise)
    
    1340
    +    , ([1,2],   Opt_ExposeOverloadedUnfoldings) -- See Note [Exposing overloaded functions] in GHC.Iface.Tidy
    
    1340 1341
         , ([1,2],   Opt_InlineGenerics)
    
    1341 1342
         , ([1,2],   Opt_Strictness)
    
    1342 1343
         , ([1,2],   Opt_UnboxSmallStrictFields)
    

  • compiler/GHC/Iface/Tidy.hs
    ... ... @@ -806,8 +806,19 @@ anyway we allow for some false positives and simply expose all functions which
    806 806
     have a constraint. This means we might expose more unhelpful unfoldings. But
    
    807 807
     it seems like the better choice.
    
    808 808
     
    
    809
    -Currently this option is off by default and has to be enabled manually. But
    
    810
    -we might change this in the future.
    
    809
    +We enable the flag by default with -O/O2 to allow users to opt into specialization
    
    810
    +at call sites. We do not enable -fspecialize-aggressively. See also #13090.
    
    811
    +
    
    812
    +In terms of performance impact the cost is very modest:
    
    813
    +On GHC and it's boot libraries overall enabling this flag increases overall disk
    
    814
    +space used by ~1%. With a highly variant distribution across various .hi files.
    
    815
    +In terms of compile times the overhead is low enough to be hard to measure, but
    
    816
    +seemed to be less than 0.2% if anything at all.
    
    817
    +
    
    818
    +It seems tempting to do the same for -fspecialize-aggressively, but that comes in
    
    819
    +at a hefty 20% compile time overhead. So we only provide the unfoldings and leave
    
    820
    +the choice of how much specialization to enable up to the user.
    
    821
    +
    
    811 822
     -}
    
    812 823
     
    
    813 824
     {-
    

  • docs/users_guide/using-optimisation.rst
    ... ... @@ -624,10 +624,10 @@ as such you shouldn't need to set any of them explicitly. A flag
    624 624
         :reverse: -fno-expose-overloaded-unfoldings
    
    625 625
         :category:
    
    626 626
     
    
    627
    -    :default: off
    
    627
    +    :default: -O and above
    
    628 628
         :since: 9.12.1
    
    629 629
     
    
    630
    -    This experimental flag is a slightly less heavy weight alternative
    
    630
    +    This flag is a slightly less heavy weight alternative
    
    631 631
         to :ghc-flag:`-fexpose-all-unfoldings`.
    
    632 632
     
    
    633 633
         Instead of exposing all functions it exposes only those functions which