ghc.git
3 years agoRevert "Desugar: Display resulting program stats with -v2"
Ömer Sinan Ağacan [Wed, 8 Jun 2016 08:55:17 +0000 (04:55 -0400)] 
Revert "Desugar: Display resulting program stats with -v2"

This reverts commit dd33245922a9d363bdb8c34d00ed4d1574bc5285.

It seems like we already have `endPassIO` calls here, which should print
term sizes. For some reason they don't sometimes, and we need to
understand why instead of adding more prints.

3 years agoDesugar: Display resulting program stats with -v2
Ömer Sinan Ağacan [Wed, 8 Jun 2016 08:47:05 +0000 (04:47 -0400)] 
Desugar: Display resulting program stats with -v2

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2310

3 years agoAdd some determinism tests
Bartosz Nitka [Tue, 7 Jun 2016 20:04:22 +0000 (13:04 -0700)] 
Add some determinism tests

These are the tests that I accumulated fixing real issues.
Each test is a separate thing that was broken and they are
relatively small.

GHC Trac: #4012

3 years agoTestsuite Windows: mark T8308 expect_broken (#8308)
Thomas Miedema [Tue, 7 Jun 2016 19:13:34 +0000 (21:13 +0200)] 
Testsuite Windows: mark T8308 expect_broken (#8308)

3 years agoTestsuite driver: always quote opts.testdir
Thomas Miedema [Tue, 7 Jun 2016 13:59:15 +0000 (15:59 +0200)] 
Testsuite driver: always quote opts.testdir

This makes sure the testsuite keeps working when testdir contains
backward slashes.

Differential Revision: https://phabricator.haskell.org/D2314

3 years agoTypofix.
Edward Z. Yang [Tue, 7 Jun 2016 21:13:42 +0000 (14:13 -0700)] 
Typofix.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoUse pprUFM in pprStgLVs
Bartosz Nitka [Tue, 7 Jun 2016 15:43:58 +0000 (08:43 -0700)] 
Use pprUFM in pprStgLVs

3 years agoKill varSetElems
Bartosz Nitka [Tue, 7 Jun 2016 14:47:42 +0000 (07:47 -0700)] 
Kill varSetElems

This eradicates varSetElems from the codebase. This function
used to introduce nondeterminism.
I've also documented benign nondeterminism in three places.

GHC Trac: #4012

3 years agoMake vectInfoParallelVars a DVarSet
Bartosz Nitka [Tue, 7 Jun 2016 14:19:30 +0000 (07:19 -0700)] 
Make vectInfoParallelVars a DVarSet

We dump it in the interface file, so we need to do it in a
deterministic order. I haven't seen any problems with this
during my testing, but that's probably because it's unused.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2313

GHC Trac Issues: #4012

3 years agoDocument determinism in pprintClosureCommand
Bartosz Nitka [Tue, 7 Jun 2016 14:33:45 +0000 (07:33 -0700)] 
Document determinism in pprintClosureCommand

Like described in the comment, it's OK here.

GHC Trac: #4012

3 years agoUse DVarSet in Vectorise.Exp
Bartosz Nitka [Tue, 7 Jun 2016 13:28:51 +0000 (06:28 -0700)] 
Use DVarSet in Vectorise.Exp

I believe this part of code is a bit unused. That's
probably why it never became a problem in my testing.
I'm changing to deterministic sets here to be safer.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2312

GHC Trac Issues: #4012

3 years agoKill varSetElems in checkValidInferredKinds
Bartosz Nitka [Tue, 7 Jun 2016 13:53:14 +0000 (06:53 -0700)] 
Kill varSetElems in checkValidInferredKinds

It's only used for producing an error message here

GHC Trac: #4012

3 years agoFix build by removing unused import
Bartosz Nitka [Tue, 7 Jun 2016 13:41:12 +0000 (06:41 -0700)] 
Fix build by removing unused import

3 years agoKill two instances of uniqSetToList
Bartosz Nitka [Tue, 7 Jun 2016 12:36:43 +0000 (05:36 -0700)] 
Kill two instances of uniqSetToList

There should be no performance impact of switching to the
deterministic set here.

GHC Trac: #4012

3 years agoCoreToStg: Remove hand-written Eq instances of HowBound and LetInfo
Ömer Sinan Ağacan [Tue, 7 Jun 2016 13:15:22 +0000 (09:15 -0400)] 
CoreToStg: Remove hand-written Eq instances of HowBound and LetInfo

3 years agoUse a deterministic map for imp_dep_mods
Bartosz Nitka [Tue, 7 Jun 2016 12:55:50 +0000 (05:55 -0700)] 
Use a deterministic map for imp_dep_mods

This lets us remove some normalization and makes it
less brittle for the future.

Test Plan: ./validate

Reviewers: ezyang, austin, bgamari, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2311

GHC Trac Issues: #4012

3 years agoKill occSetElts
Bartosz Nitka [Tue, 7 Jun 2016 12:23:32 +0000 (05:23 -0700)] 
Kill occSetElts

It uses uniqSetToList which is nondeterministic.

GHC Trac: #4012

3 years agoMerge MatchFixity and HsMatchContext
Alan Zimmerman [Tue, 24 May 2016 22:09:34 +0000 (00:09 +0200)] 
Merge MatchFixity and HsMatchContext

Summary:
MatchFixity was introduced to facilitate use of API Annotations.

HsMatchContext does the same thing with more detail, but is chased
through all over the place to provide context when processing a Match.

Since we already have MatchFixity in the Match, it may as well provide
the full context.

updates submodule haddock

Test Plan: ./validate

Reviewers: austin, goldfire, bgamari

Subscribers: thomie, mpickering

Differential Revision: https://phabricator.haskell.org/D2271

GHC Trac Issues: #12105

(cherry picked from commit 306ecad591951521ac3f5888ca8be85bf749d271)

3 years agoMake UnitIdMap a deterministic map
Bartosz Nitka [Mon, 6 Jun 2016 15:54:17 +0000 (08:54 -0700)] 
Make UnitIdMap a deterministic map

This impacts at least the order in which version macros are
generated. It's pretty hard to track what kind of nondeterminism
is benign and this should have no performance impact as the number
of packages should be relatively small.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari, ezyang

Reviewed By: ezyang

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2308

GHC Trac Issues: #4012

3 years agoKill foldUniqSet
Bartosz Nitka [Mon, 6 Jun 2016 15:15:43 +0000 (08:15 -0700)] 
Kill foldUniqSet

I planned to just say that we don't care about this part.
Turns out I was able to document away the uses in the codegenerator.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2307

GHC Trac Issues: #4012

3 years agoDocument putDictionary determinism
Bartosz Nitka [Mon, 6 Jun 2016 14:38:03 +0000 (07:38 -0700)] 
Document putDictionary determinism

Summary: Like explained in the comment it's OK here.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2306

GHC Trac Issues: #4012

3 years agoKill nameSetElems
Bartosz Nitka [Mon, 6 Jun 2016 13:53:25 +0000 (06:53 -0700)] 
Kill nameSetElems

nameSetElems used `eltsUFM` which is nondeterministic.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2305

GHC Trac Issues: #4012

3 years agoDesugar ApplicativeDo and RecDo deterministically
Bartosz Nitka [Mon, 6 Jun 2016 13:08:54 +0000 (06:08 -0700)] 
Desugar ApplicativeDo and RecDo deterministically

This fixes a problem described in
Note [Deterministic ApplicativeDo and RecursiveDo desugaring].

Test Plan: ./validate + new testcase

Reviewers: simonpj, bgamari, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2287

GHC Trac Issues: #4012

3 years agoAdd @since annotations to base instances
Seraphime Kirkovski [Mon, 6 Jun 2016 10:29:38 +0000 (12:29 +0200)] 
Add @since annotations to base instances

Add @since annotations to instances in `base`.

Test Plan:
 * ./validate  # some commets shouldn't break the build
 * review the annotations for absurdities.

Reviewers: ekmett, goldfire, RyanGlScott, austin, hvr, bgamari

Reviewed By: RyanGlScott, hvr, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2277

GHC Trac Issues: #11767

3 years agoImplement deterministic CallInfoSet
Bartosz Nitka [Mon, 6 Jun 2016 11:36:21 +0000 (04:36 -0700)] 
Implement deterministic CallInfoSet

We need CallInfoSet to be deterministic because it determines the
order that the binds get generated.

Currently it's not deterministic because it's keyed on
`CallKey = [Maybe Type]` and `Ord CallKey` is implemented
with `cmpType` which is nondeterministic.

See Note [CallInfoSet determinism] for more details.

Test Plan: ./validate

Reviewers: simonpj, bgamari, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2242

GHC Trac Issues: #4012

3 years agoUse UniqDFM for HomePackageTable
Bartosz Nitka [Mon, 6 Jun 2016 09:10:07 +0000 (02:10 -0700)] 
Use UniqDFM for HomePackageTable

This isn't strictly necessary for deterministic ABIs.
The results of eltsHpt are consumed in two ways:
1) they determine the order of linking
2) if you track the data flow all the family instances get put in
   FamInstEnvs, so the nondeterministic order is forgotten.
