From 03b7abc19c8b0ec5c606cc2da208d2d004807fe9 Mon Sep 17 00:00:00 2001 From: "klebinger.andreas@gmx.at" Date: Sat, 26 Jan 2019 00:26:02 +0100 Subject: 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. --- compiler/nativeGen/AsmCodeGen.hs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'compiler/nativeGen/AsmCodeGen.hs') 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 -- cgit v1.2.1