Replace most occurences of foldl with foldl'.
authorklebinger.andreas@gmx.at <klebinger.andreas@gmx.at>
Tue, 21 Aug 2018 16:10:38 +0000 (12:10 -0400)
committerBen Gamari <ben@smart-cactus.org>
Tue, 21 Aug 2018 22:52:42 +0000 (18:52 -0400)
commit09c1d5afba655a2427a448a9933bebe7d13b696b
treed23083a9e99afe785f632e89f0186af8b191aee2
parent02518f9d99c2d038384263f9e039efcb09bc96ff
Replace most occurences of foldl with foldl'.

This patch adds foldl' to GhcPrelude and changes must occurences
of foldl to foldl'. This leads to better performance especially
for quick builds where GHC does not perform strictness analysis.

It does change strictness behaviour when we use foldl' to turn
a argument list into function applications. But this is only a
drawback if code looks ONLY at the last argument but not at the first.
And as the benchmarks show leads to fewer allocations in practice
at O2.

Compiler performance for Nofib:

O2 Allocations:
        -1 s.d.                -----            -0.0%
        +1 s.d.                -----            -0.0%
        Average                -----            -0.0%

O2 Compile Time:
        -1 s.d.                -----            -2.8%
        +1 s.d.                -----            +1.3%
        Average                -----            -0.8%

O0 Allocations:
        -1 s.d.                -----            -0.2%
        +1 s.d.                -----            -0.1%
        Average                -----            -0.2%

Test Plan: ci

Reviewers: goldfire, bgamari, simonmar, tdammers, monoidal

Reviewed By: bgamari, monoidal

Subscribers: tdammers, rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4929
69 files changed:
compiler/basicTypes/Avail.hs
compiler/basicTypes/NameCache.hs
compiler/basicTypes/NameSet.hs
compiler/basicTypes/OccName.hs
compiler/basicTypes/RdrName.hs
compiler/basicTypes/VarEnv.hs
compiler/cmm/CmmContFlowOpt.hs
compiler/cmm/CmmExpr.hs
compiler/cmm/CmmSink.hs
compiler/cmm/Hoopl/Dataflow.hs
compiler/codeGen/StgCmmMonad.hs
compiler/coreSyn/CoreArity.hs
compiler/coreSyn/CoreMap.hs
compiler/coreSyn/CoreOpt.hs
compiler/coreSyn/CoreSyn.hs
compiler/deSugar/DsExpr.hs
compiler/deSugar/DsForeign.hs
compiler/deSugar/DsMeta.hs
compiler/deSugar/DsUtils.hs
compiler/deSugar/Match.hs
compiler/hsSyn/HsTypes.hs
compiler/hsSyn/HsUtils.hs
compiler/iface/MkIface.hs
compiler/iface/TcIface.hs
compiler/iface/ToIface.hs
compiler/main/Ar.hs
compiler/main/DynFlags.hs
compiler/main/GhcMake.hs
compiler/main/HscTypes.hs
compiler/main/Packages.hs
compiler/nativeGen/AsmCodeGen.hs
compiler/nativeGen/RegAlloc/Graph/Coalesce.hs
compiler/nativeGen/RegAlloc/Graph/Main.hs
compiler/nativeGen/RegAlloc/Graph/Stats.hs
compiler/nativeGen/RegAlloc/Linear/Stats.hs
compiler/prelude/PrelInfo.hs
compiler/rename/RnNames.hs
compiler/simplCore/CallArity.hs
compiler/simplCore/FloatIn.hs
compiler/simplCore/OccurAnal.hs
compiler/simplCore/SetLevels.hs
compiler/simplCore/Simplify.hs
compiler/specialise/Rules.hs
compiler/specialise/Specialise.hs
compiler/stranal/DmdAnal.hs
compiler/typecheck/FunDeps.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcExpr.hs
compiler/typecheck/TcGenDeriv.hs
compiler/typecheck/TcGenFunctor.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcSigs.hs
compiler/typecheck/TcSplice.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcValidity.hs
compiler/types/Coercion.hs
compiler/types/FamInstEnv.hs
compiler/types/InstEnv.hs
compiler/types/Type.hs
compiler/types/Unify.hs
compiler/utils/FiniteMap.hs
compiler/utils/GhcPrelude.hs
compiler/utils/ListSetOps.hs
compiler/utils/UnVarGraph.hs
compiler/utils/UniqDFM.hs
compiler/utils/UniqDSet.hs
compiler/utils/UniqFM.hs