simonpj     2003/06/23 04:46:41 PDT

  Modified files:
    ghc/compiler/stranal DmdAnal.lhs 
  Log:
        ------------------------------------------------------
        Make the strictness analyser more conservative for I/O
        ------------------------------------------------------
  
  Consider
        do { let len = <expensive> ;
           ; when (...) (exitWith ExitSuccess)
           ; print len }
  
  Is it safe to evaluate <expensive> before doing the 'when'?  Remember,
  <expensive> might raise an exception etc as well.
  
  Normal strictness analysis answer: yes, because either the when... diverges
  or raises an exception, or the print will happen.
  
  Correct I/O answer: no, because it's perfectly OK to terminate the program
  successfully.  And don't say the 'len' could be pushed down, because (a) sometimes
  it can't and (b) sometimes the compiler might float it out.
  
  This commit adds a hack to the demand analyser, so that it treats a case that
  looks like I/O (unboxed pair, real-world as first bindre) specially, by lub'ing
  the returned strictness type with TopType.  A bit like adding a dummy never-taken
  branch.  This seems a bit hack-oid, but it's quick and it works.  Not clear
  how to do it 'right', either.
  
  Test is in stranal/should_run/strun003.
  
  Revision  Changes    Path
  1.47      +27 -3     fptools/ghc/compiler/stranal/DmdAnal.lhs
_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to