[Git][ghc/ghc][master] Compute LambdaFormInfo when using JavaScript backend.

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Mar 21 22:12:31 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00
Compute LambdaFormInfo when using JavaScript backend.

CmmCgInfos is needed to write interface files, but the
JavaScript backend does not generate it, causing
"Name without LFInfo" warnings.

This patch adds a conservative but always correct
CmmCgInfos when the JavaScript backend is used.

Fixes #23053

- - - - -


5 changed files:

- compiler/GHC/Driver/Main.hs
- testsuite/tests/driver/all.T
- testsuite/tests/lib/integer/all.T
- testsuite/tests/simplCore/should_compile/all.T
- testsuite/tests/stranal/should_run/all.T


Changes:

=====================================
compiler/GHC/Driver/Main.hs
=====================================
@@ -204,7 +204,7 @@ import GHC.Builtin.Names
 import GHC.Builtin.Uniques ( mkPseudoUniqueE )
 
 import qualified GHC.StgToCmm as StgToCmm ( codeGen )
-import GHC.StgToCmm.Types (CmmCgInfos (..), ModuleLFInfos)
+import GHC.StgToCmm.Types (CmmCgInfos (..), ModuleLFInfos, LambdaFormInfo(..))
 
 import GHC.Cmm
 import GHC.Cmm.Info.Build
@@ -230,6 +230,7 @@ import GHC.Types.Id
 import GHC.Types.SourceError
 import GHC.Types.SafeHaskell
 import GHC.Types.ForeignStubs
+import GHC.Types.Name.Env      ( mkNameEnv )
 import GHC.Types.Var.Env       ( emptyTidyEnv )
 import GHC.Types.Error
 import GHC.Types.Fixity.Env
@@ -1872,7 +1873,19 @@ hscGenHardCode hsc_env cgguts location output_filename = do
             JSCodeOutput ->
               do
               let js_config = initStgToJSConfig dflags
-                  cmm_cg_infos  = Nothing
+
+                  -- The JavaScript backend does not create CmmCgInfos like the Cmm backend,
+                  -- but it is needed for writing the interface file. Here we compute a very
+                  -- conservative but correct value.
+                  lf_infos (StgTopLifted (StgNonRec b _)) = [(idName b, LFUnknown True)]
+                  lf_infos (StgTopLifted (StgRec bs))     = map (\(b,_) -> (idName b, LFUnknown True)) bs
+                  lf_infos (StgTopStringLit b _)          = [(idName b, LFUnlifted)]
+
+                  cmm_cg_infos  = CmmCgInfos
+                    { cgNonCafs = mempty
+                    , cgLFInfos = mkNameEnv (concatMap lf_infos stg_binds)
+                    , cgIPEStub = mempty
+                    }
                   stub_c_exists = Nothing
                   foreign_fps   = []
 
@@ -1881,7 +1894,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do
 
               -- do the unfortunately effectual business
               stgToJS logger js_config stg_binds this_mod spt_entries foreign_stubs0 cost_centre_info output_filename
-              return (output_filename, stub_c_exists, foreign_fps, Just stg_cg_infos, cmm_cg_infos)
+              return (output_filename, stub_c_exists, foreign_fps, Just stg_cg_infos, Just cmm_cg_infos)
 
             _          ->
               do


=====================================
testsuite/tests/driver/all.T
=====================================
@@ -278,7 +278,7 @@ test('T13604a',
   ], makefile_test, [])
 # omitting hpc and profasm because they affect the
 # inlining and unfoldings
-test('inline-check', [omit_ways(['hpc', 'profasm']), js_broken(22576)]
+test('inline-check', [omit_ways(['hpc', 'profasm'])]
                    , compile
 		   , ['-dinline-check foo -O -ddebug-output'])
 


=====================================
testsuite/tests/lib/integer/all.T
=====================================
@@ -5,9 +5,9 @@ test('plusMinusInteger', [omit_ways(['ghci'])], compile_and_run, [''])
 test('integerConstantFolding', normal, makefile_test, ['integerConstantFolding'])
 test('naturalConstantFolding', normal, makefile_test, ['naturalConstantFolding'])
 
-test('fromToInteger', js_broken(22576), makefile_test, ['fromToInteger'])
+test('fromToInteger', normal, makefile_test, ['fromToInteger'])
 
-test('IntegerConversionRules', [js_broken(22576)], makefile_test, ['IntegerConversionRules'])
+test('IntegerConversionRules', normal, makefile_test, ['IntegerConversionRules'])
 test('gcdInteger', normal, compile_and_run, [''])
 test('gcdeInteger', normal, compile_and_run, [''])
 test('integerPowMod', [], compile_and_run, [''])


=====================================
testsuite/tests/simplCore/should_compile/all.T
=====================================
@@ -378,7 +378,7 @@ test('T20200a', normal, compile, ['-O2'])
 test('T20200b', normal, compile, ['-O2'])
 test('T20200KG', [extra_files(['T20200KGa.hs', 'T20200KG.hs-boot'])], multimod_compile, ['T20200KG', '-v0 -O2 -fspecialise-aggressively'])
 test('T20639', normal, compile, ['-O2'])
-test('T20894', js_broken(22576), compile, ['-dcore-lint -O1 -ddebug-output'])
+test('T20894', normal, compile, ['-dcore-lint -O1 -ddebug-output'])
 test('T19790',  normal, compile, ['-O -ddump-rule-firings'])
 
 # This one had a Lint failure due to an occurrence analysis bug


=====================================
testsuite/tests/stranal/should_run/all.T
=====================================
@@ -1,6 +1,6 @@
 # Run this always as we compile the test with -O0 and -O1 and check that the
 # output is correct and the same in both cases.
-test('T16197', js_broken(22576), makefile_test, [])
+test('T16197', normal, makefile_test, [])
 
 # Run the rest only in optasm way (which implies -O), we're testing the
 # strictness analyser here



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea24360d0548c905b6b2427b5cdcb82d3cd296ae

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea24360d0548c905b6b2427b5cdcb82d3cd296ae
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230321/05a78608/attachment-0001.html>


More information about the ghc-commits mailing list