[GHC] #13170: Core Lint error on git HEAD
#13170: Core Lint error on git HEAD -------------------------------------+------------------------------------- Reporter: dobenour | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.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: -------------------------------------+------------------------------------- GHC HEAD hits a Core Lint error on this simple module: {{{#!hs module Fold where f :: Int -> Bool f x = y == 2 || y == 3 where y = -x }}} when compiling with `-O -dcore-lint`. This causes the Harbormaster build to fail on ia32. This doesn't effect 8.0.2. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13170> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13170: Core Lint error on git HEAD -------------------------------------+------------------------------------- Reporter: dobenour | Owner: rwbarton Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.1 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 rwbarton): * owner: => rwbarton Comment: It seems to be caused by https://phabricator.haskell.org/D2762 not reordering the mapped cases. Investigating. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13170#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13170: Core Lint error on git HEAD -------------------------------------+------------------------------------- Reporter: dobenour | Owner: rwbarton Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.1 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 rwbarton): For the record, the core lint failure looks like {{{ *** Core Lint errors : in result of Simplifier *** <no location info>: warning: In a case alternative: (I# x_a1Nt :: Int#) Case expression with badly-ordered alternatives case x_a1Nt of wild_Xq { __DEFAULT -> let { wild_Xq :: Int# [LclId, Unf=OtherCon []] wild_Xq = negateInt# x_a1Nt } in False; -2# -> let { wild_Xq :: Int# [LclId, Unf=OtherCon []] wild_Xq = 2# } in True; -3# -> let { wild_Xq :: Int# [LclId, Unf=OtherCon []] wild_Xq = 3# } in True } }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13170#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13170: Core Lint error on git HEAD -------------------------------------+------------------------------------- Reporter: dobenour | Owner: rwbarton Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T13170 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3008 Wiki Page: | -------------------------------------+------------------------------------- Changes (by rwbarton): * testcase: => simplCore/should_compile/T13170 * differential: => Phab:D3008 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13170#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13170: Core Lint error on git HEAD -------------------------------------+------------------------------------- Reporter: dobenour | Owner: rwbarton Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T13170 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3008 Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): Incidentally, the failure in {{{#!hs isSigIntQuit n = sig == sigINT || sig == sigQUIT where sig = fromIntegral (-n) }}} only showed up on a 32-bit system because `sig :: CInt` is 32 bits, and so on a 64-bit system there is also a `GHC.Prim.narrow32Int#` in the case scrutinee (from the implementation of `negate` for `CInt`). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13170#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13170: Core Lint error on git HEAD -------------------------------------+------------------------------------- Reporter: dobenour | Owner: rwbarton Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T13170 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3008 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
It seems to be caused by https://phabricator.haskell.org/D2762 not reordering the mapped cases
That looks absolutely right. You need to re-sort the alternatives to ensure thay are still in ascending order. See `CoreSyn` ``` -- 3. The remaining cases are in order of increasing -- tag (for 'DataAlts') or -- lit (for 'LitAlts'). -- This makes finding the relevant constructor easy, -- and makes comparison easier too. ``` Well spotted. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13170#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13170: Core Lint error on git HEAD -------------------------------------+------------------------------------- Reporter: dobenour | Owner: rwbarton Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T13170 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3008 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"abaa6815e6435ed29ad121b5e59fc017a1d3e836/ghc" abaa6815/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="abaa6815e6435ed29ad121b5e59fc017a1d3e836" Re-sort case alternatives after scrutinee constant folding (#13170) Commit d3b546b1a605 added a "scrutinee constant folding" pass that rewrites a case expression whose scrutinee is an expression like x +# 3#. But case expressions are supposed to have their alternatives in sorted order, so when the scrutinee is (for example) negateInt# x#, we need to re-sort the alternatives after mapping their values. This showed up as a core lint failure when compiling System.Process.Posix: isSigIntQuit n = sig == sigINT || sig == sigQUIT where sig = fromIntegral (-n) Data.List.sortBy is supposed to be linear-time on sorted or reverse-sorted input, so it is probably not worth doing anything more clever than this. Test Plan: Added a new test T13170 for the above case. Reviewers: austin, hsyl20, simonpj, bgamari Reviewed By: hsyl20, simonpj, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3008 GHC Trac Issues: #13170 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13170#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13170: Core Lint error on git HEAD -------------------------------------+------------------------------------- Reporter: dobenour | Owner: rwbarton Type: bug | Status: closed Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T13170 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3008 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13170#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC