Drop dead Given bindings in setImplicationStatus
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 4 Jan 2018 12:32:13 +0000 (12:32 +0000)
committerBen Gamari <ben@smart-cactus.org>
Sun, 14 Jan 2018 22:07:22 +0000 (17:07 -0500)
commit5124b04f10adfee6390f435a493984f2b45062d0
treed3c5df8ea6eacf0afbe4d0f40b1092e87d06da07
parent594879dcb2fd5421d5f6ce5341442de32a4aac0a
Drop dead Given bindings in setImplicationStatus

Trac #13032 pointed out that we sometimes generate unused
bindings for Givens, and (worse still) we can't always discard
them later (we don't drop a case binding unless we can prove
that the scrutinee is non-bottom.

It looks as if this may be a major reason for the performace
problems in #14338 (see comment:29).

This patch fixes the problem at source, by pruning away all the
dead Givens.  See Note [Delete dead Given evidence bindings]

Remarkably, compiler allocation falls by 23% in
perf/compiler/T12227!

I have not confirmed whether this change actualy helps with

(cherry picked from commit 954cbc7c106a20639960f55ebb85c5c972652d41)
14 files changed:
compiler/basicTypes/VarEnv.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcSMonad.hs
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcUnify.hs
testsuite/tests/indexed-types/should_compile/T7837.stderr
testsuite/tests/perf/compiler/all.T
testsuite/tests/simplCore/should_compile/T4398.stderr
testsuite/tests/typecheck/should_compile/T13032.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T13032.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/all.T