Re: [GHC] #7498: panic : Register allocator: out of stack slots (need 147)
#7498: panic : Register allocator: out of stack slots (need 147) --+- Reporter: erikd| Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler |Version: 7.7 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: powerpc Failure: Building GHC failed | Difficulty: Unknown Testcase: | Blockedby: Blocking: |Related: --+- Comment(by marlowsd@…): commit 03d360f289a1c7e93fedf8cfa274cbe5929cd32c {{{ Author: Simon Marlow marlo...@gmail.com Date: Mon Jan 7 12:26:29 2013 + Fix bugs in allocMoreStack (#7498, #7510) There were four bugs here. Clearly I didn't test this enough to expose the bugs - it appeared to work on x86/Linux, but completely by accident it seems. 1. the delta was wrong by a factor of the slot size (as noted on #7498) 2. we weren't correctly aligning the stack pointer (sp needs to be 16-byte aligned on x86/x86_64) 3. we were doing the adjustment multiple times in the case of a block that was both a return point and a local branch target. To fix this I had to add new shim blocks to adjust the stack pointer, and retarget the original branches. See comment for details. 4. we were doing the adjustment for CALL instructions, which is unnecessary and wrong; only JMPs should be preceded by a stack adjustment. (Someone with a PPC box will need to update the PPC version of allocMoreStack to fix the above bugs, using the x86 version as a guide.) compiler/nativeGen/AsmCodeGen.lhs | 10 ++-- compiler/nativeGen/PPC/Instr.hs |7 +- compiler/nativeGen/X86/Instr.hs | 124 +++-- 3 files changed, 99 insertions(+), 42 deletions(-) }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7498#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #7498: panic : Register allocator: out of stack slots (need 147)
#7498: panic : Register allocator: out of stack slots (need 147) --+- Reporter: erikd| Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler |Version: 7.7 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: powerpc Failure: Building GHC failed | Difficulty: Unknown Testcase: | Blockedby: Blocking: |Related: --+- Comment(by igloo): Same as #7510? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7498#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #7498: panic : Register allocator: out of stack slots (need 147)
#7498: panic : Register allocator: out of stack slots (need 147) --+- Reporter: erikd| Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler |Version: 7.7 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: powerpc Failure: Building GHC failed | Difficulty: Unknown Testcase: | Blockedby: Blocking: |Related: --+- Comment(by erikd): @Igloo I do think this is the same thing. I currently can't reproduce it with my version or @pho's version of the PPC stack resizing code, but @pho's explanation does seem plausible. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7498#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #7498: panic : Register allocator: out of stack slots (need 147)
#7498: panic : Register allocator: out of stack slots (need 147) --+- Reporter: erikd| Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler |Version: 7.7 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: powerpc Failure: Building GHC failed | Difficulty: Unknown Testcase: | Blockedby: Blocking: |Related: --+- Changes (by PHO): * owner: erikd = * resolution: fixed = * status: closed = new * os: Linux = Unknown/Multiple Comment: In HEAD the stage-2 compiler segfaults at `StgReturn` because of the stack pointer `r1` pointing to an invalid address during the compilation of `libraries/old-time/dist-install/build/System/Time.p_o`. I found `PPC.Instr.insertBeforeNonlocalTransfers` (possibly mistakenly) inserts `dealloc` before every jumpish instruction including local jumps so I modified it as follows, but my fix didn't work: {{{ insertBeforeNonlocalTransfers :: Instr - [Instr] - [Instr] insertBeforeNonlocalTransfers insert insns = foldr p [] insns where -- BCTR might or might not be a non-local jump. For -- labeled-goto we use JMP, and for computed-goto we use -- MTCTR followed by BCTR. See 'PPC.CodeGen.genJump'. p insn r = case insn of JMP _ - insert : insn : r BCTR [] Nothing - insert : insn : r _ - insn : r -- BL and BCTRL are call-like instructions rather than jumps, -- and are used only for C calls. }}} The real cause is not in the PPC specific code, but in the current algorithm (shared with X86) for `allocMoreStack` collapsing at local branches or fall-through to join points. Suppose we have two blocks `L0` and `L1`, where `L0` is the proc entry point and `L1` is a join point: {{{ L0: ... if (...) { call something() returning to L1; } L1: ... return; }}} `allocMoreStack` modifies the code as follows, which leaves the stack pointer at a wrong position when the condition does not hold: {{{ L0: move_sp_down; ... if (...) { move_sp_up; call something() returning to L1; } L1: move_sp_down; ... move_sp_up; return; }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7498#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #7498: panic : Register allocator: out of stack slots (need 147)
#7498: panic : Register allocator: out of stack slots (need 147) --+- Reporter: erikd| Owner: erikd Type: bug | Status: closed Priority: high | Milestone: 7.8.1 Component: Compiler |Version: 7.7 Resolution: fixed| Keywords: Os: Linux| Architecture: powerpc Failure: Building GHC failed | Difficulty: Unknown Testcase: | Blockedby: Blocking: |Related: --+- Changes (by PHO): * cc: pho@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7498#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #7498: panic : Register allocator: out of stack slots (need 147)
#7498: panic : Register allocator: out of stack slots (need 147) --+- Reporter: erikd| Owner: erikd Type: bug | Status: closed Priority: high | Milestone: 7.8.1 Component: Compiler |Version: 7.7 Resolution: fixed| Keywords: Os: Linux| Architecture: powerpc Failure: Building GHC failed | Difficulty: Unknown Testcase: | Blockedby: Blocking: |Related: --+- Changes (by simonmar): * status: new = closed * resolution: = fixed Comment: @erikd: I think I've now given you permission to close tickets on Trac. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7498#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #7498: panic : Register allocator: out of stack slots (need 147)
#7498: panic : Register allocator: out of stack slots (need 147) -+-- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler | Version: 7.7 Keywords:| Os: Linux Architecture: powerpc | Failure: Building GHC failed Difficulty: Unknown |Testcase: Blockedby:|Blocking: Related:| -+-- Comment(by erikd@…): commit 51d364530895e2f18fa8b98a12bf5a44f1b004d1 {{{ Author: Erik de Castro Lopo er...@mega-nerd.com Date: Sun Dec 16 04:40:54 2012 +1100 PPC: Implement stack resizing for the linear register allocator. Fixes #7498. compiler/nativeGen/AsmCodeGen.lhs |2 +- compiler/nativeGen/PPC/Instr.hs | 72 +--- 2 files changed, 59 insertions(+), 15 deletions(-) }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7498#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #7498: panic : Register allocator: out of stack slots (need 147)
#7498: panic : Register allocator: out of stack slots (need 147) -+-- Reporter: erikd | Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler | Version: 7.7 Keywords:| Os: Linux Architecture: powerpc | Failure: Building GHC failed Difficulty: Unknown |Testcase: Blockedby:|Blocking: Related:| -+-- Changes (by simonmar): * priority: normal = high * difficulty: = Unknown * milestone: = 7.8.1 Comment: Someone needs to implement this: 0b0a41f96cbdaf52aac171c9c58459e3187b0f46 for PowerPC. It's not hard, just crib from the x86 example. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7498#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #7498: panic : Register allocator: out of stack slots (need 147)
#7498: panic : Register allocator: out of stack slots (need 147) -+-- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Compiler | Version: 7.7 Keywords:| Os: Linux Architecture: powerpc | Failure: Building GHC failed Difficulty: Unknown |Testcase: Blockedby:|Blocking: Related:| -+-- Changes (by erikd): * owner: = erikd -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7498#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs