summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/AsmCodeGen.hs
diff options
context:
space:
mode:
authorklebinger.andreas@gmx.at <klebinger.andreas@gmx.at>2019-01-26 00:26:02 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-02-08 11:00:15 -0500
commit03b7abc19c8b0ec5c606cc2da208d2d004807fe9 (patch)
treee1d779fee191e71aafba557e6e4680d4d6aab60f /compiler/nativeGen/AsmCodeGen.hs
parent2b90356d26b4699227816ad9424e766eccdb6c36 (diff)
downloadhaskell-03b7abc19c8b0ec5c606cc2da208d2d004807fe9.tar.gz
Allow resizing the stack for the graph allocator.
The graph allocator now dynamically resizes the number of stack slots when running into the limit. This fixes #8657. Also loop membership of basic blocks is now available in the register allocator for cost heuristics.
Diffstat (limited to 'compiler/nativeGen/AsmCodeGen.hs')
-rw-r--r--compiler/nativeGen/AsmCodeGen.hs18
1 files changed, 15 insertions, 3 deletions
diff --git a/compiler/nativeGen/AsmCodeGen.hs b/compiler/nativeGen/AsmCodeGen.hs
index 956528bf81..8c62a15429 100644
--- a/compiler/nativeGen/AsmCodeGen.hs
+++ b/compiler/nativeGen/AsmCodeGen.hs
@@ -608,14 +608,26 @@ cmmNativeGen dflags this_mod modLoc ncgImpl us fileIds dbgMap cmm count
$ allocatableRegs ncgImpl
-- do the graph coloring register allocation
- let ((alloced, regAllocStats), usAlloc)
+ let ((alloced, maybe_more_stack, regAllocStats), usAlloc)
= {-# SCC "RegAlloc-color" #-}
initUs usLive
$ Color.regAlloc
dflags
alloc_regs
(mkUniqSet [0 .. maxSpillSlots ncgImpl])
+ (maxSpillSlots ncgImpl)
withLiveness
+ livenessCfg
+
+ let ((alloced', stack_updt_blks), usAlloc')
+ = initUs usAlloc $
+ case maybe_more_stack of
+ Nothing -> return (alloced, [])
+ Just amount -> do
+ (alloced',stack_updt_blks) <- unzip <$>
+ (mapM ((ncgAllocMoreStack ncgImpl) amount) alloced)
+ return (alloced', concat stack_updt_blks )
+
-- dump out what happened during register allocation
dumpIfSet_dyn dflags
@@ -637,10 +649,10 @@ cmmNativeGen dflags this_mod modLoc ncgImpl us fileIds dbgMap cmm count
-- force evaluation of the Maybe to avoid space leak
mPprStats `seq` return ()
- return ( alloced, usAlloc
+ return ( alloced', usAlloc'
, mPprStats
, Nothing
- , [], [])
+ , [], stack_updt_blks)
else do
-- do linear register allocation