summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/Utils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Core/Utils.hs')
-rw-r--r--compiler/GHC/Core/Utils.hs59
1 files changed, 2 insertions, 57 deletions
diff --git a/compiler/GHC/Core/Utils.hs b/compiler/GHC/Core/Utils.hs
index 30597dd8e5..57a1ccacc3 100644
--- a/compiler/GHC/Core/Utils.hs
+++ b/compiler/GHC/Core/Utils.hs
@@ -23,7 +23,7 @@ module GHC.Core.Utils (
-- * Properties of expressions
exprType, coreAltType, coreAltsType, mkLamType, mkLamTypes,
mkFunctionType,
- exprIsDupable, exprIsTrivial, getIdFromTrivialExpr, exprIsDeadEnd,
+ exprIsDupable, exprIsTrivial, getIdFromTrivialExpr,
getIdFromTrivialExpr_maybe,
exprIsCheap, exprIsExpandable, exprIsCheapX, CheapAppFun,
exprIsHNF, exprOkForSpeculation, exprOkForSideEffects, exprOkForSpecEval,
@@ -1073,63 +1073,8 @@ getIdFromTrivialExpr_maybe e
go (Var v) = Just v
go _ = Nothing
-{-
-exprIsDeadEnd is a very cheap and cheerful function; it may return
-False for bottoming expressions, but it never costs much to ask. See
-also GHC.Core.Opt.Arity.exprBotStrictness_maybe, but that's a bit more
-expensive.
--}
-exprIsDeadEnd :: CoreExpr -> Bool
--- See Note [Bottoming expressions]
-exprIsDeadEnd e
- | isEmptyTy (exprType e)
- = True
- | otherwise
- = go 0 e
- where
- go n (Var v) = isDeadEndAppSig (idDmdSig v) n
- go n (App e a) | isTypeArg a = go n e
- | otherwise = go (n+1) e
- go n (Tick _ e) = go n e
- go n (Cast e _) = go n e
- go n (Let _ e) = go n e
- go n (Lam v e) | isTyVar v = go n e
- go _ (Case _ _ _ alts) = null alts
- -- See Note [Empty case alternatives] in GHC.Core
- go _ _ = False
-
-{- Note [Bottoming expressions]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A bottoming expression is guaranteed to diverge, or raise an
-exception. We can test for it in two different ways, and exprIsDeadEnd
-checks for both of these situations:
-
-* Visibly-bottom computations. For example
- (error Int "Hello")
- is visibly bottom. The strictness analyser also finds out if
- a function diverges or raises an exception, and puts that info
- in its strictness signature.
-
-* Empty types. If a type is empty, its only inhabitant is bottom.
- For example:
- data T
- f :: T -> Bool
- f = \(x:t). case x of Bool {}
- Since T has no data constructors, the case alternatives are of course
- empty. However note that 'x' is not bound to a visibly-bottom value;
- it's the *type* that tells us it's going to diverge.
-
-A GADT may also be empty even though it has constructors:
- data T a where
- T1 :: a -> T Bool
- T2 :: T Int
- ...(case (x::T Char) of {})...
-Here (T Char) is uninhabited. A more realistic case is (Int ~ Bool),
-which is likewise uninhabited.
-
-
-************************************************************************
+{- *********************************************************************
* *
exprIsDupable
* *