[GHC] #14989: "Each block should be reachable from only one ProcPoint" compiling `integer` with `-fllvm`

#14989: "Each block should be reachable from only one ProcPoint" compiling `integer` with `-fllvm` -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Keywords: | Operating System: Windows Architecture: x86_64 | Type of failure: Compile-time (amd64) | crash or panic Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The attached file is from reduced from NoFib's `spectral/integer`. When I compile this with `-O2 -fllvm`, I get the following panic on HEAD: {{{ ghc-stage2.exe: panic! (the 'impossible' happened) (GHC version 8.5.20180329 for x86_64-unknown-mingw32): Each block should be reachable from only one ProcPoint }}} FWIW, I don't have the LLVM toolchain installed, but this is still in GHC's backend. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: "Each block should be reachable from only one ProcPoint" compiling `integer` with `-fllvm` -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by sgraf): * Attachment "Main.hs" added. Reproduction -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: "Each block should be reachable from only one ProcPoint" compiling `integer` with `-fllvm` -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by sgraf): I blame common block elimination. This is the output post sink assignments: {{{ ... c2m1: // global call (I64[R1])(R1) returns to c2m0, args: 8, res: 8, upd: 8; c2m0: // global switch [1 .. 2] (R1 & 7) { case 1 : goto u2mH; case 2 : goto c2m5; } ... c2mi: // global call (I64[R1])(R1) returns to c2mg, args: 8, res: 8, upd: 8; c2mg: // global switch [1 .. 2] (R1 & 7) { case 1 : goto u2mI; case 2 : goto c2mt; } ... c2mu: // global call (I64[R1])(R1) returns to c2mr, args: 8, res: 8, upd: 8; c2mr: // global switch [1 .. 2] (R1 & 7) { case 1 : goto c2mA; case 2 : goto u2mJ; } u2mJ: // global Sp = Sp + 8; goto c2mE; ... u2mI: // global Sp = Sp + 8; goto c2mE; u2mH: // global Sp = Sp + 8; goto c2mE; c2mE: // global call Main.$wfail_info() args: 8, res: 0, upd: 8; }}} And this is post common block elimination 2: {{{ ... c2m1: // global call (I64[R1])(R1) returns to c2m0, args: 8, res: 8, upd: 8; c2m0: // global switch [1 .. 2] (R1 & 7) { case 1 : goto u2mJ; case 2 : goto c2m5; } ... c2mi: // global call (I64[R1])(R1) returns to c2mg, args: 8, res: 8, upd: 8; c2mg: // global switch [1 .. 2] (R1 & 7) { case 1 : goto u2mJ; case 2 : goto c2mt; } ... c2mu: // global call (I64[R1])(R1) returns to c2mr, args: 8, res: 8, upd: 8; c2mr: // global switch [1 .. 2] (R1 & 7) { case 1 : goto c2mA; case 2 : goto u2mJ; } ... u2mJ: // global Sp = Sp + 8; goto c2mE; c2mE: // global call Main.$wfail_info() args: 8, res: 0, upd: 8; }}} The non-proc-point blocks u2m* have been merged into a single block u2MJ, which should have become a proc point in turn, because c2m{0,g,r} are multiple proc points (they are continuations) the block now "belongs" to. This is essentially diamond control flow introduced by the merging of blocks. {{{ c2m0 c2mg c2mr | | | u2mJ u2mI u2mH \ | / c2mE ===> c2m0 c2mg c2mr \ | / u2mJ | c2mE }}} In SSA world, this could entail inserting new Phi functions into the merged block, which corresponds to our notion of proc points, if I understand right. I find the parallels to SSA form very helpful. To stay in that analogy, c2mE was a proc point before common block elimination, but is no longer, because the dominance frontier of defs visible in c2m* changed from c2mE to u2mJ. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: "Each block should be reachable from only one ProcPoint" compiling `integer` with `-fllvm` -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by sgraf): * Attachment "Main.2.hs" added. Reproduction with only 2 branches instead of 3 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: "Each block should be reachable from only one ProcPoint" compiling `integer` with `-fllvm` -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by sgraf): This is probably the culprit: https://github.com/ghc/ghc/blob/ca535f95a742d885c4082c9dc296c151fb3c1e12/com... `cbe_fix` doesn't quite cut it because of the change in dominance frontiers outlined above. The most efficient solution would be to only consider the merged blocks and their successors. I just realized that the second CBE pass is new and also that stack layout happens before. Doesn't a change in proc points affect stack layout? I'd do the fix myself (inserting a proper call to `minimalProcPointSet`), but I feel like I don't understand enough of the interactions and where to conjure `new_proc_points` from after that. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: CBE pass 2 invalidates proc points -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: CBE pass 2 invalidates proc points -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: llvm Operating System: Windows | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ulysses4ever): * keywords: => llvm -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: CBE pass 2 invalidates proc points -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: llvm Operating System: Windows | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by sgraf): * cc: simonmar, michalt, bgamari (added) Comment: (Calling in a few people from https://phabricator.haskell.org/D4417 for advise) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: CBE pass 2 invalidates proc points -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: llvm Operating System: Windows | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: 12915 14226 | Differential Rev(s): Phab:D4417 Wiki Page: | -------------------------------------+------------------------------------- Changes (by sgraf): * differential: => Phab:D4417 * related: => 12915 14226 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: CBE pass 2 invalidates proc points -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: llvm Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: 12915 14226 | Differential Rev(s): Phab:D4417 Wiki Page: | -------------------------------------+------------------------------------- Changes (by sgraf): * os: Windows => Unknown/Multiple -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: CBE pass 2 invalidates proc points -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: llvm Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: 12915 14226 | Differential Rev(s): Phab:D4417 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonmar): Should we back out the D4417 until we can fix this, @michalt? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: CBE pass 2 invalidates proc points -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: llvm Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: 12915 14226 | Differential Rev(s): Phab:D4417 Wiki Page: | -------------------------------------+------------------------------------- Comment (by michalt): Sorry for a late reply! (vacation/travelling) @simonmar: Yes, let's do a rollback - then we can fix this properly without any rush. (I'll send something today) @sgraf: Thanks a lot for analysis! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: CBE pass 2 invalidates proc points
-------------------------------------+-------------------------------------
Reporter: sgraf | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.5
Resolution: | Keywords: llvm
Operating System: Unknown/Multiple | Architecture: x86_64
Type of failure: Compile-time | (amd64)
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: 12915 14226 | Differential Rev(s): Phab:D4417
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#14989: CBE pass 2 invalidates proc points -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: fixed | Keywords: llvm Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: 12915 14226 | Differential Rev(s): Phab:D4417 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed Comment: Rolled back. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14989: CBE pass 2 invalidates proc points -------------------------------------+------------------------------------- Reporter: sgraf | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: fixed | Keywords: llvm CodeGen Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: #12915 #14226 | Differential Rev(s): Phab:D4417 Wiki Page: | -------------------------------------+------------------------------------- Changes (by AndreasK): * keywords: llvm => llvm CodeGen * related: 12915 14226 => #12915 #14226 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14989#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC