Implement -Wredundant-bang-patterns (#17340)

Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs.
Dead bangs are the ones that under no circumstances can force a thunk that
wasn't already forced. Dead bangs are a form of redundant bangs. The new check
is performed in Pattern-Match Coverage Checker along with other checks (namely,
redundant and inaccessible RHSs). Given

    f :: Bool -> Int
    f True = 1
    f !x   = 2

we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable
where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is
dead. Such a dead bang is then indicated in the annotated pattern-match tree by
a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect
all dead bangs to warn about.

Note that we don't want to warn for a dead bang that appears on a redundant
clause. That is because in that case, we recommend to delete the clause wholly,
including its leading pattern match.

Dead bang patterns are redundant. But there are bang patterns which are
redundant that aren't dead, for example

    f !() = 0

the bang still forces the match variable, before we attempt to match on (). But
it is redundant with the forcing done by the () match. We currently don't
detect redundant bangs that aren't dead.
22 jobs for !3289 with wip/T17340 in 341 minutes and 43 seconds (queued for 3 seconds)
latest detached
Status Job ID Name Coverage
  Lint
passed #418586
lint
ghc-linters

00:01:03

passed #418587
lint
lint-linters

00:01:08

passed #418590
lint
lint-submods

00:00:21

passed #418588
lint
lint-testsuite

00:00:16

passed #418589
lint
typecheck-testsuite

00:00:15

 
  Quick Build
passed #418591
x86_64-linux
hadrian-ghc-in-ghci

00:11:47

 
  Build
passed #418592
x86_64-linux
validate-x86_64-linux-deb9-hadrian

01:36:23

 
  Full Build
failed #418595
aarch64-linux allowed to fail
validate-aarch64-linux-deb9

03:24:43

failed #418596
armv7-linux allowed to fail
validate-armv7-linux-deb9

03:15:09

passed #418597
x86_64-linux
validate-i386-linux-deb9

01:31:39

passed #418594
x86_64-darwin
validate-x86_64-darwin

01:09:50

passed #418598
x86_64-linux
validate-x86_64-linux-deb9-debug

01:41:34

passed #418600
x86_64-linux
validate-x86_64-linux-deb9-dwarf

01:20:33

passed #418599
x86_64-linux
validate-x86_64-linux-deb9-integer-simple

01:33:57

passed #418593
x86_64-linux
validate-x86_64-linux-deb9-unreg-hadrian

02:37:09

passed #418601
x86_64-linux
validate-x86_64-linux-fedora27

01:53:11

failed #418603
new-x86_64-windows test allowed to fail
validate-x86_64-windows

00:30:19

failed #418602
new-x86_64-windows test allowed to fail
validate-x86_64-windows-hadrian

03:27:49

 
  Cleanup
passed #418604
x86_64-darwin
cleanup-darwin

00:00:15

 
  Packaging
failed #418605
x86_64-linux allowed to fail
doc-tarball

00:02:12

 
  Testing
manual #418606
x86_64-linux allowed to fail manual
hackage
passed #418607
x86_64-linux
perf-nofib

00:21:29

 
Name Stage Failure
failed
validate-aarch64-linux-deb9 Full Build
cd "libraries/ghc-compact/tests/compact_pinned.run" &&  "/builds/nineonine/ghc/inplace/bin/ghc-stage2" -o compact_pinned compact_pinned.hs -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output  < 
cd "libraries/ghc-compact/tests/compact_bench.run" && ./compact_bench 100<
=====> compact_bench(sanity) 7564 of 7686 [0, 101, 0]
cd "libraries/ghc-compact/tests/compact_bench.run" && "/builds/nineonine/ghc/inplace/bin/ghc-stage2" -o compact_bench compact_bench.hs -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output -debug <
cd "libraries/ghc-compact/tests/compact_mutable.run" && ./compact_mutable +RTS -c -RTS <
=====> T17044(normal) 7565 of 7686 [0, 101, 0]
cd "libraries/ghc-compact/tests/T17044.run" && "/builds/nineonine/ghc/inplace/bin/ghc-stage2" -o T17044 T17044.hs -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output <
cd "libraries/ghc-compact/tests/compact_gc.run" && ./compact_gc +RTS -DS -RTS <
cd
Job's log exceeded limit of 16384000 bytes.
failed
validate-x86_64-windows Full Build
Git branch:   13-1-stable
GO version: go1.13.8
Built: 2020-06-19T21:12:23+0000
OS/Arch: windows/amd64
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=7084 revision=6214287e version=13.1.0
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit status 1
failed
validate-armv7-linux-deb9 Full Build
Uploading artifacts...
ghc-armv7-linux-deb9.tar.xz: found 1 matching files

junit.xml: found 1 matching files

performance-metrics.tsv: found 1 matching files

Uploading artifacts to coordinator... ok
id=418596 responseStatus=201 Created token=zhRYgppZ
Uploading artifacts...
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=418596 responseStatus=201 Created token=zhRYgppZ
ERROR: Job failed: exit code 1
failed
validate-x86_64-windows-hadrian Full Build
GO version:   go1.13.8
Built: 2020-06-19T21:12:23+0000
OS/Arch: windows/amd64
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=720 revision=6214287e version=13.1.0
junit.xml: found 1 matching files and directories

WARNING: Failed to load system CertPool: crypto/x509: system root pool is not available on Windows
Uploading artifacts as "junit" to coordinator... ok
id=418602 responseStatus=201 Created token=CbM8rB-L
ERROR: Job failed: exit status 1
failed
doc-tarball Packaging
Entering 'utils/haddock'
Entering 'utils/hsc2hs'
Downloading artifacts
Downloading artifacts for validate-x86_64-linux-deb9-debug (418598)...
Downloading artifacts from coordinator... ok
id=418598 responseStatus=200 OK token=Q3c3fV5C
Executing "step_script" stage of the job script
$ if [ ! -f "$LINUX_BINDIST" ]; then # collapsed multi-line command
Error: ghc-x86_64-mingw32.tar.xz does not exist. Did the 64-bit Windows job fail?
ERROR: Job failed: exit code 1