Simon Jakobi pushed to branch wip/sjakobi/T27507 at Glasgow Haskell Compiler / GHC
Commits:
-
a358c3f8
by Simon Jakobi at 2026-07-16T13:59:51+02:00
3 changed files:
- + testsuite/tests/simplStg/should_run/T27507a.hs
- + testsuite/tests/simplStg/should_run/T27507a.stdout
- testsuite/tests/simplStg/should_run/all.T
Changes:
| 1 | +{-# LANGUAGE BangPatterns #-}
|
|
| 2 | +-- Ensure the Box is returned boxed rather than unwrapped by CPR.
|
|
| 3 | +-- Ensure fun_exit is not floated to top, but works either way.
|
|
| 4 | +{-# OPTIONS_GHC -fno-cpr-anal -fno-full-laziness #-}
|
|
| 5 | + |
|
| 6 | +module Main where
|
|
| 7 | + |
|
| 8 | +import GHC.Exts (noinline)
|
|
| 9 | +import GHC.Exts.Heap (getClosureData, info, tipe)
|
|
| 10 | + |
|
| 11 | +data Box a = Box !a
|
|
| 12 | + |
|
| 13 | +foo :: Bool -> Int -> (Int, Box Int)
|
|
| 14 | +foo b !x = case x of
|
|
| 15 | + x' -> let -- Keep fun_exit monomorphic so that it can become a join point.
|
|
| 16 | + -- Without this signature its polymorphic result type prevents contification.
|
|
| 17 | + fun_exit :: Int -> Int -> (Int, Box Int)
|
|
| 18 | + fun_exit x_f i = (i, Box x_f)
|
|
| 19 | + {-# NOINLINE fun_exit #-}
|
|
| 20 | + in if b then fun_exit x' 0 else fun_exit x' 1
|
|
| 21 | +{-# NOINLINE foo #-}
|
|
| 22 | + |
|
| 23 | +main :: IO ()
|
|
| 24 | +main =
|
|
| 25 | + case foo True 42 of
|
|
| 26 | + (_, bx) -> do
|
|
| 27 | + c <- noinline getClosureData bx
|
|
| 28 | + noinline print (tipe (info c)) |
| 1 | +CONSTR_1_0 |
| ... | ... | @@ -24,3 +24,4 @@ test('T23783', normal, multimod_compile_and_run, ['T23783', '-O -v0']) |
| 24 | 24 | test('unpack_enum', normal, compile_and_run, [''])
|
| 25 | 25 | test('T27005a', normal, compile_and_run, [''])
|
| 26 | 26 | test('T27507', normal, compile_and_run, [''])
|
| 27 | +test('T27507a', normal, compile_and_run, ['']) |