[commit: ghc] ghc-8.0: Improve exprIsBottom (28b0693)
git at git.haskell.org
git at git.haskell.org
Fri Jan 1 18:33:13 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.0
Link : http://ghc.haskell.org/trac/ghc/changeset/28b069319eb0390fd1745949ba2ad2e623d69b00/ghc
>---------------------------------------------------------------
commit 28b069319eb0390fd1745949ba2ad2e623d69b00
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Thu Dec 31 09:07:33 2015 +0000
Improve exprIsBottom
This fixes Trac #11290, by being sligthtly cleverer about finding
what expressions are bottom. Actually this might have minor
other side benefits.
(cherry picked from commit 0579fe99b933384172d19beb6a00dc8a1238101a)
>---------------------------------------------------------------
28b069319eb0390fd1745949ba2ad2e623d69b00
compiler/coreSyn/CoreUtils.hs | 2 ++
compiler/simplCore/SetLevels.hs | 13 ++++++++++++-
testsuite/tests/deriving/should_compile/all.T | 3 ++-
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs
index f31eac6..d89612a 100644
--- a/compiler/coreSyn/CoreUtils.hs
+++ b/compiler/coreSyn/CoreUtils.hs
@@ -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]
diff --git a/compiler/simplCore/SetLevels.hs b/compiler/simplCore/SetLevels.hs
index b742a29..b84d67b 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
diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T
index 36d49f5..ff26d37 100644
--- a/testsuite/tests/deriving/should_compile/all.T
+++ b/testsuite/tests/deriving/should_compile/all.T
@@ -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
test('T1133',
extra_clean(['T1133.o-boot', 'T1133.hi-boot', 'T1133a.o', 'T1133a.hi']),
run_command,
More information about the ghc-commits
mailing list