diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-01-07 14:25:15 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-13 21:27:34 -0500 |
commit | 8e2f85f6b4662676f0d7addaff9bf2c7d751bb63 (patch) | |
tree | 6a5bea5db12d907874cdf26d709d829a3f3216ba /testsuite/tests/regalloc | |
parent | 40983d2331fe34c0af6925db7588d5ac6a19ae36 (diff) | |
download | haskell-8e2f85f6b4662676f0d7addaff9bf2c7d751bb63.tar.gz |
Refactor Logger
Before this patch, the only way to override GHC's default logging
behavior was to set `log_action`, `dump_action` and `trace_action`
fields in DynFlags. This patch introduces a new Logger abstraction and
stores it in HscEnv instead.
This is part of #17957 (avoid storing state in DynFlags). DynFlags are
duplicated and updated per-module (because of OPTIONS_GHC pragma), so
we shouldn't store global state in them.
This patch also fixes a race in parallel "--make" mode which updated
the `generatedDumps` IORef concurrently.
Bump haddock submodule
The increase in MultilayerModules is tracked in #19293.
Metric Increase:
MultiLayerModules
Diffstat (limited to 'testsuite/tests/regalloc')
-rw-r--r-- | testsuite/tests/regalloc/regalloc_unit_tests.hs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/testsuite/tests/regalloc/regalloc_unit_tests.hs b/testsuite/tests/regalloc/regalloc_unit_tests.hs index fee1302b8e..afc6fa0fca 100644 --- a/testsuite/tests/regalloc/regalloc_unit_tests.hs +++ b/testsuite/tests/regalloc/regalloc_unit_tests.hs @@ -64,9 +64,10 @@ main = do --get a GHC context and run the tests runGhc (Just libdir) $ do dflags <- fmap setOptions getDynFlags + logger <- getLogger reifyGhc $ \_ -> do us <- unitTestUniqSupply - runTests dflags us + runTests logger dflags us return () @@ -100,6 +101,7 @@ assertIO = assertOr $ \msg -> void (throwIO . RegAllocTestException $ msg) -- ***NOTE*** This function sets Opt_D_dump_asm_stats in the passed -- DynFlags because it won't work without it. Handle stderr appropriately. compileCmmForRegAllocStats :: + Logger -> DynFlags -> FilePath -> (NCGConfig -> @@ -107,7 +109,7 @@ compileCmmForRegAllocStats :: UniqSupply -> IO [( Maybe [Color.RegAllocStats (Alignment, RawCmmStatics) X86.Instr.Instr] , Maybe [Linear.RegAllocStats])] -compileCmmForRegAllocStats dflags' cmmFile ncgImplF us = do +compileCmmForRegAllocStats logger dflags' cmmFile ncgImplF us = do let ncgImpl = ncgImplF (initNCGConfig dflags thisMod) hscEnv <- newHscEnv dflags @@ -117,18 +119,18 @@ compileCmmForRegAllocStats dflags' cmmFile ncgImplF us = do errorMsgs = fmap pprError errors -- print parser errors or warnings - mapM_ (printBagOfErrors dflags) [warningMsgs, errorMsgs] + mapM_ (printBagOfErrors logger dflags) [warningMsgs, errorMsgs] let initTopSRT = emptySRT thisMod cmmGroup <- fmap snd $ cmmPipeline hscEnv initTopSRT $ fromJust parsedCmm - rawCmms <- cmmToRawCmm dflags (Stream.yield cmmGroup) + rawCmms <- cmmToRawCmm logger dflags (Stream.yield cmmGroup) collectedCmms <- mconcat <$> Stream.collect rawCmms -- compile and discard the generated code, returning regalloc stats mapM (\ (count, thisCmm) -> - cmmNativeGen dflags thisModLoc ncgImpl + cmmNativeGen logger dflags thisModLoc ncgImpl usb dwarfFileIds dbgMap thisCmm count >>= (\(_, _, _, _, colorStats, linearStats, _) -> -- scrub unneeded output from cmmNativeGen @@ -160,8 +162,8 @@ noSpillsCmmFile = "no_spills.cmm" -- | Run each unit test in this file and notify the user of success or -- failure. -runTests :: DynFlags -> UniqSupply -> IO () -runTests dflags us = testGraphNoSpills dflags noSpillsCmmFile us >>= \res -> +runTests :: Logger -> DynFlags -> UniqSupply -> IO () +runTests logger dflags us = testGraphNoSpills logger dflags noSpillsCmmFile us >>= \res -> if res then putStrLn "All tests passed." else hPutStr stderr "testGraphNoSpills failed!" @@ -177,10 +179,10 @@ runTests dflags us = testGraphNoSpills dflags noSpillsCmmFile us >>= \res -> -- the register allocator should be able to do everything -- (on x86) in the passed file without any spills or reloads. -- -testGraphNoSpills :: DynFlags -> FilePath -> UniqSupply -> IO Bool -testGraphNoSpills dflags' path us = do +testGraphNoSpills :: Logger -> DynFlags -> FilePath -> UniqSupply -> IO Bool +testGraphNoSpills logger dflags' path us = do colorStats <- fst . concatTupledMaybes <$> - compileCmmForRegAllocStats dflags path X86.ncgX86 us + compileCmmForRegAllocStats logger dflags path X86.ncgX86 us assertIO "testGraphNoSpills: color stats should not be empty" $ not (null colorStats) |