#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

Reply via email to