3) same for VectInfo stuff
4) same for Annotations

The problem is that I haven't found a nice way to do 2. in
a local way and 1. is nice to have if we went for deterministic
object files. Besides these maps are keyed on ModuleNames so they
should be small relative to other things and the overhead should
be negligible.

As a bonus we also get more specific names.

Test Plan: ./validate

Reviewers: bgamari, austin, hvr, ezyang, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2300

GHC Trac Issues: #4012

3 years agoFailing test-case for #12135.
Edward Z. Yang [Sun, 5 Jun 2016 18:40:35 +0000 (11:40 -0700)] 
Failing test-case for #12135.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoBetter comment for orIfNotFound.
Edward Z. Yang [Mon, 16 May 2016 18:31:12 +0000 (11:31 -0700)] 
Better comment for orIfNotFound.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoTestsuite: fixup comments for T9872d [skip ci]
Thomas Miedema [Sun, 5 Jun 2016 11:29:34 +0000 (13:29 +0200)] 
Testsuite: fixup comments for T9872d [skip ci]

Resolve confusion resulting from:
6746549772c5cc0ac66c0fce562f297f4d4b80a2 (typo in 64 + 32 bit numbers)
ae86eb9f72fa7220fe47ac54d6d21395691c1308 (corrects 64 bit number)
1a8d61ca1a54820d2bc30c6a964312faf76d0635 (corrects 32 bit number)

3 years agoAdd relocation type R_X86_64_REX_GOTPCRELX
Tamar Christina [Sun, 5 Jun 2016 07:59:05 +0000 (09:59 +0200)] 
Add relocation type R_X86_64_REX_GOTPCRELX

