Cheng Shao pushed to branch wip/fix-use-std-ap-thunk at Glasgow Haskell Compiler / GHC

Commits:

5 changed files:

Changes:

  • changelog.d/fix-use-std-ap-thunk
    1
    +section: codegen
    
    2
    +synopsis: Fix redundant AP thunk codegen when not using -ticky-ap-thunk
    
    3
    +issues: #27502
    
    4
    +mrs: !16340

  • compiler/GHC/Driver/Config/StgToCmm.hs
    ... ... @@ -87,7 +87,7 @@ initStgToCmmConfig dflags mod = StgToCmmConfig
    87 87
       , stgToCmmAvx           = isAvxEnabled                   dflags
    
    88 88
       , stgToCmmAvx2          = isAvx2Enabled                  dflags
    
    89 89
       , stgToCmmAvx512f       = isAvx512fEnabled               dflags
    
    90
    -  , stgToCmmTickyAP       = gopt Opt_Ticky_AP dflags
    
    90
    +  , stgToCmmUseStdApThunk = not $ gopt Opt_Ticky_AP dflags
    
    91 91
       -- See Note [Saving foreign call target to local]
    
    92 92
       , stgToCmmSaveFCallTargetToLocal = any (callerSaves platform) $ activeStgRegs platform
    
    93 93
       } where profile  = targetProfile dflags
    

  • compiler/GHC/Driver/Flags.hs
    ... ... @@ -379,6 +379,7 @@ impliedGFlags = [(Opt_DeferTypeErrors, turnOn, Opt_DeferTypedHoles)
    379 379
                     ,(Opt_ByteCodeAndObjectCode, turnOn, Opt_WriteByteCode)
    
    380 380
                     ,(Opt_InfoTableMap, turnOn, Opt_InfoTableMapWithStack)
    
    381 381
                     ,(Opt_InfoTableMap, turnOn, Opt_InfoTableMapWithFallback)
    
    382
    +                ,(Opt_InfoTableMap, turnOn, Opt_Ticky_AP)
    
    382 383
                     ] ++ validHoleFitsImpliedGFlags
    
    383 384
     
    
    384 385
     -- | General flags that are switched on/off when other general flags are switched
    

  • compiler/GHC/StgToCmm/Bind.hs
    ... ... @@ -280,7 +280,7 @@ cgRhs id (StgRhsClosure fvs cc upd_flag args body _typ)
    280 280
       = do
    
    281 281
         profile <- getProfile
    
    282 282
         check_tags <- stgToCmmDoTagCheck <$> getStgToCmmConfig
    
    283
    -    use_std_ap_thunk <- stgToCmmTickyAP <$> getStgToCmmConfig
    
    283
    +    use_std_ap_thunk <- stgToCmmUseStdApThunk <$> getStgToCmmConfig
    
    284 284
         mkRhsClosure profile use_std_ap_thunk check_tags id cc (nonVoidIds (dVarSetElems fvs)) upd_flag args body
    
    285 285
     
    
    286 286
     ------------------------------------------------------------------------
    

  • compiler/GHC/StgToCmm/Config.hs
    ... ... @@ -73,7 +73,7 @@ data StgToCmmConfig = StgToCmmConfig
    73 73
       , stgToCmmAllowWordMul2Instr        :: !Bool   -- ^ Allowed to generate WordMul2 instruction
    
    74 74
       , stgToCmmAllowFMAInstr             :: FMASign -> Bool -- ^ Allowed to generate FMA instruction
    
    75 75
       , stgToCmmAllowIntWord64X2MinMax    :: !Bool   -- ^ Allowed to generate min/max instructions for Int64X2/Word64X2
    
    76
    -  , stgToCmmTickyAP                   :: !Bool   -- ^ Disable use of precomputed standard thunks.
    
    76
    +  , stgToCmmUseStdApThunk             :: !Bool   -- ^ Use precomputed standard AP thunks in the RTS.
    
    77 77
       , stgToCmmSaveFCallTargetToLocal    :: !Bool   -- ^ Save a foreign call target to a Cmm local, see
    
    78 78
                                                      -- Note [Saving foreign call target to local] for details
    
    79 79
       ------------------------------ SIMD flags ------------------------------------