1. 15 Jan, 2017 6 commits
    • Erik de Castro Lopo's avatar
      LLVM: Tweak TBAA metadata codegen · 9d67f04d
      Erik de Castro Lopo authored
      This change is requred for llvm 4.0. GHC doesn't use that version yet,
      but this change is just as valid for versions eariler than 4.0.
      
      Two changes needed:
      
      * Previously, GHC defined a `topN` node in the TBAA heiarchy and some IR
        instructions referenced that node. With LLVM 4.0 the root node can no
        longer be referenced by IR instructions, so we introduce a new element
        `rootN` and make `topN` a child of that.
      
      * Previously the root TBAA node was rendered as "!0 = !{!"root", null}".
        With LLVM 4.0 that needs to be "!0 = !{!"root"}" which is also
        accepted by earlier versions.
      
      Test Plan: Build with quick-llvm BuildFlavor and run tests
      
      Reviewers: bgamari, drbo, austin, angerman, michalt, DemiMarie
      
      Reviewed By: DemiMarie
      
      Subscribers: mpickering, DemiMarie, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2975
      9d67f04d
    • Matthew Pickering's avatar
      Revert "Record evaluated-ness on workers and wrappers" · 1f48fbc9
      Matthew Pickering authored
      This reverts commit 6b976eb8.
      
      Ben, Ryan and I decided to revert this for now due to T12234 failing
      and causing all harbormaster builds to fail.
      1f48fbc9
    • Ryan Scott's avatar
      Improve access violation reporting on Windows · c13151e5
      Ryan Scott authored
      Summary:
      This patch is courtesy of @awson.
      
      Currently, whenever GHC catches a segfault on Windows, it simply reports the
      somewhat uninformative message
      `Segmentation fault/access violation in generated code`. This patch adds to
      the message the type of violation (read/write/dep) and location information,
      which should help debugging segfaults in the future.
      
      Fixes #13108.
      
      Test Plan: Build on Windows
      
      Reviewers: austin, erikd, bgamari, simonmar, Phyx
      
      Reviewed By: bgamari, Phyx
      
      Subscribers: awson, thomie, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2969
      
      GHC Trac Issues: #13108
      c13151e5
    • Ryan Scott's avatar
      Properly introduce CTimer to System.Posix.Types · db91d17e
      Ryan Scott authored
      Summary:
      In ffc23270, an attempt was made at
      adding a Haskell wrapper around the C `timer_t` type. Unfortunately, GHC's
      autoconf macros weren't sophisticated enough at the time to properly detect
      that `timer_t` is represented by a `void *` (i.e., a pointer) on most OSes.
      
      This is a second attempt at `CTimer`, this time using `AC_COMPILE_IFELSE` to
      detect if a type is a pointer type by compiling the following program:
      
      ```
      type val;
      *val;
      ```
      
      This also only derives a small subset of class instances for `CTimer` that are
      known to be compatible with `Ptr` using a new `OPAQUE_TYPE_WITH_CTYPE` macro.
      
      Test Plan: ./validate
      
      Reviewers: erikd, hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2952
      
      GHC Trac Issues: #12795, #12998
      db91d17e
    • Tamar Christina's avatar
      Fix abort and import lib search on Windows · 331f88d0
      Tamar Christina authored
      Summary:
      Apparently `sysErrorBelch` doesn't terminate the program anymore making
      previously unreachable code now execute. If a dll is not found the error
      message we return needs to be a heap value.
      
      Secondly also allow the pattern `lib<name>` to be allowed for finding an
      import library with the name `lib<name>.dll.a`.
      
      Test Plan: ./validate, new tests T13082_good and T13082_fail
      
      Reviewers: austin, RyanGlScott, hvr, erikd, simonmar, bgamari
      
      Reviewed By: RyanGlScott, bgamari
      
      Subscribers: thomie, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2941
      
      GHC Trac Issues: #13082
      331f88d0
    • Tamar Christina's avatar
      Use latin1 code page on Windows for response files. · f63c8ef3
      Tamar Christina authored
      Summary:
      D2917 added a change that will make paths on Windows response files
      use DOS 8.3 shortnames to get around the fact that `libiberty` assumes
      a one byte per character encoding.
      
      This is actually not the problem, the actual problem is that GCC on
      Windows doesn't seem to support Unicode at all.
      
      This comes down to how unicode characters are handled between POSIX and
      Windows. On Windows, Unicode is only supported using a multibyte character
      encoding such as `wchar_t` with calls to the appropriate wide version of
      APIs (name post-fixed with the `W` character). On Posix I believe the standard
      `char` is used and based on the value it is decoded to the correct string.
      
      GCC doesn't seem to make calls to the Wide version of the Windows APIs,
      and even if it did, it's character representation would be wrong. So I
      believe GCC just does not support utf-8 paths on Windows.
      
      So the hack in D2917 is the only way to get Unicode support. The problem is
      however that `GCC` is not the only tool with this issue and we don't use response
      files for every invocation of the tools. Most of the tools probably don't support it.
      
      Furthermore, DOS 8.1 shortnames only exist when the path or file physically exists on
      disk. We pass lots of paths to GCC that don't exist yet, like the output file.
      D2917 works around this by splitting the path from the file and try shortening that.
      
      But this may not always work.
      
      In short, even if we do Unicode correctly (which we don't atm, the GCC driver we build
      uses `char` instead of `wchar_t`) we won't be able to compile using unicode paths that
      need to be passed to `GCC`. So not sure about the point of D2917.
      
      What we can do is support the most common non-ascii characters by writing the response
      files out using the `latin1` code page.
      
      Test Plan: compile + make test TEST=T12971
      
      Reviewers: austin, bgamari, erikd
      
      Reviewed By: bgamari
      
      Subscribers: thomie, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2942
      
      GHC Trac Issues: #12971
      f63c8ef3
  2. 13 Jan, 2017 6 commits
  3. 12 Jan, 2017 3 commits
    • Simon Peyton Jones's avatar
      Fix top-level constraint handling (Trac #12921) · f5f6d423
      Simon Peyton Jones authored
      Some out-of-scope errors were not being reported if anyone
      throws an un-caught exception in the TcM monad.  That led to
      
        ghc: panic! (the 'impossible' happened)
      	initTc: unsolved constraints
      
      I fixed this
      
      * Splitting captureConstraints to use an auxilliary
        tryCaptureConstraints (which never fails)
      
      * Define a new TcSimplify.captureTopConstraints (replacing
        the old TcRnMonad.captureTopConstraints), which reports
        any unsolved out-of-scope constraints before propagating
        the exception
      
      That in turn allowed me to do some tidying up of the static-constraint
      machinery, reducing duplication.
      
      Also solves #13106.
      f5f6d423
    • Simon Peyton Jones's avatar
      Small refactoring in TcErrors · 89ce9cd3
      Simon Peyton Jones authored
      No change in behaviour
      89ce9cd3
    • Gabor Greif's avatar
      Typos in manual, comments and tests · c6b04865
      Gabor Greif authored
      c6b04865
  4. 11 Jan, 2017 10 commits
    • Ryan Scott's avatar
      Add mkUserGuidePart.cabal to .gitignore · f9df77e4
      Ryan Scott authored
      Following fe75d2d4.
      f9df77e4
    • Edward Z. Yang's avatar
      501de268
    • Edward Z. Yang's avatar
      Fix handling of closed type families in Backpack. · f59aad68
      Edward Z. Yang authored
      Summary:
      A few related problems:
      
      - CoAxioms, like DFuns, are implicit and never exported,
        so we have to make sure we treat them the same way as
        DFuns: in RnModIface we need to rename references to
        them with rnIfaceImplicit and in mergeSignatures we need
        to NOT check them directly for compatibility (the
        test on the type family will do this check for us.)
      
      - But actually, we weren't checking if the axioms WERE
        consistent.  This is because we were forwarding all
        embedded CoAxiom references in the type family TyThing
        to the merged version, but that reference was what
        checkBootDeclM was using as a comparison point.
        This is similar to a problem we saw with DFuns.
      
        To fix this, I refactored the handling of implicit entities in TcIface
        for Backpack.  See Note [The implicit TypeEnv] for the gory details.
        Instead of passing the TypeEnv around explicitly, we stuffed it in
        IfLclEnv.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: bgamari, simonpj, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2928
      f59aad68
    • Edward Z. Yang's avatar
      Rewrite module signature documentation. · 8744869e
      Edward Z. Yang authored
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: none
      
      Reviewers: bgamari, simonpj, austin, goldfire
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2918
      
      GHC Trac Issues: #10262
      8744869e
    • Edward Z. Yang's avatar
      Revamp Backpack/hs-boot handling of type class signatures. · 5def07fa
      Edward Z. Yang authored
      Summary:
      A basket of fixes and improvements:
      
      - The permissible things that one can write in a type
        class definition in an hsig file has been reduced
        to encompass the following things:
      
          - Methods
          - Default method signatures (but NOT implementation)
          - MINIMAL pragma
      
        It is no longer necessary nor encouraged to specify
        that a method has a default if it is mentioned in
        a MINIMAL pragma; the MINIMAL pragma is assumed to
        provide the base truth as to what methods need to
        be implemented when writing instances of a type
        class.
      
      - Handling of default method signatures in hsig was
        previously buggy, as these identifiers were not exported,
        so we now treat them similarly to DFuns.
      
      - Default methods are merged, where methods with defaults
        override those without.
      
      - MINIMAL pragmas are merged by ORing together pragmas.
      
      - Matching has been relaxed: a method with a default can
        be used to fill a signature which did not declare the
        method as having a default, and a more relaxed MINIMAL
        pragma can be used (we check if the signature pragma
        implies the final implementation pragma, on the way
        fixing a bug with BooleanFormula.implies, see #13073)
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, bgamari, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2925
      
      GHC Trac Issues: #13041
      5def07fa
    • Edward Z. Yang's avatar
      Improve Backpack support for fixities. · e41c61fa
      Edward Z. Yang authored
      Summary:
      Two major bug-fixes:
      
          - Check that fixities match between hsig and implementation
      
          - Merge and preserve fixities when merging signatures
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: bgamari, simonpj, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2919
      
      GHC Trac Issues: #13066
      e41c61fa
    • Edward Z. Yang's avatar
      Warn if you explicitly export an identifier with warning attached. · 0bbcf76a
      Edward Z. Yang authored
      Summary:
      This won't stop people from attempting to use this identifier
      (since it is still always going to be in the export list), but
      having an explicit reference to something people shouldn't
      use is a smell, so warn about it.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2907
      0bbcf76a
    • Edward Z. Yang's avatar
      Attach warnings to non-PVP compatible uses of signatures. · 9f169bcd
      Edward Z. Yang authored
      Summary:
      If you use an inherited signature from another package in your own code,
      the only valid PVP bound you can specify for this package is an *exact*
      version bound.  This is because the signature is used both covariantly
      (it provides declarations for import) and contravariantly (it specifies
      what is required).  However, this is a bit distressing if you want to
      use a PVP-style bound that allows for upgrading a package.  So there is
      a dichotomy:
      
          1. Any signatures that come from packages with exact bounds
          (this includes, in particular, signature packages, who are
          included solely to make declarations available), can be
          used without problem by modules, but
      
          2. Any signatures that come from packages that are version
          bounded (i.e., any package that also provides modules) must
          NOT be used, because if they were used, they could break
          under a PVP policy that allows relaxations in the needed
          requirements.
      
      To help users avoid situation (2), I've added a warning to all
      signature declarations that come solely from (2).  This is not
      perfect; you might still end up relying on some type identity
      specified by a signature in a version-bounded package, but it
      should help catch major errors.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2906
      9f169bcd
    • Edward Z. Yang's avatar
      Support for using only partial pieces of included signatures. · 5f9c6d2a
      Edward Z. Yang authored
      Summary:
      Generally speaking, it's not possible to "hide" a requirement from a
      package you include, because if there is some module relying on that
      requirement, well, you can't just wish it out of existence.
      
      However, some packages don't have any modules.  For these, we can
      validly thin out requirements; indeed, this is very convenient if
      someone has published a large signature package but you only want
      some of the definitions.
      
      This patchset tweaks the interpretation of export lists in
      signatures: in particular, they no longer need to refer to
      entities that are defined locally; they range over both the current
      signature as well as any signatures that were inherited from
      signature packages (defined by having zero exposed modules.)
      
      In the process of doing this, I cleaned up a number of other
      things:
      
      * rnModIface and rnModExports now report errors that occurred
        during renaming and can propagate these to the TcM monad.
        This is important because in the current semantics, you can
        thin out a type which is referenced by a value you keep;
        in this situation, we need to error (to ensure that all
        types in signatures are rooted, so that we can determine
        their identities).
      
      * I ended up introducing a new construct 'dependency signature;
        to bkp files, to make it easier to tell if we were depending
        on a signature package.  It's not difficult for Cabal to
        figure this out (I already have a patch for it.)
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2904
      
      GHC Trac Issues: #12994
      5f9c6d2a
    • Ben Gamari's avatar
      Revert "event manager: Don't worry if attempt to wake dead manager fails" · 436aa7aa
      Ben Gamari authored
      This broke the OS X build.
      
      This reverts commit 6de76136.
      436aa7aa
  5. 10 Jan, 2017 15 commits
    • David Feuer's avatar
      Inline partially-applied wrappers · 2be364ac
      David Feuer authored
      Suppose we have
      
      ```
      data Node a = Node2 !Int a a | Node3 !Int a a a
      instance Traversable Node where
        traverse f (Node2 s x y) = Node2 s <$> f x <*> f y
        ...
      
      ```
      
      Since `Node2` is partially applied, we wouldn't inline its
      wrapper.  The result was that we'd box up the `Int#` to put
      the box in the closure passed to `fmap`. We now allow the wrapper
      to inline when partially applied, so GHC stores the `Int#`
      directly in the closure.
      
      Reviewers: rwbarton, mpickering, simonpj, austin, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2891
      
      GHC Trac Issues: #12990
      2be364ac
    • David Feuer's avatar
      Fix references in let/app invariant note · 8b15fc42
      David Feuer authored
      `mkCoreApp` and `mkCoreLet` have moved since the let/app invariant
      note was written. Update the note to reflect that change.
      
      [skip ci]
      
      Test Plan: Read
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2953
      8b15fc42
    • takano-akio's avatar
      Mark *FB functions INLINE[0] (Fixes #13001) · 09bce7ac
      takano-akio authored
      When fusion rules successfully fire, we are left with calls to
      *FB functions. They are higher-order functions, and therefore they
      often benefit from inlining. This is particularly important when
      then final consumer is a strict fold (foldl', length, etc.), because
      not inlining these functions means allocating a function closure
      for each element in the list, which often is more costly than what
      fusion eliminates.
      
      Nofib shows a slight increase in the binary size:
      
      ------------------------------------------------------------------------
             Program           Size    Allocs   Runtime   Elapsed  TotalMem
      ------------------------------------------------------------------------
         gen_regexps          -0.3%      0.0%     0.000     0.000      0.0%
              puzzle          +0.8%      0.0%     0.089     0.090      0.0%
             reptile          +0.8%     -0.0%     0.008     0.008      0.0%
      ------------------------------------------------------------------------
                 Min          -0.3%     -0.0%     -7.3%     -7.1%      0.0%
                 Max          +0.8%     +0.0%     +7.8%     +7.7%     +1.8%
      Geometric Mean          +0.0%     -0.0%     +0.2%     +0.2%     +0.0%
      ------------------------------------------------------------------------
      
      Reviewers: simonpj, austin, hvr, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2951
      
      GHC Trac Issues: #13001
      09bce7ac
    • dobenour's avatar
      Don't use the splitter on Darwin · 266a9dc4
      dobenour authored
      Test Plan: GHC CI
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2879
      266a9dc4
    • Rufflewind's avatar
      Fix terminal corruption bug and clean up SDoc interface. · 22845adc
      Rufflewind authored
      - Fix #13076 by wrapping `printDoc_` so that the terminal color is
        reset even if an exception occurs.
      
      - Add `printSDoc`, `printSDocLn`, and `bufLeftRenderSDoc` to keep `SDoc`
        values abstract (they are wrappers of `printDoc_`, `printDoc`, and
        `bufLeftRender` respectively).
      
      - Remove unused function: `printForAsm`
      
      Test Plan: manual
      
      Reviewers: RyanGlScott, austin, dfeuer, bgamari
      
      Reviewed By: dfeuer, bgamari
      
      Subscribers: dfeuer, mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2932
      
      GHC Trac Issues: #13076
      22845adc
    • rwbarton's avatar
      testsuite driver: don't append to existing output files · 35a5b603
      rwbarton authored
      If you happen to have a T1234.run.stdout file lying aroud (probably
      from before the move to running tests in temporary subdirectories)
      it gets symlinked into the T1234.run directory since its name starts
      with T1234; and then program output gets appended to the existing
      file (through the symlink). We should open the file for writing
      instead, to replace the symlink with a new file.
      
      Test Plan: tested locally, + harbormaster
      
      Reviewers: austin, Phyx, bgamari
      
      Reviewed By: Phyx, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2946
      35a5b603
    • Jon Coens's avatar
      Expose purgeObj in ObjLink · c2bd62ed
      Jon Coens authored
      Test Plan: Rebuild GHC under 7.10.2.
      
      Reviewers: niteria, simonmar, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2948
      c2bd62ed
    • Steffen Forkmann's avatar
      Fix typo in comment · b1923ed5
      Steffen Forkmann authored
      b1923ed5
    • David Feuer's avatar
      Remove tyConString · 5857dfb8
      David Feuer authored
      `tyConString` has been deprecated since GHC 7.4. It's time for it to go.
      
      Reviewers: austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2950
      
      GHC Trac Issues: #13096
      5857dfb8
    • David Feuer's avatar
      Remove deprecated InteractiveEval API · eee81994
      David Feuer authored
      Remove `RunResult(..)`, `runStmt`, and `runStmtWithLocation`.  These
      were all deprecated and documented as slated for removal in GHC 7.14,
      which I figure means 8.2.
      
      See cf7573b8 for an explanation of why
      this change was made.
      
      Reviewers: simonpj, hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2949
      
      GHC Trac Issues: #13095
      eee81994
    • Ben Gamari's avatar
      event manager: Don't worry if attempt to wake dead manager fails · 6de76136
      Ben Gamari authored
      This fixes #12038, where the TimerManager would attempt to wake up a
      manager that was already dead, resulting in setnumcapabilities001
      occassionally failing during shutdown with unexpected output on stderr.
      
      I'm frankly still not entirely confident in this solution but perhaps it
      will help to get a few more eyes on this.
      
      My hypothesis is that the TimerManager is racing:
      
        thread                   TimerManager worker
        -------                  --------------------
        requests that thread
        manager shuts down
      
                                 begins to clean up,
                                 closing eventfd
      
        calls wakeManager,
        which tries to write
        to closed eventfd
      
      To prevent this `wakeManager` will need to synchronize with the
      TimerManger worker to ensure that the worker doesn't clean up the
      `Control` while another thread is trying to send a wakeup. However, this
      would add a bit of overhead on every timer interaction, which feels
      rather costly for what is really a problem only at shutdown.  Moreover,
      it seems that the event manager (e.g.  `GHC.Event.Manager`) is also
      afflicted by a similar race.
      
      This patch instead simply tries to catch the write failure after it has
      happened and silence it in the case that the fd has vanished. It feels
      rather hacky but it seems to work.
      
      Test Plan: Run `setnumcapabilities001` repeatedly
      
      Reviewers: austin, hvr, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2926
      
      GHC Trac Issues: #12038
      6de76136
    • Chris Martin's avatar
      Add doc header to Dynamic's re-export of Typeable · fe8bc14f
      Chris Martin authored
      Data.Data and Data.Dynamic both re-export Data.Typeable with the same
      comment, though in the Data module the comment is a haddock header, and
      in Typeable it is not. I assume the inconsistency was a mistake.
      
      Reviewers: austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2923
      fe8bc14f
    • Ben Gamari's avatar
      users-guide: Produce OpenSearch description · 89d4d261
      Ben Gamari authored
      Reviewers: austin, hsyl20
      
      Reviewed By: hsyl20
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2921
      89d4d261
    • dobenour's avatar
      Enable subsections via symbols on iOS · 58e68b37
      dobenour authored
      Test Plan: GHC CI
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2915
      
      GHC Trac Issues: #11040, #13049
      58e68b37
    • johnleo's avatar
      Check that type variable does not reference itself in its kind signature · 8a76d32e
      johnleo authored
      This fixes #11592.
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari, goldfire
      
      Reviewed By: goldfire
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2914
      
      GHC Trac Issues: #11592
      8a76d32e