Summary:
Adding support for the `R_X86_64_REX_GOTPCRELX` relocation type.
This relocation is treated by the linker the same as the `R_X86_64_GOTPCRELX` type
`G + GOT + A - P` to generate relative offsets to the GOT.
The `REX` prefix has no influence in this stage.

This is based on https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r252.pdf

Test Plan: ./validate

Reviewers: erikd, austin, bgamari, simonmar

Reviewed By: erikd

Subscribers: thomie, #ghc_windows_task_force

Differential Revision: https://phabricator.haskell.org/D2303

GHC Trac Issues: #12147

3 years agoReplace hand-written Bounded instances with derived ones
Ryan Scott [Sat, 4 Jun 2016 21:59:47 +0000 (17:59 -0400)] 
Replace hand-written Bounded instances with derived ones

Summary:
The spiritual successor to D2291, since deriving `Bounded` instances
in `GHC.Enum` wasn't possible prior to changes made in that Diff.

This Diff finds every manually implemented `Bounded` instance in `base` that is
completely equivalent to the derived instances, and replaces it.

Reviewers: bgamari, goldfire, austin, hvr

Reviewed By: austin, hvr

Subscribers: thomie, rwbarton

Differential Revision: https://phabricator.haskell.org/D2301

3 years agoRefactor the SymbolName and SymbolAddr types to be pointers
Tamar Christina [Sat, 4 Jun 2016 11:07:32 +0000 (13:07 +0200)] 
Refactor the SymbolName and SymbolAddr types to be pointers

Take the pointer notation out of the typedef such that it preserves the
fact that these are pointers at the use site.

Test Plan:
./validate on all platforms that use the runtime linker.

For unix platforms please ensure `DYNAMIC_GHC_PROGRAMS=NO` is
 added to your validate file.

Continuation of D2250

Reviewers: austin, bgamari, simonmar, erikd

Reviewed By: erikd

Subscribers: thomie, #ghc_windows_task_force

Differential Revision: https://phabricator.haskell.org/D2302

GHC Trac Issues: #11816

3 years agoRename isPinnedByteArray# to isByteArrayPinned#
Ben Gamari [Fri, 3 Jun 2016 20:22:42 +0000 (22:22 +0200)] 
Rename isPinnedByteArray# to isByteArrayPinned#

Reviewers: simonmar, duncan, erikd, austin

Reviewed By: austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2290

GHC Trac Issues: #12059

3 years agoRTS SMP: Use compiler built-ins on all platforms.
Peter Trommler [Fri, 3 Jun 2016 20:22:23 +0000 (22:22 +0200)] 
RTS SMP: Use compiler built-ins on all platforms.

Use C compiler builtins for atomic SMP primitives. This saves a lot
of CPP ifdefs.

Add test for atomic xchg:
Test if __sync_lock_test_and_set() builtin stores the second argument.
The gcc manual says the actual value stored is implementation defined.

Test Plan: validate and eyeball generated assembler code

Reviewers: kgardas, simonmar, hvr, bgamari, austin, erikd

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2233

3 years agoPrelInfo: Ensure that tuple promoted datacon names are in knownKeyNames
Ben Gamari [Fri, 3 Jun 2016 20:19:17 +0000 (22:19 +0200)] 
PrelInfo: Ensure that tuple promoted datacon names are in knownKeyNames

Previously the promoted datacons of the boxed tuple types were not
included in knownKeyNames, which lead to #12132.

Test Plan: Test with included TypeOf testcase

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2279

GHC Trac Issues: #12132

3 years agointeger-gmp: Make minusInteger more efficient
Alan Mock [Fri, 3 Jun 2016 20:16:27 +0000 (22:16 +0200)] 
integer-gmp: Make minusInteger more efficient

Give `minusInteger` its own implementation.
Previously `minusInteger` used `plusInteger` and `negateInteger`, which
meant it always allocated.  Now it works more like `plusInteger`.

Reviewers: goldfire, hvr, bgamari, austin

Reviewed By: hvr, bgamari, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2278

GHC Trac Issues: #12129

3 years agoUse useful names for Symbol Addr and Names in Linker.c
Tamar Christina [Fri, 3 Jun 2016 19:42:45 +0000 (21:42 +0200)] 
Use useful names for Symbol Addr and Names in Linker.c

Replace `char*` and `void*` with `SymbolName` and `SymbolAddr` in
`Linker.c`. Gives some useful information about what the variables are
used for and also normalizes the types used in Mac, Linux and Windows

Test Plan:
./validate on all platforms that use the runtime linker.

For unix platforms please ensure `DYNAMIC_GHC_PROGRAMS=NO` is
 added to your validate file.

This is a continuation from D2184

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie, #ghc_windows_task_force

Differential Revision: https://phabricator.haskell.org/D2250

GHC Trac Issues: #11816

3 years agoRefactored SymbolInfo to lower memory usage in RTS
Tamar Christina [Fri, 3 Jun 2016 19:42:16 +0000 (21:42 +0200)] 
Refactored SymbolInfo to lower memory usage in RTS

Previously as part of #11223 a new struct `SymbolInfo` was introduced to
keep track it the weak symbol status of a symbol.

This structure also kept a copy of the calculated address of the symbol
which turns out was useful in ignoring non-weak zero-valued symbols.

