<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>
<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">
<h3>
Sebastian Graf pushed to branch wip/dmdanal-precise-exn
at <a href="https://gitlab.haskell.org/ghc/ghc">Glasgow Haskell Compiler / GHC</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.haskell.org/ghc/ghc/-/commit/d9d8b11baed5617977cedc33e28d014e8e8d68c8">d9d8b11b</a></strong>
<div>
<span>by Sebastian Graf</span>
<i>at 2020-04-01T20:09:11+02:00</i>
</div>
<pre class="commit-message" style="white-space: pre-wrap; margin: 0;">DmdAnal: Reflect precise exceptions in demand types
This is part two of the "fixing precise exception" plan in
https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions
and, in combination with !2956, supercedes !2525.
In #13380 and #17676 we saw that we didn't preserve precise exception
semantics in demand analysis. We fixed that with minimal changes in
!2956, but that is terribly unprincipled.
That unprincipledness results in a loss of precision, which is tracked
by these new test cases:
- `T13380b`: Regression in dead code elimination, because !2956 was too
syntactic about `raiseIO#`
- `T13380c`: No need to apply the "IO hack" when the IO action may not
throw a precise exception
- `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting
to manual state token threading and direct use of primops.
More details below.
The "IO hack" (which is a fallback to preserve precise exceptions
semantics and thus soundness, rather than some smart thing that
increases precision) is quite a misnomer and is called
`mayThrowPreciseException` now.
Also there is a slight chance that the IO hack was unsound before,
because it assumes that precise exceptions can only be thrown from a
case scrutinee of type `(# State# RealWorld, _ #)`.
I couldn't come up with a program using the `IO` abstraction that
violates this assumption. But it's easy to do so via manual state token
threading and direct use of primops, see `T13380d`. Also similar code
might be generated by Nested CPR in the (hopefully not too) distant
future.
Hence, we now have a more careful test in `forcesRealWorld` that passes
`T13380d`.
As for *how* we fixed these wrinkles: We augmented the `Divergence`
lattice to a diamond with two new elements forming the middle layer:
- `ExnOrDiv`: Means either `Diverges` (, throws an imprecise exception)
or throws a *precise* exception.
- `ConOrDiv`: Means either `Diverges` (, throws an imprecise exception)
or converges.
See the wiki page for more implementational details:
https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#replacing-hacks-by-principled-program-analyses
</pre>
</li>
</ul>
<h4>30 changed files:</h4>
<ul>
<li class="file-stats">
<a href="#d0d96a6d03668aeab20ebe05e2c4ccb798c7e64c">
compiler/GHC.hs
</a>
</li>
<li class="file-stats">
<a href="#8b1482a65a3092c268b853a00aa18286427d1dec">
compiler/GHC/Core/Arity.hs
</a>
</li>
<li class="file-stats">
<a href="#36a42448a83a9d1f6df8475f03ead2eed199dd8e">
compiler/GHC/Core/Lint.hs
</a>
</li>
<li class="file-stats">
<a href="#3bb380152f7a13d926e48fe380cdce86d60cf92e">
compiler/GHC/Core/Op/CallArity.hs
</a>
</li>
<li class="file-stats">
<a href="#1419e35d2402c23209a644b054c5a67aa4463451">
compiler/GHC/Core/Op/DmdAnal.hs
</a>
</li>
<li class="file-stats">
<a href="#c91bc01a4374fd510bfd57e3818d888393902e29">
compiler/GHC/Core/Op/FloatIn.hs
</a>
</li>
<li class="file-stats">
<a href="#e1d5e8c787a59117885861198e4c24effc067d7a">
compiler/GHC/Core/Op/FloatOut.hs
</a>
</li>
<li class="file-stats">
<a href="#225664ec66ad2a4158da295cbc31b7e2c5808bdb">
compiler/GHC/Core/Op/LiberateCase.hs
</a>
</li>
<li class="file-stats">
<a href="#de7d9d388885ce6e3a45a39fac6e2c36a7f94f69">
compiler/GHC/Core/Op/SetLevels.hs
</a>
</li>
<li class="file-stats">
<a href="#e3fe84599ec044fc7aacb062dada32b067732fc8">
compiler/GHC/Core/Op/Simplify.hs
</a>
</li>
<li class="file-stats">
<a href="#b73ea2c5744c45878c8939cf97da70308baa7e48">
compiler/GHC/Core/Op/Simplify/Utils.hs
</a>
</li>
<li class="file-stats">
<a href="#6fd97a6cb77fefdde9bb59d009ce990a69e83d97">
compiler/GHC/Core/Op/SpecConstr.hs
</a>
</li>
<li class="file-stats">
<a href="#12b764912308026ebf73c88bcb2f60c19c2eaaf9">
compiler/GHC/Core/Op/WorkWrap/Lib.hs
</a>
</li>
<li class="file-stats">
<a href="#11ffe98a94d798427bc600e4fcfe899407536346">
compiler/GHC/Core/SimpleOpt.hs
</a>
</li>
<li class="file-stats">
<a href="#2811a7297b8aa206197ac1f5dabd0818e3c7ec5a">
compiler/GHC/Core/Unfold.hs
</a>
</li>
<li class="file-stats">
<a href="#1a7aba0daeafab195716dd25432479804a55ab60">
compiler/GHC/Core/Utils.hs
</a>
</li>
<li class="file-stats">
<a href="#d11203a9321005ba51a16d751c86f609d1f18c71">
compiler/GHC/Iface/Tidy.hs
</a>
</li>
<li class="file-stats">
<a href="#06ff7bac58fd8cfe0c17b81963b03f4cce86a065">
compiler/GHC/IfaceToCore.hs
</a>
</li>
<li class="file-stats">
<a href="#d09e98aae6ad2eb59d08eac7894b68c0ab820cda">
compiler/GHC/Types/Demand.hs
</a>
</li>
<li class="file-stats">
<a href="#20aaf8344f379f354fe31dd0c1c4db4ddc5b17aa">
compiler/GHC/Types/Id.hs
</a>
</li>
<li class="file-stats">
<a href="#38110817cdbc9a34d2b80a14070cabc7515c808a">
compiler/GHC/Types/Id/Info.hs
</a>
</li>
<li class="file-stats">
<a href="#261c0c5029eb34eb7436b087d77314f377ff8223">
compiler/GHC/Types/Id/Make.hs
</a>
</li>
<li class="file-stats">
<a href="#2a8bedbc781353ca3c4d1e56daba6faa8829aaf3">
compiler/prelude/primops.txt.pp
</a>
</li>
<li class="file-stats">
<a href="#71247aaad504d89a31c398d6edd6cfc090975b86">
testsuite/tests/deSugar/should_compile/T2431.stderr
</a>
</li>
<li class="file-stats">
<a href="#73459bdd68c8a1d83dd2fc05500d4d379b541a3d">
testsuite/tests/numeric/should_compile/T14170.stdout
</a>
</li>
<li class="file-stats">
<a href="#68981928c0d335390bba962b95dc1104a8881d05">
testsuite/tests/numeric/should_compile/T14465.stdout
</a>
</li>
<li class="file-stats">
<a href="#e6a25af732cafed9cd91b716ddbdb29b303bd865">
testsuite/tests/numeric/should_compile/T7116.stdout
</a>
</li>
<li class="file-stats">
<a href="#6e2ce964ea02e92c2202946150700a3219beed86">
testsuite/tests/simplCore/should_compile/T13143.stderr
</a>
</li>
<li class="file-stats">
<a href="#bf69f752e63fa946a0fa2f60e4eb26bfbdb185cd">
testsuite/tests/simplCore/should_compile/T13543.stderr
</a>
</li>
<li class="file-stats">
<a href="#240f515f83d0d2bd4f3fd8627a432213afbc9d16">
testsuite/tests/simplCore/should_compile/T3717.stderr
</a>
</li>
</ul>
<h5>The diff was not included because it is too large.</h5>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">
—
<br>
<a href="https://gitlab.haskell.org/ghc/ghc/-/commit/d9d8b11baed5617977cedc33e28d014e8e8d68c8">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.haskell.org.
If you'd like to receive fewer emails, you can
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.haskell.org/ghc/ghc/-/commit/d9d8b11baed5617977cedc33e28d014e8e8d68c8"}}</script>
</p>
</div>
</body>
</html>