[GHC] #7574: Register allocator chokes on certain branches with literals

#7574: Register allocator chokes on certain branches with literals -----------------------------+---------------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.1 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: 7571, 7573 -----------------------------+---------------------------------------------- While running the test for #7571 (test is in #7573,) under '''WAY=normal''' instead of '''WAY=llvm''', I encountered this bug in the native backend: {{{ =====> T7571(normal) 6 of 6 [0, 0, 0] cd . && '/Users/a/code/haskell/ghc/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history -c T7571.cmm -no-hs-main >T7571.comp.stderr 2>&1 Compile failed (status 256) errors were: ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20130113 for x86_64-apple-darwin): allocateRegsAndSpill: Cannot read from uninitialized register %vI_c7 }}} The test in question is: {{{ #include "Cmm.h" testLiteralBranch (W_ dst, W_ src) { if (1) { prim %memcpy(dst, src, 1024, 4); } else { prim %memcpy(dst, src, 512, 8); } return (); } }}} If you comment out the branch conditionals, the test passes, so clearly something fishy is going on here. The test also fails if you change the condition to ```if (1 == 1)``` I have absolutely no idea how this did not trip the profiling-based build in StgStdThunks.cmm, like in the LLVM build c.f. #7571 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals -----------------------------+---------------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.1 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: #7571, #7573 -----------------------------+---------------------------------------------- Changes (by thoughtpolice): * related: 7571, 7573 => #7571, #7573 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals -----------------------------+---------------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.1 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: #7571 -----------------------------+---------------------------------------------- Changes (by thoughtpolice): * related: #7571, #7573 => #7571 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals -------------------------------+-------------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Component: Compiler (NCG) Version: 7.7 | Keywords: ncg, codegen Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: #7571 -------------------------------+-------------------------------------------- Changes (by thoughtpolice): * keywords: => ncg, codegen * failure: None/Unknown => Compile-time crash * version: 7.6.1 => 7.7 * component: Compiler => Compiler (NCG) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals -------------------------------+-------------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Component: Compiler (NCG) Version: 7.7 | Keywords: ncg, codegen Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: 7573 Blocking: | Related: #7571 -------------------------------+-------------------------------------------- Changes (by thoughtpolice): * blockedby: => 7573 Comment: If we want to make a test for this like #7571 (or just reuse it,) we'll need the patch in #7573 too. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571 | ---------------------------------+------------------------------------------ Changes (by simonmar): * difficulty: => Unknown Comment: The problem here is that the else-block becomes unreachable after `cmmStmtConFold` optimises away the conditional, and the register allocator doesn't like unreachable code. The right fix is to discard unreachable code before register allocation. It already does a strongly-connected-component analysis so this shouldn't be too hard, but IIRC when I tried to do this before it wasn't straightforward because `Digraph` doesn't expose the right bits. We need an SCC pass that starts from a particular node, not the entire set of nodes. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Changes (by simonmar): * related: #7571 => #7571,#7534 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Changes (by PHO): * cc: pho@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Changes (by erikd): * cc: mle+hs@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Changes (by Feuerbach): * cc: roma@… (added) Comment: This bug also affects the "statistics" library. To reproduce, try to install statistics-0.10.2.0 from hackage with profiling enabled using GHC HEAD. It fails with a similar message {{{ [ 4 of 39] Compiling Statistics.Transform ( Statistics/Transform.hs, dist/build/Statistics/Transform.p_o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20130407 for i386-unknown-linux): allocateRegsAndSpill: Cannot read from uninitialized register %vI_cdUj }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Old description:
While running the test for #7571 (test is in #7573,) under '''WAY=normal''' instead of '''WAY=llvm''', I encountered this bug in the native backend:
{{{
=====> T7571(normal) 6 of 6 [0, 0, 0] cd . && '/Users/a/code/haskell/ghc/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history -c T7571.cmm -no-hs-main >T7571.comp.stderr 2>&1 Compile failed (status 256) errors were: ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20130113 for x86_64-apple-darwin): allocateRegsAndSpill: Cannot read from uninitialized register %vI_c7
}}}
The test in question is:
{{{
#include "Cmm.h"
testLiteralBranch (W_ dst, W_ src) { if (1) { prim %memcpy(dst, src, 1024, 4); } else { prim %memcpy(dst, src, 512, 8); } return (); }
}}}
If you comment out the branch conditionals, the test passes, so clearly something fishy is going on here. The test also fails if you change the condition to ```if (1 == 1)```
I have absolutely no idea how this did not trip the profiling-based build in StgStdThunks.cmm, like in the LLVM build c.f. #7571
New description: {{{ }}} While running the test for #7571 (test is in #7573,) under '''WAY=normal''' instead of '''WAY=llvm''', I encountered this bug in the native backend: {{{ =====> T7571(normal) 6 of 6 [0, 0, 0] cd . && '/Users/a/code/haskell/ghc/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history -c T7571.cmm -no-hs-main >T7571.comp.stderr 2>&1 Compile failed (status 256) errors were: ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20130113 for x86_64-apple-darwin): allocateRegsAndSpill: Cannot read from uninitialized register %vI_c7 }}} The test in question is: {{{ #include "Cmm.h" testLiteralBranch (W_ dst, W_ src) { if (1) { prim %memcpy(dst, src, 1024, 4); } else { prim %memcpy(dst, src, 512, 8); } return (); } }}} If you comment out the branch conditionals, the test passes, so clearly something fishy is going on here. The test also fails if you change the condition to ```if (1 == 1)``` I have absolutely no idea how this did not trip the profiling-based build in StgStdThunks.cmm, like in the LLVM build c.f. #7571 -- Comment(by simonpj): So this ticket is looking more important than it was before! Would anyone like to look at it? Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Changes (by simonpj): * milestone: => 7.8.1 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Description changed by igloo: Old description:
{{{
}}} While running the test for #7571 (test is in #7573,) under '''WAY=normal''' instead of '''WAY=llvm''', I encountered this bug in the native backend:
{{{
=====> T7571(normal) 6 of 6 [0, 0, 0] cd . && '/Users/a/code/haskell/ghc/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history -c T7571.cmm -no-hs-main >T7571.comp.stderr 2>&1 Compile failed (status 256) errors were: ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20130113 for x86_64-apple-darwin): allocateRegsAndSpill: Cannot read from uninitialized register %vI_c7
}}}
The test in question is:
{{{
#include "Cmm.h"
testLiteralBranch (W_ dst, W_ src) { if (1) { prim %memcpy(dst, src, 1024, 4); } else { prim %memcpy(dst, src, 512, 8); } return (); }
}}}
If you comment out the branch conditionals, the test passes, so clearly something fishy is going on here. The test also fails if you change the condition to ```if (1 == 1)```
I have absolutely no idea how this did not trip the profiling-based build in StgStdThunks.cmm, like in the LLVM build c.f. #7571
New description: While running the test for #7571 (test is in #7573,) under '''WAY=normal''' instead of '''WAY=llvm''', I encountered this bug in the native backend: {{{ =====> T7571(normal) 6 of 6 [0, 0, 0] cd . && '/Users/a/code/haskell/ghc/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history -c T7571.cmm -no-hs-main >T7571.comp.stderr 2>&1 Compile failed (status 256) errors were: ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20130113 for x86_64-apple-darwin): allocateRegsAndSpill: Cannot read from uninitialized register %vI_c7 }}} The test in question is: {{{ #include "Cmm.h" testLiteralBranch (W_ dst, W_ src) { if (1) { prim %memcpy(dst, src, 1024, 4); } else { prim %memcpy(dst, src, 512, 8); } return (); } }}} If you comment out the branch conditionals, the test passes, so clearly something fishy is going on here. The test also fails if you change the condition to ```if (1 == 1)``` I have absolutely no idea how this did not trip the profiling-based build in StgStdThunks.cmm, like in the LLVM build c.f. #7571 -- -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Changes (by igloo): * priority: normal => high -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: thoughtpolice Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Changes (by thoughtpolice): * owner: => thoughtpolice Comment: I'm going to go ahead and assign this to myself since I'm looking at it today. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: thoughtpolice Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Changes (by jstolarek): * cc: jan.stolarek@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: thoughtpolice Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Comment(by simonmar): @thoughtpolice - I presume you got stalled? I looked into this myself and somehow couldn't get my fix to work properly, the NCG was throwing away code that it shouldn't have been. I shall try again when I get some time, but it definitely needs fixing before 7.8.1. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7574: Register allocator chokes on certain branches with literals ---------------------------------+------------------------------------------ Reporter: thoughtpolice | Owner: thoughtpolice Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler (NCG) | Version: 7.7 Keywords: ncg, codegen | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: 7573 | Blocking: Related: #7571,#7534 | ---------------------------------+------------------------------------------ Comment(by thoughtpolice): Yes, I did get a bit stalled here unfortunately and worked on other things, and I merely haven't returned to it. I think I may still have part of a lingering patch sitting around, I can try to look again soon. (Also, perhaps we should bump this to highest priority for 7.8.1.) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7574#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (2)
-
GHC
-
GHC