The information was kept in an array so it means for every symbol two
extra bytes were kept even though the vast majority of symbols are
non-weak and non-zero valued.

This changes the array into a sparse map keeping this information only
for the symbols that are weak or zero-valued. This allows for a
reduction in the amount of information needed to be kept while giving up
a small (negligable) hit in performance as this information now has to
be looked up in hashmaps.

Test Plan: ./validate on all platforms that use the runtime linker.

For unix platforms please ensure `DYNAMIC_GHC_PROGRAMS=NO` is added to
your validate file.

Reviewers: simonmar, austin, erikd, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie, #ghc_windows_task_force

Differential Revision: https://phabricator.haskell.org/D2184

GHC Trac Issues: #11816

3 years agotestsuite: Mark broken tests on powerpc64le
Peter Trommler [Fri, 3 Jun 2016 19:39:31 +0000 (21:39 +0200)] 
testsuite: Mark broken tests on powerpc64le

Mark all failing tests that have a ticket for powerpc64 as broken. Most
of these failures are due to the lack of linker support in the runtime
system.

Test Plan: validate on powerpc and AIX

Reviewers: erikd, bgamari, simonmar, hvr, austin

Reviewed By: austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2289

GHC Trac Issues: #11261, #11259, #11260, #11323

3 years agoDerive instances in Data.Data
Ryan Scott [Fri, 3 Jun 2016 18:48:16 +0000 (14:48 -0400)] 
Derive instances in Data.Data

Summary:
Currently, none of the `Data` instances in `Data.Data` are derived,
which has resulted in hundreds of lines of laboriously hand-written `Data`
instances. This cleans it up by using `DeriveDataTypeable` to derive all of
the boring instances.

Note that previously, `tcTopSrcDecls` in `TcRnDriver` was typechecking the
variables generated in `deriving` statements before other top-level variables,
which causes an error when `DeriveDataTypeable` is used in `Data.Data`, since
the `deriving`-generated variable definitions refer to top-level definitions
in `Data.Data` itself. To fix this, the order in which these two groups are
typechecked was reversed.

Test Plan: ./validate

Reviewers: rwbarton, bgamari, hvr, austin

Reviewed By: austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D2291

3 years agoDocument putSymbolTable determinism
Bartosz Nitka [Fri, 3 Jun 2016 16:11:50 +0000 (09:11 -0700)] 
Document putSymbolTable determinism

Like explained in the comment it's OK here.

Test Plan: ./validate

Reviewers: bgamari, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2298

GHC Trac Issues: #4012

3 years agoMake FieldLabelEnv a deterministic set
Bartosz Nitka [Fri, 3 Jun 2016 16:11:10 +0000 (09:11 -0700)] 
Make FieldLabelEnv a deterministic set

This lets us kill fsEnvElts function which is nondeterministic.
We also get better guarantees than just comments.
We don't do lookups, but I believe a set is needed for deduplication.

Test Plan: ./validate

Reviewers: bgamari, mpickering, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2297

GHC Trac Issues: #4012

3 years agoHscMain: Minor simplification
Ömer Sinan Ağacan [Fri, 3 Jun 2016 08:05:48 +0000 (04:05 -0400)] 
HscMain: Minor simplification

3 years agoWhitespace only
Ömer Sinan Ağacan [Fri, 3 Jun 2016 07:38:34 +0000 (03:38 -0400)] 
Whitespace only

3 years agoKill nameSetElems in rnCmdTop
Bartosz Nitka [Thu, 2 Jun 2016 18:38:11 +0000 (11:38 -0700)] 
Kill nameSetElems in rnCmdTop

This change isn't necessary for determinism. appAName, choiceAName,
loopAName all have pre-allocated Uniques and their relative order
can't change. I opted to use nameSetElemsStable here because:
* the cost is negligible
* it's less fragile than just documenting

Test Plan: ./validate

Reviewers: simonpj, austin, bgamari, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2292

GHC Trac Issues: #4012

3 years agoKill nameSetElems in findImportUsage
Bartosz Nitka [Thu, 2 Jun 2016 18:37:41 +0000 (11:37 -0700)] 
Kill nameSetElems in findImportUsage

nameSetElems is nondeterministic and while I think we don't need
determinism here it doesn't hurt.

Test Plan: ./validate

Reviewers: ezyang, bgamari, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2293

GHC Trac Issues: #4012

3 years agoUse UniqDSet for finding free names in the Linker
Bartosz Nitka [Thu, 2 Jun 2016 18:36:44 +0000 (11:36 -0700)] 
Use UniqDSet for finding free names in the Linker

This is not necessary for determinism, but it's a choice
between making this deterministic and using `nonDetEltsUFM`
and a comment explaining that it doesn't matter.

Test Plan: ./validate

Reviewers: austin, hvr, bgamari, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2295

GHC Trac Issues: #4012

3 years agoRemove dead generics-related code from OccName
Ryan Scott [Thu, 2 Jun 2016 19:00:22 +0000 (15:00 -0400)] 
Remove dead generics-related code from OccName

Before #9766 was fixed, GHC would generate auxiliary datatypes for every
Generic instance, and it would use functions from OccName to prefix the
generated names. GHC no longer generates any auxiliary datatypes for
Generic instances, but the accompanying code was never removed from
OccName (until now).

3 years agoAdd nameSetElemsStable and fix the build
Bartosz Nitka [Thu, 2 Jun 2016 17:34:57 +0000 (10:34 -0700)] 
Add nameSetElemsStable and fix the build

