summaryrefslogtreecommitdiff
path: root/compiler/simplCore
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2015-12-31 09:07:33 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2015-12-31 14:43:59 +0000
commit0579fe99b933384172d19beb6a00dc8a1238101a (patch)
tree273ecea533838ccbe61702f5b7a393d830a15fee /compiler/simplCore
parent75851bf930067ae7c57bee3c6feea456534eafed (diff)
downloadhaskell-0579fe99b933384172d19beb6a00dc8a1238101a.tar.gz
Improve exprIsBottom
This fixes Trac #11290, by being sligthtly cleverer about finding what expressions are bottom. Actually this might have minor other side benefits.
Diffstat (limited to 'compiler/simplCore')
-rw-r--r--compiler/simplCore/SetLevels.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/simplCore/SetLevels.hs b/compiler/simplCore/SetLevels.hs
index b742a291fc..b84d67b496 100644
--- a/compiler/simplCore/SetLevels.hs
+++ b/compiler/simplCore/SetLevels.hs
@@ -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