
#14118: stg2stg passes appear to produce invalid STG
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
While building with GHC with `-dstg-lint -g3 -O0` (after fixing #14116 and
#14117) I encountered a rather peculiar error,
{{{
"inplace/bin/ghc-stage1" -hisuf hi -osuf o -hcsuf hc -static -O -H64m
-Wall -this-unit-id integer-gmp-1.0.1.0 -hide-all-packages -i
-ilibraries/integer-gmp/src/ -ilibraries/integer-gmp/dist-install/build
-Ilibraries/integer-gmp/dist-install/build -ilibraries/integer-gmp/dist-
install/build/./autogen -Ilibraries/integer-gmp/dist-
install/build/./autogen -Ilibraries/integer-gmp/include -optP-include
-optPlibrari
es/integer-gmp/dist-install/build/./autogen/cabal_macros.h -package-id
ghc-prim-0.5.1.0 -this-unit-id integer-gmp -Wall -XHaskell2010 -O -dcore-
lint -g3 -ddump-to-file -ddump-stg -dcore-lint -dstg-lint -dcmm-lin
t -no-user-package-db -rtsopts -Wno-deprecated-flags -Wnoncanonical-
monad-instances -odir libraries/integer-gmp/dist-install/build -hidir
libraries/integer-gmp/dist-install/build -stubdir libraries/intege
r-gmp/dist-install/build -dynamic-too -c libraries/integer-
gmp/src//GHC/Integer/Type.hs -o libraries/integer-gmp/dist-
install/build/GHC/Integer/Type.o -dyno libraries/integer-gmp/dist-
install/build/GHC/Integer
/Type.dyn_o
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 8.3.20170815 for x86_64-unknown-linux):
*** Stg Lint ErrMsgs: in Stg2Stg ***
<no location info>: warning:
[in body of lambda with binders m0_scBy :: State# s_a2Em
-> State# s_a2Em,
s1_scBz :: State# s_a2Em]
s'_scBA is out of scope
<no location info>: warning:
[in body of lambda with binders wild1_sdUv :: Int#]
qr_sdUp is out of scope
}}}
Looking at the STG it appears that these warnings are absolutely correct,
{{{#!hs
svoid [InlPrag=INLINE (sat-args=1)]
:: forall s. (State# s -> State# s) -> S s ()
[GblId,
Arity=2,
Caf=NoCafRefs,
Str=,
Unf=OtherCon []] =
\r [m0_scBy s1_scBz]
src,
Unf=OtherCon []]
GHC.Integer.Type.svoid
= \ (@ s_a2Em)
(m0_scBy [Occ=Once!]
:: GHC.Prim.State# s_a2Em -> GHC.Prim.State# s_a2Em)
(s1_scBz [Occ=Once] :: GHC.Prim.State# s_a2Em) ->
src