3 years agoSerialize vParallelTyCons in a stable order
Bartosz Nitka [Thu, 2 Jun 2016 16:51:04 +0000 (09:51 -0700)] 
Serialize vParallelTyCons in a stable order

nameSetElems can introduce nondeterminism and while I haven't
observed this being a problem in practice (possibly because this
is dead code) there's no downside to doing this.

Test Plan: ./validate

Reviewers: bgamari, austin, simonpj, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2296

GHC Trac Issues: #4012

3 years agoLocalize orphan-related nondeterminism
Bartosz Nitka [Thu, 2 Jun 2016 16:39:47 +0000 (09:39 -0700)] 
Localize orphan-related nondeterminism

chooseOrphanAnchor now takes a NameSet, relieving the callers
from the burden of converting it to a list

Test Plan: ./validate

Reviewers: bgamari, ezyang, austin, simonmar, simonpj

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2294

GHC Trac Issues: #4012

3 years agoTravis: llvm's apt repository is offline
Thomas Miedema [Thu, 2 Jun 2016 13:29:39 +0000 (15:29 +0200)] 
Travis: llvm's apt repository is offline

3 years agoTestsuite: run tests in /tmp/ghctest-xxx instead of /tmp/ghctest/xxx
Thomas Miedema [Thu, 2 Jun 2016 13:10:28 +0000 (15:10 +0200)] 
Testsuite: run tests in /tmp/ghctest-xxx instead of /tmp/ghctest/xxx

This fixes a bug of not being able to create files or directories in
/tmp/ghctest if it was created by a different user.

Trac ticket #11980.

3 years agoKill nameSetElems in getInfo
Bartosz Nitka [Thu, 2 Jun 2016 13:18:03 +0000 (06:18 -0700)] 
Kill nameSetElems in getInfo

nameSetAll is more precise here

3 years agoImprove failed knot-tying error message.
Edward Z. Yang [Mon, 30 May 2016 12:21:36 +0000 (14:21 +0200)] 
Improve failed knot-tying error message.

Test Plan: validate

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2207

3 years agoUse nameSetAny in findUses
Bartosz Nitka [Thu, 2 Jun 2016 09:17:37 +0000 (02:17 -0700)] 
Use nameSetAny in findUses

This kills one use of nameSetElems which is nondeterministic

3 years agoFix detection and use of `USE_LIBDW`
Erik de Castro Lopo [Tue, 31 May 2016 20:14:00 +0000 (06:14 +1000)] 
Fix detection and use of `USE_LIBDW`

Test Plan: Configure/build with and without --enable-libdw

Reviewers: trofi, hvr, austin, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2276

3 years agoUpdate a Cmm note
Ömer Sinan Ağacan [Tue, 31 May 2016 11:54:17 +0000 (07:54 -0400)] 
Update a Cmm note

3 years agoRemove unused FAST_STRING_NOT_NEEDED macro defs
Ömer Sinan Ağacan [Tue, 31 May 2016 08:08:35 +0000 (04:08 -0400)] 
Remove unused FAST_STRING_NOT_NEEDED macro defs

Reviewers: austin, bgamari, simonmar, hvr

Reviewed By: hvr

Subscribers: hvr, thomie

Differential Revision: https://phabricator.haskell.org/D2285

3 years agoStgCmmUtils.emitMultiAssign: Make assertion msg more helpful
Ömer Sinan Ağacan [Mon, 30 May 2016 14:39:59 +0000 (10:39 -0400)] 
StgCmmUtils.emitMultiAssign: Make assertion msg more helpful

3 years agoRtsFlags.c: Const correct fixes
Erik de Castro Lopo [Sat, 28 May 2016 21:26:39 +0000 (07:26 +1000)] 
RtsFlags.c: Const correct fixes

Test Plan: validate

Reviewers: hvr, austin, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2275

3 years agoTestsuite: don't use --interactive in Makefiles
Thomas Miedema [Wed, 25 May 2016 11:24:34 +0000 (13:24 +0200)] 
Testsuite: don't use --interactive in Makefiles

