#3552: Unreachable code in optimised CMM code
---------------------------------+------------------------------------------
    Reporter:  simonpj           |        Owner:                  
        Type:  bug               |       Status:  new             
    Priority:  normal            |    Milestone:  6.14 branch     
   Component:  Compiler          |      Version:  6.10.4          
    Severity:  normal            |   Resolution:                  
    Keywords:                    |   Difficulty:  Unknown         
    Testcase:                    |           Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |  
---------------------------------+------------------------------------------
Comment (by simonmar):

 These unreachable blocks are left behind by the flattener,
 `CgMonad.flattenCgStmts`.  Here's the comment:

 {{{
   -- A label at the end of a function or fork: this label must not be
 reachable,
   -- but it might be referred to from another BB that also isn't
 reachable.
   -- Eliminating these has to be done with a dead-code analysis.  For now,
   -- we just make it into a well-formed block by adding a recursive jump.
   flatten [CgLabel id]
     = ( [CmmBranch id], [BasicBlock id [CmmBranch id]] )
 }}}

 I think it happens when you write something like

 {{{
 if (e) { ... } else { ... }
 }}}

 at the end of a C-- procedure, the code generation for this looks like
 (`CmmParse.ifThenElse`):

 {{{
 ifThenElse cond then_part else_part = do
      then_id <- code newLabelC
      join_id <- code newLabelC
      c <- cond
      emitCond c then_id
      else_part
      stmtEC (CmmBranch join_id)
      code (labelC then_id)
      then_part
      -- fall through to join
      code (labelC join_id)
 }}}

 So it leaves a join-point label at the end; it doesn't know whether the
 join point is reachable or not.  Can this ticket be closed, or should we
 wait until the symptom that Ben described is also fixed?

 All this is different in the new code generator, I imagine...

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3552#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to