[GHC] #8425: ghc-7.6.3: crossmodule inline leads to buggy code (-O2)
GHC
ghc-devs
Thu Oct 10 21:02:08 UTC 2013
#8425: ghc-7.6.3: crossmodule inline leads to buggy code (-O2)
-------------------------------------+----------------------------------
Reporter: slyfox | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: x86_64 (amd64)
Type of failure: Runtime crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+----------------------------------
Comment (by slyfox):
My theory is the bug is induced by '''{-# INLINABLE insert #-}''' and
'''{-# INLINABLE lookup #-}'''
pragmas.
It makes Main module use '''BuggyOpt.$sinsert''' specialisation (with it's
environment taken into account).
It's seen nicely when we build Main in both modes:
good (all ok: Base.lookup):
{{{
==================== Occurrence analysis ====================
[snip instances]
Main.mkLin
:: Arr.Array GHC.Types.Int
-> Base.Map (Arr.Array GHC.Types.Int) GHC.Types.Int
[LclIdX,
Arity=1,
Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=1, Value=True,
ConLike=True, WorkFree=True, Expandable=True,
Guidance=IF_ARGS [0] 110 0}]
Main.mkLin =
\ (mseqs_amq :: Arr.Array GHC.Types.Int) ->
case Base.lookup
@ (Arr.Array GHC.Types.Int)
@ (GHC.Prim.Any *)
(Arr.$fEqArray @ GHC.Types.Int)
mseqs_amq
(Base.empty @ (Arr.Array GHC.Types.Int) @ (GHC.Prim.Any *))
of _ { __DEFAULT ->
Base.insert
@ (Arr.Array GHC.Types.Int)
@ GHC.Types.Int
$dOrd_apD
mseqs_amq
(GHC.Types.I# 1)
(Base.empty @ (Arr.Array GHC.Types.Int) @ GHC.Types.Int)
}
}}}
bad (note BuggyOpt.$sinsert on an early phase):
{{{
==================== Occurrence analysis ====================
Main.mkLin
:: Arr.Array GHC.Types.Int
-> Base.Map (Arr.Array GHC.Types.Int) GHC.Types.Int
[LclIdX,
Arity=1,
Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=1, Value=True,
ConLike=True, WorkFree=True, Expandable=True,
Guidance=IF_ARGS [0] 100 0}]
Main.mkLin =
\ (mseqs_amy :: Arr.Array GHC.Types.Int) ->
case Base.lookup
@ (Arr.Array GHC.Types.Int)
@ (GHC.Prim.Any *)
(Arr.$fEqArray @ GHC.Types.Int)
mseqs_amy
(Base.empty @ (Arr.Array GHC.Types.Int) @ (GHC.Prim.Any *))
of _ { __DEFAULT ->
BuggyOpt.$sinsert
@ GHC.Types.Int
mseqs_amy
(GHC.Types.I# 1)
(Base.empty @ (Arr.Array GHC.Types.Int) @ GHC.Types.Int)
}
}}}
Does it look suspicious?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8425#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list