Add a linter to encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)`
instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's
too easy to forget one of those flags when adding a new test.

Update submodule hpc.

Reviewed by: austin

Differential Revision: https://phabricator.haskell.org/D2265

GHC Trac Issues: #11468

3 years agoClarify users' guide section on GeneralizedNewtypeDeriving
Ryan Scott [Fri, 27 May 2016 18:12:57 +0000 (14:12 -0400)] 
Clarify users' guide section on GeneralizedNewtypeDeriving

Summary:
It seemed to imply that GHC was generating infelicitous code when it
actually wasn't. Fixes #12047.

Reviewers: hvr, bgamari, austin

Reviewed By: austin

Subscribers: thomie, Iceland_jack

Differential Revision: https://phabricator.haskell.org/D2273

GHC Trac Issues: #12047

3 years agoTypos in comments
Gabor Greif [Fri, 27 May 2016 15:09:33 +0000 (17:09 +0200)] 
Typos in comments

3 years agoDo not init record accessors as exported
Ömer Sinan Ağacan [Fri, 27 May 2016 15:02:47 +0000 (11:02 -0400)] 
Do not init record accessors as exported

This was causing redundant code generation when accessors are not
actually exported, as they were being marked as "exported" at
initialization.

Test Plan: validate

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: mpickering, thomie

Differential Revision: https://phabricator.haskell.org/D2270

3 years agoStgCmmExpr: Remove a redundant list
Ömer Sinan Ağacan [Fri, 27 May 2016 14:47:50 +0000 (10:47 -0400)] 
StgCmmExpr: Remove a redundant list

3 years agoComments and white space only
Simon Peyton Jones [Fri, 27 May 2016 13:38:25 +0000 (14:38 +0100)] 
Comments and white space only

3 years agoMore fixes for unboxed tuples
Simon Peyton Jones [Fri, 27 May 2016 13:34:45 +0000 (14:34 +0100)] 
More fixes for unboxed tuples

This is a continuation of
   commit e9e61f18a548b70693f4ccd245bc56335c94b498
   Date:   Thu May 26 15:24:53 2016 +0100
   Reduce special-casing for nullary unboxed tuple

which related to Trac #12115.  But typecheck/should_run/tcrun051
revealed that my patch was incomplete.

This fixes it, by removing another special case in Type.repType.
I had also missed a case in UnariseStg.unariseIdBinder.

I took the opportunity to add explanatory notes
  Note [Unarisation]
  Note [Unarisation and nullary tuples]
in UnariseStg

3 years agoStgCmmCon: Do not generate moves from unused fields to local variables
Ömer Sinan Ağacan [Fri, 27 May 2016 09:18:47 +0000 (05:18 -0400)] 
StgCmmCon: Do not generate moves from unused fields to local variables

Say we have a record like this:

    data Rec = Rec
      { f1 :: Int
      , f2 :: Int
      , f3 :: Int
      , f4 :: Int
      , f5 :: Int
      }

Before this patch, the code generated for `f1` looked like this:

    f1_entry()
        {offset
           ...
           cJT:
               _sI6::P64 = R1;
               _sI7::P64 = P64[_sI6::P64 + 7];
               _sI8::P64 = P64[_sI6::P64 + 15];
               _sI9::P64 = P64[_sI6::P64 + 23];
               _sIa::P64 = P64[_sI6::P64 + 31];
               _sIb::P64 = P64[_sI6::P64 + 39];
               R1 = _sI7::P64 & (-8);
               Sp = Sp + 8;
               call (I64[R1])(R1) args: 8, res: 0, upd: 8;
        }

Note how all fields of the record are moved to local variables, even though
they're never used. These moves make it to the final assembly:

    f1_info:
        ...
    _cJT:
        movq 7(%rbx),%rax
        movq 15(%rbx),%rcx
        movq 23(%rbx),%rcx
        movq 31(%rbx),%rcx
        movq 39(%rbx),%rbx
        movq %rax,%rbx
        andq $-8,%rbx
        addq $8,%rbp
        jmp *(%rbx)

With this patch we stop generating these move instructions. Cmm becomes this:

    f1_entry()
        {offset
           ...
           cJT:
               _sI6::P64 = R1;
               _sI7::P64 = P64[_sI6::P64 + 7];
               R1 = _sI7::P64 & (-8);
               Sp = Sp + 8;
               call (I64[R1])(R1) args: 8, res: 0, upd: 8;
        }

Assembly becomes this:

    f1_info:
        ...
    _cJT:
        movq 7(%rbx),%rax
        movq %rax,%rbx
        andq $-8,%rbx
        addq $8,%rbp
        jmp *(%rbx)

It turns out CmmSink already optimizes this, but it's better to generate
better code in the first place.

Reviewers: simonmar, simonpj, austin, bgamari

Reviewed By: simonmar, simonpj

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D2269

3 years agoCoverage.hs: Fix a duplication
Ömer Sinan Ağacan [Thu, 26 May 2016 16:06:35 +0000 (12:06 -0400)] 
Coverage.hs: Fix a duplication

3 years agoStgCmmExpr: Fix a duplication
Ömer Sinan Ağacan [Thu, 26 May 2016 16:04:36 +0000 (12:04 -0400)] 
StgCmmExpr: Fix a duplication

3 years agoReduce special-casing for nullary unboxed tuple
Simon Peyton Jones [Thu, 26 May 2016 14:24:53 +0000 (15:24 +0100)] 
Reduce special-casing for nullary unboxed tuple

When we built the kind of a nullary unboxed tuple, we said, in
TysWiredIn.mk_tuple:

    res_rep | arity == 0 = voidRepDataConTy
                  -- See Note [Nullary unboxed tuple] in Type
            | otherwise  = unboxedTupleRepDataConTy

But this is bogus.  The Note deals with what the 'unarise' transformation
does, and up to that point it's simpler and more uniform to treat
nullary unboxed tuples the same as all the others.

Nicer now.  And it fixes the Lint error in Trac #12115

3 years agoFix bytecode gen to deal with rep-polymorphism
Simon Peyton Jones [Thu, 26 May 2016 13:20:29 +0000 (14:20 +0100)] 
Fix bytecode gen to deal with rep-polymorphism

When faced runtime-rep-polymorphic code from a pattern-synonym
matcher, the bytecode generator was treating the result as lifted,
which it isn't.  The fix is just to treat those rep-polymorphic
continuations like unlifted types, and add a dummy arg.

Trac #12007 is a case in point.

3 years agoTestsuite: add a test for #5522 (-fliberate-case -fspec-constr)
Thomas Miedema [Wed, 25 May 2016 19:23:09 +0000 (21:23 +0200)] 
Testsuite: add a test for #5522 (-fliberate-case -fspec-constr)

3 years agoTestsuite: fix enum01/02/03 on Windows (#9399)
Thomas Miedema [Wed, 25 May 2016 15:51:26 +0000 (17:51 +0200)] 
Testsuite: fix enum01/02/03 on Windows (#9399)

3 years agoTestsuite: also normalise platform-dependent .stdout/stderr
Thomas Miedema [Wed, 25 May 2016 14:03:19 +0000 (16:03 +0200)] 
Testsuite: also normalise platform-dependent .stdout/stderr

This effectively reverses commit
429f0099ab9adfadc779ca76f3aae1c9c160fb8c (2006).

I don't see why platform-dependent .stdout/stderr files should //not//
get normalised.

It fixes T11223_link_order_a_b_2_fail on Windows, by normalising
`ghc-stage2.exe` to `ghc` when comparing stderr with .stderr-mingw32.

Reviewed by: Phyx

Differential Revision: https://phabricator.haskell.org/D2267

GHC Trac Issues: #12118

3 years agoSpelling in comments
Gabor Greif [Tue, 24 May 2016 12:10:15 +0000 (14:10 +0200)] 
Spelling in comments

3 years agoTestsuite: introduce TEST_HC_OPTS_INTERACTIVE (#11468)
Thomas Miedema [Wed, 25 May 2016 11:01:42 +0000 (13:01 +0200)] 
Testsuite: introduce TEST_HC_OPTS_INTERACTIVE (#11468)

Refactoring only.

3 years agoRTS: simplify read_heap_profiling_flag
Thomas Miedema [Thu, 19 May 2016 08:20:15 +0000 (10:20 +0200)] 
RTS: simplify read_heap_profiling_flag

Since 535896e58f7fc8d89a5ff34629a3471eac529d93, "args" is not mutated
anymore, so we don't need to create a temporary copy.

Reviewed by: bgamari

Differential Revision: https://phabricator.haskell.org/D2264

3 years agoFix broken links to mdo papers
Bartosz Nitka [Wed, 25 May 2016 16:25:51 +0000 (09:25 -0700)] 
Fix broken links to mdo papers

There's no guarantee that the links will work in the future.
Is there a more future-proof solution to this?

Test Plan: none

Reviewers: bgamari, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie, simonmar

Differential Revision: https://phabricator.haskell.org/D2266

3 years agoUpdate submodule vector [skip ci]
Thomas Miedema [Tue, 24 May 2016 09:26:58 +0000 (11:26 +0200)] 
Update submodule vector [skip ci]

Contains commits to let vector compile with primitive master.

3 years agoAlways use native-Haskell de/encoders for ASCII and latin1
Thomas Miedema [Tue, 24 May 2016 09:31:45 +0000 (11:31 +0200)] 
Always use native-Haskell de/encoders for ASCII and latin1

This fixes test encoding005 on Windows (#10623).

Reviewed by: austin, bgamari

Differential Revision: https://phabricator.haskell.org/D2262

3 years agoTestsuite: delete drvfail015.stderr-7.0 [skip ci]
Thomas Miedema [Tue, 24 May 2016 20:32:07 +0000 (22:32 +0200)] 
Testsuite: delete drvfail015.stderr-7.0 [skip ci]

Running the testsuite with ghc-7.0 is not supported.

3 years agoFix: #12084 deprecate old profiling flags
Seraphime Kirkovski [Tue, 24 May 2016 20:30:09 +0000 (22:30 +0200)] 
Fix: #12084 deprecate old profiling flags

Change help message so it doesn't specify -auto-all.
Make old profiling flags deprecated as they are no longer
documented.
Update Makefile and documentation accordingly.
Update release notes for ghc 8.2

Test Plan:
./verify; `ghc --help` shouldn't specify the -auto-all
flag. Furthermore `ghc -fprof -auto-all` should emit a warning

Reviewed By: thomie, austin

Differential Revision: https://phabricator.haskell.org/D2257

GHC Trac Issues: #12084

Update submodule nofib

3 years agoRuntime linker: Break m32 allocator out into its own file
Erik de Castro Lopo [Tue, 24 May 2016 09:26:56 +0000 (19:26 +1000)] 
Runtime linker: Break m32 allocator out into its own file

This makes the code a little more modular and allows the removal of some
CPP hackery. By providing dummy implementations of of the `m32_*`
functions (which simply call `errorBelch`) it means that the call sites
for these functions are syntax checked even when `RTS_LINKER_USE_MMAP`
is `0`.

Also changes some size parameter types from `unsigned int` to `size_t`.

Test Plan: Validate on Linux, OS X and Windows

Reviewers: Phyx, hsyl20, bgamari, simonmar, austin

Reviewed By: simonmar, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2237

3 years agoRemove 'deriving Typeable' statements
Ryan Scott [Tue, 24 May 2016 13:22:04 +0000 (09:22 -0400)] 
Remove 'deriving Typeable' statements

Summary:
Deriving `Typeable` has been a no-op since GHC 7.10, and now that we
require 7.10+ to build GHC, we can remove all the redundant `deriving Typeable`
statements in GHC.

Test Plan: ./validate

Reviewers: goldfire, austin, hvr, bgamari

Reviewed By: austin, hvr, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2260

3 years agoMake Arrow desugaring deterministic
Bartosz Nitka [Tue, 24 May 2016 11:44:37 +0000 (04:44 -0700)] 
Make Arrow desugaring deterministic

This kills two instances of varSetElems that turned out to be
nondeterministic. I've tried to untangle this before, but it's
a bit hard with the fixDs in the middle. Fortunately I now have
a test case that proves that we need determinism here.

Test Plan: ./validate, new testcase

Reviewers: simonpj, simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2258

GHC Trac Issues: #4012

3 years agoDocument some benign nondeterminism
Bartosz Nitka [Tue, 24 May 2016 09:56:59 +0000 (02:56 -0700)] 
Document some benign nondeterminism

I've changed the functions to their nonDet equivalents and explained
why they're OK there. This allowed me to remove foldNameSet,
foldVarEnv, foldVarEnv_Directly, foldVarSet and foldUFM_Directly.

Test Plan: ./validate, there should be no change in behavior

Reviewers: simonpj, simonmar, austin, goldfire, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2244

GHC Trac Issues: #4012

3 years agoAdd support for unicode TH quotes (#11743)
Josh Price [Tue, 24 May 2016 10:35:21 +0000 (12:35 +0200)] 
Add support for unicode TH quotes (#11743)

I've also added cases for `IToparenbar` and `ITcparenbar` (aka banana
brackets) to `isUnicode`.

Document unicode TH quote alternatives (#11743)

Test Plan: ./validate

Reviewers: austin, goldfire, bgamari

Reviewed By: bgamari

Subscribers: thomie, mpickering

Differential Revision: https://phabricator.haskell.org/D2185

GHC Trac Issues: #11743

3 years agoSpelling
Gabor Greif [Tue, 24 May 2016 10:58:18 +0000 (12:58 +0200)] 
Spelling

3 years agoTestsuite: delete check_files_written
Thomas Miedema [Tue, 2 Feb 2016 18:07:51 +0000 (19:07 +0100)] 
Testsuite: delete check_files_written

The CHECK_FILES_WRITTEN feature is no longer necessary, since tests
don't write to the source directory anymore (#11980).

Reviewed by: bgamari

Differential Revision: https://phabricator.haskell.org/D2162

3 years agoComments only
Simon Peyton Jones [Mon, 23 May 2016 15:27:08 +0000 (16:27 +0100)] 
Comments only

3 years agoRemove unused Type.splitFunTysN
Simon Peyton Jones [Mon, 23 May 2016 09:46:47 +0000 (10:46 +0100)] 
Remove unused Type.splitFunTysN

3 years agoSpelling in comment
Simon Peyton Jones [Mon, 23 May 2016 09:46:26 +0000 (10:46 +0100)] 
Spelling in comment

3 years agoDon't split the arg types in a PatSyn signature
Simon Peyton Jones [Thu, 19 May 2016 14:02:09 +0000 (15:02 +0100)] 
Don't split the arg types in a PatSyn signature

This patch fixes Trac #11977, and #12108, rather satisfactorily
maily by deleting code!

  pattern P :: Eq a => a -> a -> Int

The idea is simply /not/ to split the bit after the '=>' into the
pattern argument types, but to keep the (a->a->Int) part
un-decomposed, in the patsig_body_ty field of a TcPatSynInfo.

There is one awkward wrinkle, which is that we can't split the
implicitly-bound type variables into existential and universal until
we know which types are arguments and which are part of the result.
So we postpone the decision until we have the declaration in hand.
See TcPatSyn Note [The pattern-synonym signature splitting rule]

3 years agoSuppress the warning about __sync_fetch_and_nand (#9678)
Thomas Miedema [Mon, 23 May 2016 22:35:33 +0000 (00:35 +0200)] 
Suppress the warning about __sync_fetch_and_nand (#9678)

3 years agoRevert "compiler/iface: compress .hi files"
Ben Gamari [Mon, 23 May 2016 13:32:12 +0000 (15:32 +0200)] 
Revert "compiler/iface: compress .hi files"

This appears to cause validation issues on,

    TEST="T11108 T9071 T11076 T7600 T7672 T8329 T10420 T10322 T8308 T4114a
    T4114c T10602 T10110 T9204 T2435 T9838 T4114d T10233 T8696 T1735 T5281
    T6056 T10134 T9580 T6018 T9762 T8103"

With compiler panics of the form,

    Compile failed (status 256) errors were:
    ghc: panic! (the 'impossible' happened)
      (GHC version 8.1.20160523 for x86_64-unknown-linux):
            Binary.readBinMem: decompression failed
    CallStack (from HasCallStack):
      error, called at compiler/utils/Binary.hs:192:16 in ghc:Binary

    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

This reverts commit d9cb7a8a94daa4d20aa042cd053e20b491315633.

3 years agotestsuite: Update max_bytes_used for T4029
Ben Gamari [Mon, 23 May 2016 12:41:44 +0000 (14:41 +0200)] 
testsuite: Update max_bytes_used for T4029

3 years agoFix build by removing unused import.
Matthew Pickering [Mon, 23 May 2016 13:53:39 +0000 (14:53 +0100)] 
Fix build by removing unused import.

3 years agoAllow unlifted types in pattern synonym result type
Matthew Pickering [Sun, 22 May 2016 10:52:26 +0000 (11:52 +0100)] 
Allow unlifted types in pattern synonym result type

Fixes #12094

Test Plan: ./validate

Reviewers: austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2255

GHC Trac Issues: #12094