Commit 0579fe99 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Improve exprIsBottom

This fixes Trac #11290, by being sligthtly cleverer about finding
what expressions are bottom.  Actually this might have minor
other side benefits.
parent 75851bf9
......@@ -810,6 +810,8 @@ exprIsBottom 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 CoreSyn
go _ _ = False
{- Note [Bottoming expressions]
......@@ -542,7 +542,7 @@ See Maessen's paper 1999 "Bottom extraction: factoring error handling out
of functional programs" (unpublished I think).
When we do this, we set the strictness and arity of the new bottoming
Id, *immediately*, for two reasons:
Id, *immediately*, for three reasons:
* To prevent the abstracted thing being immediately inlined back in again
via preInlineUnconditionally. The latter has a test for bottoming Ids
......@@ -551,6 +551,17 @@ Id, *immediately*, for two reasons:
* So that it's properly exposed as such in the interface file, even if
this is all happening after strictness analysis.
* In case we do CSE with the same expression that *is* marked bottom
lvl = error "urk"
x{str=bot) = error "urk"
Here we don't want to replace 'x' with 'lvl', else we may get Lint
errors, e.g. via a case with empty alternatives: (case x of {})
Lint complains unless the scrutinee of such a case is clearly bottom.
This was reported in Trac #11290. But since the whole bottoming-float
thing is based on the cheap-and-cheerful exprIsBottom, I'm not sure
that it'll nail all such cases.
Note [Bottoming floats: eta expansion] c.f Note [Bottoming floats]
Tiresomely, though, the simplifier has an invariant that the manifest
......@@ -31,7 +31,8 @@ test('T4966', normal, compile, [''])
test('drv-functor1', normal, compile, [''])
test('drv-functor2', normal, compile, [''])
test('drv-foldable-traversable1', normal, compile, [''])
test('T6031', extra_clean(['T6031a.o', 'T6031a.hi']), multimod_compile, ['T6031', '-v0'])
test('T6031', extra_clean(['T6031a.o', 'T6031a.hi']), multimod_compile, ['T6031', '-v0 -O'])
# Adding -O on T6031 to expose Trac #11245 regardless of way
extra_clean(['T1133.o-boot', 'T1133.hi-boot', 'T1133a.o', 'T1133a.hi']),
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment