Magnus pushed to branch wip/mangoiv/bp-16719 at Glasgow Haskell Compiler / GHC

Commits:

15 changed files:

Changes:

  • changelog.d/27845
    1
    +section: compiler
    
    2
    +synopsis: Fix a bug where an argument used lazily only by a function's stable
    
    3
    +  unfolding could be treated as strict in its fields.
    
    4
    +mrs: !16746
    
    5
    +issues: #27845

  • compiler/GHC/Types/Demand.hs
    ... ... @@ -927,6 +927,8 @@ maxCard (Card a) (Card b) = Card ((a .&. b .&. 0b001) .|. ((a .|. b) .&. 0b110))
    927 927
     maxDmd :: Demand -> Demand -> Demand
    
    928 928
     maxDmd BotDmd      dmd2        = dmd2
    
    929 929
     maxDmd dmd1        BotDmd      = dmd1
    
    930
    +maxDmd AbsDmd      dmd2        = dmd2
    
    931
    +maxDmd dmd1        AbsDmd      = dmd1
    
    930 932
     maxDmd (n1 :* sd1) (n2 :* sd2) =
    
    931 933
       maxCard n1 n2 :* maxSubDmd sd1 sd2
    
    932 934
     
    

  • rts/include/rts/PosixSource.h
    ... ... @@ -29,6 +29,8 @@
    29 29
        Oracle's Solaris 11 supports only up to XPG6, hence the ifdef.
    
    30 30
       */
    
    31 31
     
    
    32
    +#undef _POSIX_C_SOURCE
    
    33
    +#undef _XOPEN_SOURCE
    
    32 34
     #if defined(solaris2_HOST_OS)
    
    33 35
     #define _POSIX_C_SOURCE 200112L
    
    34 36
     #define _XOPEN_SOURCE   600
    

  • testsuite/tests/bytecode/T27001.stdout
    1
    -(0.40 secs,)
    
    1
    +(0.19 secs,)
    
    2 2
     it :: ()
    
    3 3
     100000.0
    
    4
    -(0.19 secs, 51,566,088 bytes)
    4
    +(0.12 secs, 51,566,088 bytes)

  • testsuite/tests/bytecode/T27842.stdout
    1
    +(0.28 secs,)
    
    2
    +it :: ()
    
    1 3
     42
    
    2 4
     42
    
    3 5
     3
    
    6
    +(0.08 secs, 142,200 bytes)

  • testsuite/tests/bytecode/all.T
    ... ... @@ -21,5 +21,5 @@ test('T27001', [extra_files(['T27001.hs']), req_interp],
    21 21
     test('T27842', [extra_files(['T27842A.hs', 'T27842N.hs']), req_interp],
    
    22 22
          run_command,
    
    23 23
          ['{compiler} -e main -O -fno-unoptimized-core-for-interpreter '
    
    24
    -      '-fobject-code -fbyte-code-and-object-code -fwrite-byte-code -fprefer-byte-code '
    
    24
    +      '-fobject-code -fbyte-code-and-object-code -fprefer-byte-code '
    
    25 25
           'T27842.hs'])

  • testsuite/tests/dmdanal/should_run/T27845.hs
    1
    +module Main where
    
    2
    +import T27845_Lib (f)
    
    3
    +import System.Environment (getArgs)
    
    4
    +
    
    5
    +{-# NOINLINE mkArg #-}
    
    6
    +mkArg :: Int -> Int
    
    7
    +mkArg n | n < 0     = n
    
    8
    +        | otherwise = error ("boom " ++ show n)
    
    9
    +
    
    10
    +main :: IO ()
    
    11
    +main = do
    
    12
    +  n <- length <$> getArgs
    
    13
    +  let x = mkArg n
    
    14
    +  print (length (f (x, x) n))

  • testsuite/tests/dmdanal/should_run/T27845.stdout
    1
    +0

  • testsuite/tests/dmdanal/should_run/T27845_Lib.hs
    1
    +module T27845_Lib where
    
    2
    +
    
    3
    +{-# INLINABLE [2] f #-}
    
    4
    +f :: a -> Int -> [a]
    
    5
    +f p x = lazyUse p x ++ lazyUse p (x + 1) ++ lazyUse p (x + 2)
    
    6
    +
    
    7
    +{-# NOINLINE lazyUse #-}
    
    8
    +lazyUse :: a -> Int -> [a]
    
    9
    +lazyUse p x = p `seq` replicate x p
    
    10
    +
    
    11
    +{-# RULES "lazyUse" [1] forall p x. lazyUse p x = [] #-}

  • testsuite/tests/dmdanal/should_run/T27845b.hs
    1
    +module Main where
    
    2
    +import T27845b_Lib (outer)
    
    3
    +import System.Environment (getArgs)
    
    4
    +
    
    5
    +{-# NOINLINE mkArg #-}
    
    6
    +mkArg :: Int -> Int
    
    7
    +mkArg n | n < 0     = n
    
    8
    +        | otherwise = error ("boom " ++ show n)
    
    9
    +
    
    10
    +main :: IO ()
    
    11
    +main = do
    
    12
    +  n <- length <$> getArgs
    
    13
    +  let x = mkArg n
    
    14
    +  print (length (outer (x, x) n))

  • testsuite/tests/dmdanal/should_run/T27845b.stdout
    1
    +0

  • testsuite/tests/dmdanal/should_run/T27845b_Lib.hs
    1
    +module T27845b_Lib where
    
    2
    +
    
    3
    +outer :: a -> Int -> [a]
    
    4
    +outer a n =
    
    5
    +  let {-# INLINABLE [2] g #-}
    
    6
    +      g x = lazyUse a (x + 0) ++ lazyUse a (x + 1) ++ lazyUse a (x + 2)
    
    7
    +  in g n ++ g (n + 1) ++ g (n + 2)
    
    8
    +{-# NOINLINE outer #-}
    
    9
    +
    
    10
    +{-# NOINLINE lazyUse #-}
    
    11
    +lazyUse :: a -> Int -> [a]
    
    12
    +lazyUse p x = p `seq` replicate x p
    
    13
    +
    
    14
    +{-# RULES "lazyUse" [1] forall p x. lazyUse p x = [] #-}

  • testsuite/tests/dmdanal/should_run/all.T
    ... ... @@ -36,3 +36,5 @@ test('T23208', exit_code(1), multimod_compile_and_run, ['T23208_Lib', 'T23208'])
    36 36
     test('T25439', normal, compile_and_run, [''])
    
    37 37
     test('T26416', [extra_files(['M1.hs'])], multimod_compile_and_run, ['T26416','M1.hs'])
    
    38 38
     test('T27626', [extra_files(['M2.hs'])], multimod_compile_and_run, ['T27626','M2.hs'])
    
    39
    +test('T27845', [extra_files(['T27845_Lib.hs'])], multimod_compile_and_run, ['T27845','T27845_Lib.hs'])
    
    40
    +test('T27845b', [extra_files(['T27845b_Lib.hs'])], multimod_compile_and_run, ['T27845b','T27845b_Lib.hs'])

  • testsuite/tests/simplStg/should_run/T22042.stdout
    1
    -(0.30 secs,)
    
    1
    +(0.11 secs,)
    
    2 2
     it :: ()
    
    3 3
     ABC
    
    4
    -(0.14 secs, 223,768 bytes)
    4
    +(0.06 secs, 223,768 bytes)

  • testsuite/tests/simplStg/should_run/all.T
    ... ... @@ -26,9 +26,6 @@ test('T22042', [extra_files(['T22042a.hs']),only_ways('normal'),unless(have_dyna
    26 26
     # Depends on tag inference being similarly effective for bytecode which it is not yet.
    
    27 27
     test('T23783', omit_ghci, multimod_compile_and_run, ['T23783', '-O -v0'])
    
    28 28
     
    
    29
    -# Requires UNPACK which needs -O
    
    30
    -test('unpack_enum', omit_ways(['ghci']), compile_and_run, [''])
    
    31
    -
    
    32 29
     # Tests that tag inference optimizes well, which is not the case for bytecode or
    
    33 30
     # when we insert profiling ticks.
    
    34 31
     test('T27005a', omit_ways(ghci_ways + prof_ways), compile_and_run, [''])