1. 28 Apr, 2017 7 commits
• Be a bit more eager to inline in a strict context · 29d88ee1
Simon Peyton Jones authored
```If we see f (g x), and f is strict, we want to be a bit more eager to
inline g, because it may well expose an eval (on x perhaps) that can
be eliminated or shared.

I saw this in nofib boyer2, function RewriteFuns.onewayunify1.  It
showed up as a consequence of the preceding patch that makes the
simplifier do less work (Trac #13379).  We had

f d (g x)

where f was a class-op. Previously we simplified both d and
(g x) with a RuleArgCtxt (making g a bit more eager to inline).
But now we simplify only d that way, then fire the rule, and
only then simplify (g x).  Firing the rule produces a strict
funciion, so we want to make a strict function encourage
inlining a bit.```
• Cure exponential behaviour in the simplifier · a1b753e8
Simon Peyton Jones authored
```This patch nails a Bad Bug exposed in Trac #13379. Roughly,
a deeply-nested application like
f (f (f ....) ) )
could make the simplifier go exponential -- without producing
an exponential-sized result!

The reason was that we
- simplified a (big) function argument
- then decided to inline the function
- then preInilneUnconditionally the argument
- and then re-simplified the big argument

And if the "big argument" itself had a similar structure

Once I'd understood, it was easy to fix:

* See Note Note [Avoiding exponential behaviour] for an overview

* The key change is that Simplify.simplLam now as a case for
(isSimplified dup). This is what removes the perf bug.

avoiding doing so when the coercion is Refl

* And similarly I now try to avoid simplifying arguments
where possible before applying rules.
See Note [Trying rewrite rules]

The latter two points tackle common cases, and in those cases make the
simplifier take fewer iterations.```
• Eta expansion and join points · 25754c83
Simon Peyton Jones authored
```CoreArity.etaExpand tried to deal with eta-expanding expressions
with join points.  For example
let j x = e in \y. b

But it is hard to eta-expand this in the "no-crap" way described in
Note [No crap in eta-expanded code], becuase it would mean pushing
the "apply to y" into the join RHS, and changing its type. And the
join might be recursive, and it might have an unfolding.

Moreover in elaborate cases like this I don't think we need the
no-crap thing.  So for now I'm simplifying the code by generating
\z. (let j x = e in \y. b) z

Let's see if that gives rise to any problems.
See Note [Eta expansion for join points]```
Simon Peyton Jones authored
Simon Peyton Jones authored
• A bit more tcTrace · 6c2d9175
Simon Peyton Jones authored
• Comments and tiny refactoring · 7f6674d6
Simon Peyton Jones authored
2. 27 Apr, 2017 1 commit
3. 26 Apr, 2017 2 commits
4. 25 Apr, 2017 9 commits
• Add instances for Data.Ord.Down · 47be6444
```Namely `Num`, `Functor`, `Applicative`, `Monad`, `Semigroup` and
`Monoid` for `Data.Ord.Down` (#13097).

Reviewers: austin, hvr, bgamari, RyanGlScott

Reviewed By: bgamari, RyanGlScott

Subscribers: RyanGlScott, rwbarton, thomie

GHC Trac Issues: #13097

• Document mkWeak# · 24460269
Ben Gamari authored
```Reviewers: simonmar, austin

Reviewed By: simonmar

Subscribers: RyanGlScott, rwbarton, thomie

GHC Trac Issues: #10640, #13611

• Only pretty-print binders in closed type families with -fprint-explicit-foralls · da792e47
Ryan Scott authored
```Previously, we were unconditionally pretty-printing all type variable
binders when pretty-printing closed type families (e.g., in the output
of `:info` in GHCi). This threw me for a loop, so let's guard this behind
the `-fprint-explicit-foralls` flag.

Test Plan: make test TEST=T13420

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13420

• Add backup url and sync support for Win32 tarball script · 71c3cea6
Tamar Christina authored
```This imports @bgamari's sync script into the mirror script
and adds a backup url for packages.

The idea is that the URLs won't need updating when updating
the tarballs from now on.

failing that it'll try repo.msys2.org

Test Plan: try new command `mk/get-win32-tarballs.sh sync`

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, bgamari

• PPC NCG: Implement callish prim ops · 89a3241f
Peter Trommler authored
```Provide PowerPC optimised implementations of callish prim ops.

MO_?_QuotRem
The generic implementation of quotient remainder prim ops uses
a division and a remainder operation. There is no remainder on
PowerPC and so we need to implement remainder "by hand" which
results in a duplication of the divide operation when using the
generic code.

Avoid this duplication by implementing the prim op in the native
code generator.

MO_U_Mul2
Use PowerPC's instructions for long multiplication.

Use PowerPC add/subtract with carry/overflow instructions

MO_Clz and MO_Ctz
Use PowerPC's CNTLZ instruction and implement count trailing

MO_QuotRem2
Implement an algorithm given by Henry Warren in "Hacker's Delight"
using PowerPC divide instruction. TODO: Use long division instructions
when available (POWER7 and later).

Test Plan: validate on AIX and 32-bit Linux

Reviewers: simonmar, erikd, hvr, austin, bgamari

Reviewed By: erikd, hvr, bgamari

Subscribers: trofi, kgardas, thomie

• configure: Kill off FP_ARG_WITH_* · 9373994a
Ben Gamari authored
```This replaces the --with-* configure flags with the usual autoconf
environment variables, as suggested by #13583.

Test Plan: Configure on various platforms

Reviewers: hvr, trofi, thomie, austin

Reviewed By: trofi

Subscribers: rwbarton, erikd

GHC Trac Issues: #13583

• Revert "Remove special casing of Windows in generic files" · 66108864
Ben Gamari authored
```This commit didn't consider the fact that binary distributions on Windows must
have relative toolchain paths. This caused #13560.

This reverts commit 48385cb2 (except for a
• Don't describe tuple sections as "Python-style" · 688272ba
Chris Martin authored
`(cherry picked from commit 960589e89da3dbf60e88042d7e064ad4a98fb2ff)`
• Don't setProgramDynFlags on every :load · 914842e5
Simon Marlow authored
```Summary:
setProgramDynFlags invalidates the whole module graph, forcing
everything to be re-summarised (including preprocessing) on every

Looks like this was a bad regression in 8.0, but we didn't notice
because there was no test for it.  Now there is!

Test Plan:
* validate
* new unit test

Reviewers: bgamari, triple, austin, niteria, erikd, jme

Subscribers: rwbarton, thomie

5. 24 Apr, 2017 7 commits
• core-spec: Simplify the handling of LetRec · 583fa9e3
Joachim Breitner authored
```We do not need to keep an enrivonment around to implement letrec, as
long as we only do call-by-name. Instead, evaluate letrec by
substituting for all the variables with their RHS wrapped in the letrec
binding.

Since nothing adds to the enrivonment any more, there is no need for a
S_Var rule.

• Guard yet another /bin/sh `for in` loop against empty vars · cd10a232
Herbert Valerio Riedel authored
```This is a follow-up to df679403
which missed `INSTALL_BINS````
• Add failing test case for T13611 · 1c27e5b3
Joachim Breitner authored
`this program should be rejected, but is not (and segfaults).`
• testsuite/driver: Fix deletion retry logic on Windows · 6f9f5ff1
Ben Gamari authored
```Previously rmtree's error callback would throw an exception, breaking
out of the retry loop.

Test Plan: Validate on Windows

Reviewers: Phyx, austin

Reviewed By: Phyx

Subscribers: rwbarton, thomie

• compiler/cmm/PprC.hs: constify labels in .rodata · b68697e5
Sergei Trofimovich authored
```Consider one-line module
module B (v) where v = "hello"
in -fvia-C mode it generates code like
static char gibberish_str[] = "hello";

It resides in data section (precious resource on ia64!).
The patch switches genrator to emit:
static const char gibberish_str[] = "hello";

Other types if symbols that gained 'const' qualifier are:

- info tables (from haskell and CMM)
- static reference tables (from haskell and CMM)

Cleanups along the way:

- fixed info tables defined in .cmm to reside in .rodata
- split out closure declaration into 'IC_' / 'EC_'
- added label declaration (based on label type) right before
each label definition (based on section type) so that C
compiler could check if declaration and definition matches
at definition site.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

Test Plan: ran testsuite on unregisterised x86_64 compiler

Reviewers: simonmar, ezyang, austin, bgamari, erikd

Reviewed By: bgamari, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #8996

• Disable terminfo, if we don’t build it. · d5cb4d2b
Moritz Angermann authored
```This is a derivation of a patch from @jophish.

