[GHC] #11444: 8.0 rc1 panics in applyTypeToArgs

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1-rc1 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: -------------------------------------+------------------------------------- To reproduce, clone https://github.com/rrnewton/haskell-lockfree and switch to ghc-8.0 branch. Then run {{{cabal install atomic-primops/}}} (note the trailing slash, we don't want to install it from Hackage). It should fail with a message like this: {{{ ➜ haskell-lockfree git:(ghc-8.0) ✗ cabal install atomic-primops/ Warning: The package list for 'hackage.haskell.org' is 25.1 days old. Run 'cabal update' to get the latest list of available packages. Resolving dependencies... Notice: installing into a sandbox located at /home/omer/haskell/haskell-lockfree/.cabal-sandbox Configuring primitive-0.6.1.0... Building primitive-0.6.1.0... Warning: /tmp/pkgConf-primitive-0.6.110252023621350490027.0: Unrecognized field abi on line 21 Installed primitive-0.6.1.0 Configuring atomic-primops-0.8.0.2... Building atomic-primops-0.8.0.2... Failed to install atomic-primops-0.8.0.2 Build log ( /home/omer/haskell/haskell-lockfree/.cabal-sandbox/logs /atomic-primops-0.8.0.2.log ): [1 of 1] Compiling Main ( atomic-primops/dist/dist-sandbox- ad71ba7e/setup/setup.hs, atomic-primops/dist/dist-sandbox- ad71ba7e/setup/Main.o ) Linking atomic-primops/dist/dist-sandbox-ad71ba7e/setup/setup ... Configuring atomic-primops-0.8.0.2... Building atomic-primops-0.8.0.2... Preprocessing library atomic-primops-0.8.0.2... [1 of 3] Compiling Data.Atomics.Internal ( Data/Atomics/Internal.hs, dist /dist-sandbox-ad71ba7e/build/Data/Atomics/Internal.o ) Data/Atomics/Internal.hs:69:20: warning: Defined but not used: data constructor ‘Ticket’ [2 of 3] Compiling Data.Atomics.Counter ( Data/Atomics/Counter.hs, dist /dist-sandbox-ad71ba7e/build/Data/Atomics/Counter.o ) [3 of 3] Compiling Data.Atomics ( Data/Atomics.hs, dist/dist-sandbox- ad71ba7e/build/Data/Atomics.o ) ghc: panic! (the 'impossible' happened) (GHC version 8.0.0.20160111 for x86_64-unknown-linux): applyTypeToArgs Expression: readMutVar# eta_s4sC st_s4sD Type: forall d_15 a_12. MutVar# d_15 a_12 -> State# d_15 -> (# State# d_15, a_12 #) Args: [eta_s4sC, st_s4sD] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug cabal: Error: some packages failed to install: atomic-primops-0.8.0.2 failed during the building phase. The exception was: ExitFailure 1 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 osa1): So it seems like {{{readMutVar#}}} now has two extra arguments, I'm guessing this is related with levity args? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 osa1): Also reproduced with 8.1.20160116. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 osa1): I think I found the problem. I'll keep debugging this tomorrow.. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#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): But how does this lead to the `applyTypeToArgs` panic? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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, any thoughts about comment:5? On comment:2 * Assume for now that `reallyUnsafePtrEquality# @ a_a1Ts x_X1wq y_X1ws` is ''not'' ok-for-speculation. Then the transformation you show above should not happen. Look at this code in `Simplify`: {{{ -- 2b. Turn the case into a let, if -- a) it binds only the case-binder -- b) unlifted case: the scrutinee is ok-for-speculation -- lifted case: the scrutinee is in HNF (or will later be demanded) | all_dead_bndrs , if is_unlifted then exprOkForSpeculation scrut -- See Note [Case elimination: unlifted case] else exprIsHNF scrut -- See Note [Case elimination: lifted case] || scrut_is_demanded_var scrut = do { tick (CaseElim case_bndr) ; env' <- simplNonRecX env case_bndr scrut ; simplExprF env' rhs cont } }}} We are in the unlifted case, and `exprOkForSpeculation` is false, so this case should not fire. But I think it is firing. Why? Can you check that this really is happening (e.g. there is a `CaseElim` on this case binder)? And figure out why? Can you make a small test case so I can see? Separately, it's true that `exprOkForSpeculation` is being conservative; see this comment in `CoreUtils.app_ok` {{{ | otherwise -> primop_ok op -- A bit conservative: we don't really need && all (expr_ok primop_ok) args -- to care about lazy arguments, but this is easy }}} Let me know if you need more help. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: RyanGlScott (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 RyanGlScott): Two things: 1. osa1, I can't seem to reproduce the error you originally reported in this ticket on GHC 8.0.1, 8.0.2, or HEAD. 2. On GHC HEAD, I noticed that the package fails to build with `-dcore- lint` on: {{{ *** Core Lint errors : in result of Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = False}) *** <no location info>: warning: In the expression: I# (reallyUnsafePtrEquality# @ a x_a1B9 y_a1Ba) This argument does not satisfy the let/app invariant: reallyUnsafePtrEquality# @ a x_a1B9 y_a1Ba *** Offending Program *** ... ptrEq [InlPrag=NOINLINE] :: forall a. a -> a -> Bool [LclIdX, Arity=2] ptrEq = \ (@ a_a1Dh) (x_a1B9 :: a) (y_a1Ba :: a) -> case x_a1B9 of x_X1Bi { __DEFAULT -> case y_a1Ba of y_X1Bk { __DEFAULT -> eqInt (I# (reallyUnsafePtrEquality# @ a x_a1B9 y_a1Ba)) lvl_s1QL } } }}} Possibly related to #13027? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 RyanGlScott): To be precise, here's the portion of `atomic-primops` that fails with a Core Lint error: {{{#!hs {-# LANGUAGE BangPatterns #-} {-# LANGUAGE MagicHash #-} module AtomicPrimops where import GHC.Exts {-# NOINLINE ptrEq #-} ptrEq :: a -> a -> Bool ptrEq !x !y = I# (reallyUnsafePtrEquality# x y) == 1 }}} {{{ $ ~/Software/ghc3/inplace/bin/ghc-stage2 -fforce-recomp -dcore-lint -O2 Bug.hs[1 of 1] Compiling AtomicPrimops ( Bug.hs, Bug.o ) *** Core Lint errors : in result of Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = False}) *** <no location info>: warning: In the expression: I# (reallyUnsafePtrEquality# @ a x_a2OY y_a2OZ) This argument does not satisfy the let/app invariant: reallyUnsafePtrEquality# @ a x_a2OY y_a2OZ *** Offending Program *** lvl_s3TE :: Int [LclId] lvl_s3TE = I# 1# ptrEq [InlPrag=NOINLINE] :: forall a. a -> a -> Bool [LclIdX, Arity=2] ptrEq = \ (@ a_a3I6) (x_a2OY :: a) (y_a2OZ :: a) -> case x_a2OY of x_X2P2 { __DEFAULT -> case y_a2OZ of y_X2P4 { __DEFAULT -> eqInt (I# (reallyUnsafePtrEquality# @ a x_a2OY y_a2OZ)) lvl_s3TE } } $trModule_s3TA :: TrName [LclId] $trModule_s3TA = TrNameS "main"# $trModule_s3TB :: TrName [LclId] $trModule_s3TB = TrNameS "AtomicPrimops"# $trModule :: Module [LclIdX] $trModule = Module $trModule_s3TA $trModule_s3TB *** End of Offense *** <no location info>: error: Compilation had errors }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 dfeuer): Replying to [comment:6 simonpj]:
Can you make a small test case so I can see?
Based on your investigation, I've constructed a small test case: {{{#!hs {-# LANGUAGE MagicHash, BangPatterns #-} module PtrEqTest where import GHC.Exts (reallyUnsafePtrEquality#, Int (..)) ptrEq :: a -> a -> Bool ptrEq !x !y = I# (reallyUnsafePtrEquality# x y) == 1 }}} This produces the following error: {{{ *** Core Lint errors : in result of Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = False}) *** <no location info>: warning: In the expression: I# (reallyUnsafePtrEquality# @ a x_a2Pv y_a2Pw) This argument does not satisfy the let/app invariant: reallyUnsafePtrEquality# @ a x_a2Pv y_a2Pw *** Offending Program *** lvl_s3Ub :: Int [LclId] lvl_s3Ub = I# 1# ptrEq :: forall a. a -> a -> Bool [LclIdX, Arity=2] ptrEq = \ (@ a_a3ID) (x_a2Pv :: a) (y_a2Pw :: a) -> case x_a2Pv of x_X2Pz { __DEFAULT -> case y_a2Pw of y_X2PB { __DEFAULT -> eqInt (I# (reallyUnsafePtrEquality# @ a x_a2Pv y_a2Pw)) lvl_s3Ub } } $trModule_s3U7 :: TrName [LclId] $trModule_s3U7 = TrNameS "main"# $trModule_s3U8 :: TrName [LclId] $trModule_s3U8 = TrNameS "PtrEqTest"# $trModule :: Module [LclIdX] $trModule = Module $trModule_s3U7 $trModule_s3U8 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 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: #13027 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * related: => #13027 * milestone: => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 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: #13027 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Aha! This is closely linked to #13027; read esp comment:23 on that ticket. In that comment I quote this Note from `CoreUtils` {{{ Note [dataToTag speculation] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Is this OK? f x = let v::Int# = dataToTag# x in ... We say "yes", even though 'x' may not be evaluated. Reasons * dataToTag#'s strictness means that its argument often will be evaluated, but FloatOut makes that temporarily untrue case x of y -> let v = dataToTag# y in ... --> case x of y -> let v = dataToTag# x in ... Note that we look at 'x' instead of 'y' (this is to improve floating in FloatOut). So Lint complains. Moreover, it really *might* improve floating to let the v-binding float out }}} The remark about `FloatOut` is ''exactly'' what is happening here. So if we follow the "alternative path" described in comment:23, that'll fix this ticket too. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 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: #13027 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): The substitution of `x` for `y` in the note you mention above sounds rather wrong for pointer equality. In particular, we probably never want a pointer equality test to float out of a case on one of its arguments. Floating one *in* should be fine. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 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: #13027 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Sorry; that last comment was unclear. If we have {{{#!hs case x of x' { _ -> case y of y' { _ -> case reallyUnsafePtrEquality# x' y' of {....}}} }}} and we substitute as above, {{{#!hs case x of x' { _ -> case y of y' { _ -> case reallyUnsafePtrEquality# x y of {....}}} }}} then wouldn't floating out lead to this? {{{#!hs let wrong = reallyUnsafePtrEquality# x y in { case x of x' { _ -> case y of y' { _ -> case wrong of { ... }}}} }}} Now the pointer equality test could be performed ''before'' the reductions that would make it much more precise! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 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: #13027 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
In particular, we probably never want a pointer equality test to float out of a case on one of `reallyUnsafePtrEq`'s arguments.
OK. Fix that in `primops.txt.pp` by giving `reallyUnsafePtrEq` a `can_fail` attribute. That sounds a bit odd, but read `Note [dataToTag#]` in `primops.txt.pp`, and `Note [PrimOp can_fail and has_side_effects]` in `PrimOp.h`, and expecially `Note [Transformations affected by can_fail and has_side_effects]` in `PrimOp.hs`. Would you like to do that? Add a Note obviously with your example above. Maybe make a new ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 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: #13027 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): That looks like overkill, strictly speaking, but I could definitely believe that it doesn't matter. It looks like overkill because if we have {{{#!hs foo !x !y = case x of Con1 p -> let rup1 = reallyUnsafePtrEquality# x y in ... Con2 p -> let rup2 = reallyUnsafePtrEquality# x y in ... }}} then we can safely float out just a drop: {{{#!hs foo !x !y = let rup1 = reallyUnsafePtrEquality# x y rup2 = reallyUnsafePtrEquality# x y in case x of Con1 p -> ... Con2 p -> ... }}} and then CSE the duplication out. What I don't know is if such a thing will ever occur (or matter) in practice, or whether it would be a good idea even if it did. I can certainly make the change and add some notes. There are some interactions with some discussion in #13027. At present, anyway, `reallyUnsafePtrEquality#` is only considered "safe for speculation" when its arguments are known to be forced, which sounded really weird before, but isn't that precisely when it should be safe to float it out? OTOH, this ticket reveals another issue relating to polymorphic arguments, so maybe we should make the conservative change? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 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: #13027 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Agh, I just saw that my test case was almost a word-for-word copy of Ryan's. I'll leave it in place to preserve history. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 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: #13027 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Let's move this discussion about primops to #13027, which has more relevant discussion. I'll add a test for comment:10, which is indeed fixed by the patch in #13027. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs
-------------------------------------+-------------------------------------
Reporter: osa1 | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.2.1
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: #13027 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11444: 8.0 rc1 panics in applyTypeToArgs -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1-rc1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11444 Blocked By: | Blocking: Related Tickets: #13027 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => simplCore/should_compile/T11444 * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11444#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11444: 8.0 rc1 panics in applyTypeToArgs
-------------------------------------+-------------------------------------
Reporter: osa1 | Owner:
Type: bug | Status: closed
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 8.0.1-rc1
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| simplCore/should_compile/T11444
Blocked By: | Blocking:
Related Tickets: #13027 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by David Feuer
participants (1)
-
GHC