Commit c9eb4385 authored by duog's avatar duog Committed by Ben Gamari

Desugar modules compiled with -fno-code

Previously modules with hscTarget == HscNothing were not desugared.
This patch changes behavior so that all modules HsSrcFile Modules except GHC.Prim
are desugared. Modules with hscTarget == HscNothing are not simplified.

Warnings and errors produced by the desugarer will now be produced when
compiling with -fno-code.

HscMain.finishTypecheckingOnly is removed, HscMain.hscIncrementalCompile is
simplified a bit, and HscMain.finish takes in the removed logic. I think this
is easier to follow.

Updates haddock submodule.

Tests T8101, T8101b, T10600 are no longer expect_broken.

Reviewers: ezyang, austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #10600

Differential Revision: https://phabricator.haskell.org/D3542
parent a65dfea5
......@@ -137,6 +137,7 @@ import FamInstEnv
import Fingerprint ( Fingerprint )
import Hooks
import TcEnv
import PrelNames
import DynFlags
import ErrUtils
......@@ -657,8 +658,6 @@ hscIncrementalCompile always_do_basic_recompilation_check m_tc_result
-- to get those warnings too. (But we'll always exit at that point
-- because the desugarer runs ioMsgMaybe.)
runHsc hsc_env $ do
let dflags = hsc_dflags hsc_env
e <- hscIncrementalFrontend always_do_basic_recompilation_check m_tc_result mHscMessage
mod_summary source_modified mb_old_iface mod_index
case e of
......@@ -686,61 +685,58 @@ hscIncrementalCompile always_do_basic_recompilation_check m_tc_result
-- the interface that existed on disk; it's possible we had
-- to retypecheck but the resulting interface is exactly
-- the same.)
Right (FrontendTypecheck tc_result, mb_old_hash) -> do
(status, hmi, no_change)
<- case ms_hsc_src mod_summary of
HsSrcFile | hscTarget dflags /= HscNothing ->
finish hsc_env mod_summary tc_result mb_old_hash
_ ->
finishTypecheckOnly hsc_env mod_summary tc_result mb_old_hash
liftIO $ hscMaybeWriteIface dflags (hm_iface hmi) no_change mod_summary
return (status, hmi)
-- Generates and writes out the final interface for a typecheck.
finishTypecheckOnly :: HscEnv
-> ModSummary
-> TcGblEnv
-> Maybe Fingerprint
-> Hsc (HscStatus, HomeModInfo, Bool)
finishTypecheckOnly hsc_env summary tc_result mb_old_hash = do
let dflags = hsc_dflags hsc_env
(iface, changed, details) <- liftIO $ hscSimpleIface hsc_env tc_result mb_old_hash
let hsc_status =
case (hscTarget dflags, ms_hsc_src summary) of
(HscNothing, _) -> HscNotGeneratingCode
(_, HsBootFile) -> HscUpdateBoot
(_, HsigFile) -> HscUpdateSig
_ -> panic "finishTypecheckOnly"
return (hsc_status,
HomeModInfo{ hm_details = details,
hm_iface = iface,
hm_linkable = Nothing },
changed)
Right (FrontendTypecheck tc_result, mb_old_hash) ->
finish hsc_env mod_summary tc_result mb_old_hash
-- Runs the post-typechecking frontend (desugar and simplify),
-- and then generates and writes out the final interface. We want
-- to write the interface AFTER simplification so we can get
-- as up-to-date and good unfoldings and other info as possible
-- in the interface file. This is only ever run for HsSrcFile,
-- and NOT for HscNothing.
-- in the interface file.
finish :: HscEnv
-> ModSummary
-> TcGblEnv
-> Maybe Fingerprint
-> Hsc (HscStatus, HomeModInfo, Bool)
-> Hsc (HscStatus, HomeModInfo)
finish hsc_env summary tc_result mb_old_hash = do
let dflags = hsc_dflags hsc_env
MASSERT( ms_hsc_src summary == HsSrcFile )
MASSERT( hscTarget dflags /= HscNothing )
guts0 <- hscDesugar' (ms_location summary) tc_result
guts <- hscSimplify' guts0
(iface, changed, details, cgguts) <- liftIO $ hscNormalIface hsc_env guts mb_old_hash
return (HscRecomp cgguts summary,
HomeModInfo{ hm_details = details,
hm_iface = iface,
hm_linkable = Nothing },
changed)
let dflags = hsc_dflags hsc_env
target = hscTarget dflags
hsc_src = ms_hsc_src summary
should_desugar =
ms_mod summary /= gHC_PRIM && hsc_src == HsSrcFile
mk_simple_iface = do
let hsc_status =
case (target, hsc_src) of
(HscNothing, _) -> HscNotGeneratingCode
(_, HsBootFile) -> HscUpdateBoot
(_, HsigFile) -> HscUpdateSig
_ -> panic "finish"
(iface, changed, details) <- liftIO $
hscSimpleIface hsc_env tc_result mb_old_hash
return (iface, changed, details, hsc_status)
(iface, changed, details, hsc_status) <-
-- we usually desugar even when we are not generating code, otherwise
-- we would miss errors thrown by the desugaring (see #10600). The only
-- exceptions are when the Module is Ghc.Prim or when
-- it is not a HsSrcFile Module.
if should_desugar
then do
desugared_guts0 <- hscDesugar' (ms_location summary) tc_result
if target == HscNothing
-- We are not generating code, so we can skip simplification
-- and generate a simple interface.
then mk_simple_iface
else do
desugared_guts <- hscSimplify' desugared_guts0
(iface, changed, details, cgguts) <-
liftIO $ hscNormalIface hsc_env desugared_guts mb_old_hash
return (iface, changed, details, HscRecomp cgguts summary)
else mk_simple_iface
liftIO $ hscMaybeWriteIface dflags iface changed summary
return
( hsc_status
, HomeModInfo
{hm_details = details, hm_iface = iface, hm_linkable = Nothing})
hscMaybeWriteIface :: DynFlags -> ModIface -> Bool -> ModSummary -> IO ()
hscMaybeWriteIface dflags iface changed summary =
......
......@@ -200,10 +200,10 @@ test('T8959a',
test('T703', normal, run_command, ['$MAKE -s --no-print-directory T703'])
test('T2182', normal, run_command, ['$MAKE -s --no-print-directory T2182'])
test('T8101', expect_broken(10600), compile, ['-Wall -fno-code'])
test('T8101b', expect_broken(10600), multimod_compile,
test('T8101', normal, compile, ['-Wall -fno-code'])
test('T8101b', normal, multimod_compile,
['T8101b', '-Wall -fno-code'])
test('T10600', expect_broken(10600), compile_fail, ['-fno-code'])
test('T10600', normal, compile_fail, ['-fno-code'])
# Should not panic when compiling cmm file together with -outputdir.
test('T9050', cmm_src, compile, ['-outputdir=.'])
......
......@@ -9,7 +9,7 @@ test('haddock.base',
[(platform('x86_64-unknown-mingw32'), 24286343184, 5)
# 2017-02-19 24286343184 (x64/Windows) - Generalize kind of (->)
,(wordsize(64), 25592972912, 5)
,(wordsize(64), 27868466432, 5)
# 2012-08-14: 5920822352 (amd64/Linux)
# 2012-09-20: 5829972376 (amd64/Linux)
# 2012-10-08: 5902601224 (amd64/Linux)
......@@ -39,6 +39,7 @@ test('haddock.base',
# 2017-02-16: 32695562088 Better Lint for join points
# 2017-02-17: 38425793776 (x86_64/Linux) - Generalize kind of (->)
# 2017-02-12: 25592972912 (x86_64/Linux) - Type-indexed Typeable
# 2017-06-05: 27868466432 (x86_64/Linux) - Desugar modules compiled with -fno-code
,(platform('i386-unknown-mingw32'), 2885173512, 5)
# 2013-02-10: 3358693084 (x86/Windows)
......@@ -65,7 +66,7 @@ test('haddock.Cabal',
[extra_files(['../../../../libraries/Cabal/Cabal/dist-install/haddock.t']),
unless(in_tree_compiler(), skip), req_haddock
,stats_num_field('bytes allocated',
[(wordsize(64), 18269309128, 5)
[(wordsize(64), 22294859000, 5)
# 2012-08-14: 3255435248 (amd64/Linux)
# 2012-08-29: 3324606664 (amd64/Linux, new codegen)
# 2012-10-08: 3373401360 (amd64/Linux)
......@@ -111,6 +112,7 @@ test('haddock.Cabal',
# 2017-02-17: 27784875792 (amd64/Linux) - Generalize kind of (->)
# 2017-02-12: 18865432648 (amd64/Linux) - Type-indexed Typeable
# 2017-05-31: 18269309128 (amd64/Linux) - Faster checkFamInstConsistency
# 2017-06-05: 22294859000 (amd64/Linux) - Desugar modules compiled with -fno-code
,(platform('i386-unknown-mingw32'), 3293415576, 5)
# 2012-10-30: 1733638168 (x86/Windows)
......@@ -134,7 +136,7 @@ test('haddock.compiler',
[extra_files(['../../../../compiler/stage2/haddock.t']),
unless(in_tree_compiler(), skip), req_haddock
,stats_num_field('bytes allocated',
[(wordsize(64), 52762752968, 10)
[(wordsize(64), 65378619232, 10)
# 2012-08-14: 26070600504 (amd64/Linux)
# 2012-08-29: 26353100288 (amd64/Linux, new CG)
# 2012-09-18: 26882813032 (amd64/Linux)
......@@ -153,6 +155,7 @@ test('haddock.compiler',
# 2017-02-11: 62070477608 (amd64/Linux) OccurAnal / One-Shot (#13227) (and others)
# 2017-02-25: 55777283352 (amd64/Linux) Early inline patch
# 2017-05-31: 52762752968 (amd64/Linux) Faster checkFamInstConsistency
# 2017-06-05: 65378619232 (amd64/Linux) Desugar modules compiled with -fno-code
,(platform('i386-unknown-mingw32'), 367546388, 10)
# 2012-10-30: 13773051312 (x86/Windows)
......
Subproject commit b7d7b7acd42cbe424afde3c8a5a59a0706445343
Subproject commit a1b57146c5678b32eb5ac37021e93a81a4b73007
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment