[Git][ghc/ghc][wip/sjakobi/T27106] Fix -dsuppress-uniques for free variables in demand signatures
Simon Jakobi pushed to branch wip/sjakobi/T27106 at Glasgow Haskell Compiler / GHC Commits: 6a7faadc by Simon Jakobi at 2026-03-28T12:58:05+01:00 Fix -dsuppress-uniques for free variables in demand signatures Before: Str=b{sXyZ->S} With this patch: Str=b{S} T13143.stderr is updated accordingly. Fixes #27106. - - - - - 5 changed files: - compiler/GHC/Types/Demand.hs - testsuite/tests/dmdanal/should_compile/T13143.stderr - + testsuite/tests/dmdanal/should_compile/T27106.hs - + testsuite/tests/dmdanal/should_compile/T27106.stderr - testsuite/tests/dmdanal/should_compile/all.T Changes: ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -2830,7 +2830,10 @@ instance Outputable DmdEnv where = ppr div <> if null fv_elts then empty else braces (fsep (map pp_elt fv_elts)) where - pp_elt (uniq, dmd) = ppr uniq <> text "->" <> ppr dmd + pp_elt (uniq, dmd) = + sdocOption sdocSuppressUniques $ \case + True -> ppr dmd + False -> ppr uniq <> text "->" <> ppr dmd fv_elts = nonDetUFMToList fvs -- It's OK to use nonDetUFMToList here because we only do it for -- pretty printing ===================================== testsuite/tests/dmdanal/should_compile/T13143.stderr ===================================== @@ -1,13 +1,13 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 71, types: 40, coercions: 0, joins: 0/0} + = {terms: 59, types: 31, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] :: forall a. (# #) -> a -[GblId, Arity=1, Str=<B>b{sBX->S}, Cpr=b, Unf=OtherCon []] +[GblId, Arity=1, Str=<B>b{S}, Cpr=b, Unf=OtherCon []] T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Internal.Types.(##) end Rec } @@ -16,7 +16,7 @@ end Rec } f [InlPrag=NOINLINE[final]] :: forall a. Int -> a [GblId, Arity=1, - Str=<B>b{sBX->S}, + Str=<B>b{S}, Cpr=b, Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -26,100 +26,58 @@ f [InlPrag=NOINLINE[final]] :: forall a. Int -> a f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Internal.Types.(##) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule4 :: GHC.Internal.Prim.Addr# -[GblId, - Unf=Unf{Src=<vanilla>, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 20 0}] -T13143.$trModule4 = "main"# +$trModule1 :: GHC.Internal.Prim.Addr# +[GblId, Unf=OtherCon []] +$trModule1 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule3 :: GHC.Internal.Types.TrName -[GblId, - Unf=Unf{Src=<vanilla>, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -T13143.$trModule3 = GHC.Internal.Types.TrNameS T13143.$trModule4 +$trModule2 :: GHC.Internal.Types.TrName +[GblId, Unf=OtherCon []] +$trModule2 = GHC.Internal.Types.TrNameS $trModule1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule2 :: GHC.Internal.Prim.Addr# -[GblId, - Unf=Unf{Src=<vanilla>, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 30 0}] -T13143.$trModule2 = "T13143"# +$trModule3 :: GHC.Internal.Prim.Addr# +[GblId, Unf=OtherCon []] +$trModule3 = "T13143"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule1 :: GHC.Internal.Types.TrName -[GblId, - Unf=Unf{Src=<vanilla>, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -T13143.$trModule1 = GHC.Internal.Types.TrNameS T13143.$trModule2 +$trModule4 :: GHC.Internal.Types.TrName +[GblId, Unf=OtherCon []] +$trModule4 = GHC.Internal.Types.TrNameS $trModule3 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule :: GHC.Internal.Types.Module -[GblId, - Unf=Unf{Src=<vanilla>, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -T13143.$trModule - = GHC.Internal.Types.Module T13143.$trModule3 T13143.$trModule1 +T13143.$trModule [InlPrag=[~]] :: GHC.Internal.Types.Module +[GblId, Unf=OtherCon []] +T13143.$trModule = GHC.Internal.Types.Module $trModule2 $trModule4 --- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int -[GblId, Str=b{sBX->S}, Cpr=b] -lvl = T13143.$wf @Int GHC.Internal.Types.(##) +[GblId, Unf=OtherCon []] +lvl = GHC.Internal.Types.I# 1# + +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +lvl1 :: Int +[GblId, Str=b{S}, Cpr=b] +lvl1 = T13143.$wf @Int GHC.Internal.Types.(##) Rec { -- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} -T13143.$wg [InlPrag=[2], Occ=LoopBreaker] - :: Bool -> Bool -> GHC.Internal.Prim.Int# -> GHC.Internal.Prim.Int# -[GblId[StrictWorker([!, !])], - Arity=3, - Str=<1L><1L><L>, - Unf=OtherCon []] -T13143.$wg - = \ (ds :: Bool) (ds1 :: Bool) (ww :: GHC.Internal.Prim.Int#) -> +g [Occ=LoopBreaker] :: Bool -> Bool -> Int -> Int +[GblId, Arity=3, Str=<1L><1L><L>, Unf=OtherCon []] +g = \ (ds :: Bool) (ds1 :: Bool) (p :: Int) -> case ds of { False -> case ds1 of { - False -> - T13143.$wg GHC.Internal.Types.False GHC.Internal.Types.True ww; - True -> GHC.Internal.Prim.+# ww 1# + False -> g GHC.Internal.Types.False GHC.Internal.Types.True p; + True -> + @Int GHC.Internal.Num.$fNumInt p lvl }; True -> case ds1 of { - False -> - T13143.$wg GHC.Internal.Types.True GHC.Internal.Types.True ww; - True -> case lvl of {} + False -> g GHC.Internal.Types.True GHC.Internal.Types.True p; + True -> lvl1 } } end Rec } --- RHS size: {terms: 14, types: 6, coercions: 0, joins: 0/0} -g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int -[GblId, - Arity=3, - Str=<1L><1L><1!P(L)>, - Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) - Tmpl= \ (ds [Occ=Once1] :: Bool) - (ds1 [Occ=Once1] :: Bool) - (p [Occ=Once1!] :: Int) -> - case p of { GHC.Internal.Types.I# ww [Occ=Once1] -> - case T13143.$wg ds ds1 ww of ww1 [Occ=Once1] { __DEFAULT -> - GHC.Internal.Types.I# ww1 - } - }}] -g = \ (ds :: Bool) (ds1 :: Bool) (p :: Int) -> - case p of { GHC.Internal.Types.I# ww -> - case T13143.$wg ds ds1 ww of ww1 { __DEFAULT -> - GHC.Internal.Types.I# ww1 - } - } - ===================================== testsuite/tests/dmdanal/should_compile/T27106.hs ===================================== @@ -0,0 +1,5 @@ +module T27106 where + +{-# NOINLINE weird #-} +weird :: Int -> a +weird x = weird x ===================================== testsuite/tests/dmdanal/should_compile/T27106.stderr ===================================== @@ -0,0 +1,4 @@ +weird [InlPrag=NOINLINE[final]] :: forall a. Int -> a +[GblId, + Arity=1, + Str=<B>b{S}, ===================================== testsuite/tests/dmdanal/should_compile/all.T ===================================== @@ -45,6 +45,13 @@ test('T13077a', normal, compile, ['']) # T13143: WW for NOINLINE function f test('T13143', [ grep_errmsg(r'^T13143\.\$wf') ], compile, ['-ddump-simpl -dsuppress-uniques']) +# Uniques in the free variable part of a demand signature should be +# suppressed by -dsuppress-uniques. +test('T27106', normal, multimod_compile_filter, + ['T27106', + '-v0 -O -ddump-simpl -dsuppress-uniques', + r"sed -n '/^weird /,/.* Str=/p'"]) + # T15627 # Absent bindings of unlifted types should be WW'ed away. # The idea is to check that both $wmutVar and $warray View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a7faadcbe78ad826ab116b6191c7d0b... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a7faadcbe78ad826ab116b6191c7d0b... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Jakobi (@sjakobi2)