This is necessary due to `haskeline`'s `terminfo` flag being marked as
`Manual` as of 43d7fa106027fcd4ec7f443923a8dd5b8c169f9c.

Reviewers: jophish, bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie, jophish

• Add regression test for #13603 · ab27fdcf
Ryan Scott authored
```Summary:
Commit b207b536 (#11714) happened to
fix #13603 as well. Let's add a regression test so that it stays fixed.

Test Plan: make test TEST=T13603

Reviewers: bgamari, austin, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13603

6. 23 Apr, 2017 14 commits
• Export function for use in GHC API · 1f4fd37e
Alan Zimmerman authored
• testsuite: Add testcase for #13075 · 868bdcc8
Ben Gamari authored
• testsuite: Add testcase for #13587 · 907b0f3d
Ben Gamari authored
```Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13587

• testsuite: Add test for #13591 · f6eaf01c
Ben Gamari authored
```Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13591

• Only build iserv with -threaded if GhcThreaded is set · 317ceb41
rwbarton authored
```By default GhcThreaded is set by
```
```
so it seems incorrect to try to build iserv with -threaded when
GhcThreaded is not set. This came up when I was building GHC with
some strange combination of flavours (debugged and profiled but not

Test Plan: harbormaster

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, snowleopard

• Document the kind generalization behavior observed in #13555 · 18c3a7ea
Ryan Scott authored
```The conclusion of #13555 was that a program which began to fail to
typecheck (starting in GHC 8.2) was never correct to begin with. Let's
document why this is the case with respect to `MonoLocalBinds`'
interaction with kind generalization. Also adds the reported program as
a `compile_fail` testcase.

Test Plan: make test TEST=T13555 # Also, read the docs

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: goldfire, simonpj, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13555

Moritz Angermann authored
```Further cleanup of the linker, we'll add elf_compat.h for a more
complete set of relocations.

Depends on D3444, D3445

Reviewers: bgamari, austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Moritz Angermann authored
```This diff introduces ElfTypes similar to provide the linker
code with a richer data structure, similar to the approach

Reviewers: bgamari, austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

• rts: Fix "ASSERT ("s · 1d66f105
Ben Gamari authored
```Reviewers: austin, erikd, simonmar

Reviewed By: erikd

Subscribers: rwbarton, thomie

• cpp: Use #pragma once instead of #ifndef guards · f13eebcc
Ben Gamari authored
```This both says what we mean and silences a bunch of spurious CPP linting
warnings. This pragma is supported by all CPP implementations which we
support.

Reviewers: austin, erikd, simonmar, hvr

Reviewed By: simonmar

Subscribers: rwbarton, thomie

• win32/Ticker: Stop ticker on exit · 87fbf39a
Ben Gamari authored
```While debugging an unrelated issue I noticed that we leak a
TimerQueueTimer on exit since we don't necessarily call stopTicker
before exitTicker. Fix this.

Test Plan: Validate on Windows

Reviewers: simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

• ghc.mk: fix 'make install' for cross-mingw32 · 74e5ec9e
Sergei Trofimovich authored
```Attempt to install cross-compiled mingw32 GHC built on linux failed as:

\$ make install DESTDIR=\$(pwd)/__i__

"mv" "\$(pwd)/__i__/usr/local/lib/ghc-8.3.20170422/bin/ghc-stage2" \
"\$(pwd)/__i__/usr/local/lib/ghc-8.3.20170422/bin/ghc"
mv: failed to stat
'\$(pwd)/__i__/usr/local/lib/ghc-8.3.20170422/bin/ghc-stage2': \
No such file or directory

The rename should not be performed for windows targets.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>```