diff options
Diffstat (limited to 'compiler/GHC/Stg/Pipeline.hs')
-rw-r--r-- | compiler/GHC/Stg/Pipeline.hs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/compiler/GHC/Stg/Pipeline.hs b/compiler/GHC/Stg/Pipeline.hs index 13b403fc53..87690b90eb 100644 --- a/compiler/GHC/Stg/Pipeline.hs +++ b/compiler/GHC/Stg/Pipeline.hs @@ -19,6 +19,7 @@ import GHC.Stg.Syntax import GHC.Stg.Lint ( lintStgTopBindings ) import GHC.Stg.Stats ( showStgStats ) +import GHC.Stg.DepAnal ( depSortStgPgm ) import GHC.Stg.Unarise ( unarise ) import GHC.Stg.CSE ( stgCse ) import GHC.Stg.Lift ( stgLiftLams ) @@ -56,9 +57,18 @@ stg2stg dflags this_mod binds ; binds' <- runStgM 'g' $ foldM do_stg_pass binds (getStgToDo dflags) - ; dump_when Opt_D_dump_stg_final "Final STG:" binds' - - ; return binds' + -- Dependency sort the program as last thing. The program needs to be + -- in dependency order for the SRT algorithm to work (see + -- CmmBuildInfoTables, which also includes a detailed description of + -- the algorithm), and we don't guarantee that the program is already + -- sorted at this point. #16192 is for simplifier not preserving + -- dependency order. We also don't guarantee that StgLiftLams will + -- preserve the order or only create minimal recursive groups, so a + -- sorting pass is necessary. + ; let binds_sorted = depSortStgPgm binds' + ; dump_when Opt_D_dump_stg_final "Final STG:" binds_sorted + + ; return binds_sorted } where |