From 2974b2b873b4bad007c619c6e32706123a612428 Mon Sep 17 00:00:00 2001 From: Michal Terepeta Date: Thu, 1 Feb 2018 00:30:22 -0500 Subject: Hoopl.Collections: change right folds to strict left folds It seems that most uses of these folds should be strict left folds (I could only find a single place that benefits from a right fold). So this removes the existing `setFold`/`mapFold`/`mapFoldWihKey` replaces them with: - `setFoldl`/`mapFoldl`/`mapFoldlWithKey` (strict left folds) - `setFoldr`/`mapFoldr` (for the less common case where a right fold actually makes sense, e.g., `CmmProcPoint`) Signed-off-by: Michal Terepeta Test Plan: ./validate Reviewers: bgamari, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter, kavon Differential Revision: https://phabricator.haskell.org/D4356 --- compiler/nativeGen/RegAlloc/Graph/Spill.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'compiler/nativeGen') diff --git a/compiler/nativeGen/RegAlloc/Graph/Spill.hs b/compiler/nativeGen/RegAlloc/Graph/Spill.hs index 02da824cfe..bce24bdd3c 100644 --- a/compiler/nativeGen/RegAlloc/Graph/Spill.hs +++ b/compiler/nativeGen/RegAlloc/Graph/Spill.hs @@ -113,8 +113,8 @@ regSpill_top platform regSlotMap cmm -- after we've done a successful allocation. let liveSlotsOnEntry' :: BlockMap IntSet liveSlotsOnEntry' - = mapFoldWithKey patchLiveSlot - liveSlotsOnEntry liveVRegsOnEntry + = mapFoldlWithKey patchLiveSlot + liveSlotsOnEntry liveVRegsOnEntry let info' = LiveInfo static firstId @@ -131,10 +131,9 @@ regSpill_top platform regSlotMap cmm -- then record the fact that these slots are now live in those blocks -- in the given slotmap. patchLiveSlot - :: BlockId -> RegSet - -> BlockMap IntSet -> BlockMap IntSet + :: BlockMap IntSet -> BlockId -> RegSet -> BlockMap IntSet - patchLiveSlot blockId regsLive slotMap + patchLiveSlot slotMap blockId regsLive = let -- Slots that are already recorded as being live. curSlotsLive = fromMaybe IntSet.empty -- cgit v1.2.1