[GHC] #11444: 8.0 rc1 panics in applyTypeToArgs
GHC
ghc-devs at haskell.org
Tue Jan 19 23:15:13 UTC 2016
#11444: 8.0 rc1 panics in applyTypeToArgs
-------------------------------------+-------------------------------------
Reporter: osa1 | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1-rc1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Omer writes: I found one of the problems with #11444, but I don't know how
to fix it. The
problem is that the desugarer is generating this function:
{{{
ptrEq [InlPrag=NOINLINE] :: forall a_a1wc. a_a1wc -> a_a1wc -> Bool
[LclIdX, Str=DmdType]
ptrEq =
\ (@ a_a1Ts) (x_a1we :: a_a1Ts) (y_a1wf :: a_a1Ts) ->
case x_a1we of x_X1wq { __DEFAULT ->
case y_a1wf of y_X1ws { __DEFAULT ->
==
@ Int
GHC.Classes.$fEqInt
(case reallyUnsafePtrEquality# @ a_a1Ts x_X1wq y_X1ws
of wild_00 { __DEFAULT ->
GHC.Types.I# wild_00
})
(GHC.Types.I# 1#)
}
}
}}}
Which is lint-safe. Then, the optimizer is transforming this into:
{{{
ptrEq [InlPrag=NOINLINE] :: forall a_a1wc. a_a1wc -> a_a1wc -> Bool
[LclIdX,
Arity=2,
Str=DmdType,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 20] 71
0}]
ptrEq =
\ (@ a_a1Ts) (x_a1we :: a_a1Ts) (y_a1wf :: a_a1Ts) ->
case x_a1we of x_X1wq { __DEFAULT ->
case y_a1wf of y_X1ws { __DEFAULT ->
eqInt
(I# (reallyUnsafePtrEquality# @ a_a1Ts x_X1wq y_X1ws)) (I# 1#)
}
}
}}}
The problem with this, according to the linter, is the argument of I# is
not
OK-for-speculation (the expression `reallyUnsafePtrEquality# @ a_a1Ts
x_X1wq y_X1ws`). The reason is because arguments of
`reallyUnsafePtrEquality#` are not
OK-for-speculation, because their types are polymorphic, and variables
with
polymorphic types are not OK for speculation.
However, I think this expression should be OK-for-speculation, because it
can't
fail, the primop is not out-of-line etc. I think all the requirements for
being
OK for speculation hold here.
So my questions are:
- Does that look like a correct optimization transformation? (it looked OK
to
me, but wanted to make sure)
- Am I right that this expression should be OK for speculation?
- What's a good way to make this code lint-safe?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11444#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list