1. 16 Sep, 2019 4 commits
    • Sebastian Graf's avatar
      Encode shape information in `PmOracle` · 7915afc6
      Sebastian Graf authored
      Previously, we had an elaborate mechanism for selecting the warnings to
      generate in the presence of different `COMPLETE` matching groups that,
      albeit finely-tuned, produced wrong results from an end user's
      perspective in some cases (#13363).
      The underlying issue is that at the point where the `ConVar` case has to
      commit to a particular `COMPLETE` group, there's not enough information
      to do so and the status quo was to just enumerate all possible complete
      sets nondeterministically.  The `getResult` function would then pick the
      outcome according to metrics defined in accordance to the user's guide.
      But crucially, it lacked knowledge about the order in which affected
      clauses appear, leading to the surprising behavior in #13363.
      In !1010 we taught the term oracle to reason about literal values a
      variable can certainly not take on. This MR extends that idea to
      `ConLike`s and thereby fixes #13363: Instead of committing to a
      particular `COMPLETE` group in the `ConVar` case, we now split off the
      matching constructor incrementally and record the newly covered case as
      a refutable shape in the oracle. Whenever the set of refutable shapes
      covers any `COMPLETE` set, the oracle recognises vacuosity of the
      uncovered set.
      This patch goes a step further: Since at this point the information
      in value abstractions is merely a cut down representation of what the
      oracle knows, value abstractions degenerate to a single `Id`, the
      semantics of which is determined by the oracle state `Delta`.
      Value vectors become lists of `[Id]` given meaning to by a single
      `Delta`, value set abstractions (of which the uncovered set is an
      instance) correspond to a union of `Delta`s which instantiate the
      same `[Id]` (akin to models of formula).
      Fixes #11528 #13021, #13363, #13965, #14059, #14253, #14851, #15753, #17096, #17149
      Metric Decrease:
    • Sylvain Henry's avatar
    • Sylvain Henry's avatar
      Fix Hadrian build with Stack (#17189) · 7208160d
      Sylvain Henry authored
      Broken by 2b37a79d
    • Ben Gamari's avatar
      Rename GHC.StgToCmm.Con -> GHC.StgToCmm.DataCon · cf7e78a3
      Ben Gamari authored
      Incredibly, Windows disallows the manipulation of any file matching
      Con(\..*)?. The `GHC.StgToCmm.Con` was introduced in the renamings in
      447864a9, breaking the Windows build. Work around this by renaming it to
      Fixes #17187.
  2. 14 Sep, 2019 1 commit
  3. 13 Sep, 2019 10 commits
  4. 12 Sep, 2019 5 commits
  5. 11 Sep, 2019 8 commits
    • Tamar Christina's avatar
      Windows: make openTempFile fully atomic. · 3a7d3923
      Tamar Christina authored
    • Ömer Sinan Ağacan's avatar
      Refactor bad coercion checking in a few places · c76cc0c6
      Ömer Sinan Ağacan authored
      We do bad coercion checking in a few places in the compiler, but they
      all checked it differently:
      - CoreToStg.coreToStgArgs:
        Disallowed lifted-to-unlifted, disallowed changing prim reps even when
        the sizes are the same.
      - StgCmmExpr.cgCase:
        Checked primRepSlot equality. This disallowed Int to Int64 coercions
        on 64-bit systems (and Int to Int32 on 32-bit) even though those are
      - CoreLint:
        Only place where we do this right. Full rules are explained in Note
        [Bad unsafe coercion].
      This patch implements the check explained in Note [Bad unsafe coercion]
      in CoreLint and uses it in CoreToStg.coreToStgArgs and
      This fixes #16952 and unblocks !1381 (which fixes #16893).
      This is the most conservative and correct change I came up with that
      fixes #16952.
      One remaining problem with coercion checking is that it's currently done
      in seemingly random places. What's special about CoreToStg.coreToStgArgs
      and StgCmmExpr.cgCase? My guess is that adding assertions to those
      places caught bugs before so we left assertions in those places. I think
      we should remove these assertions and do coercion checking in CoreLint
      and StgLint only (#17041).
    • Ben Gamari's avatar
      SetLevels: Fix potential panic in lvlBind · 7ef6fe8f
      Ben Gamari authored
      3b31a94d introduced a use of isUnliftedType which can panic in the case
      of levity-polymorphic types. Fix this by introducing mightBeUnliftedType
      which returns whether the type is *guaranteed* to be lifted.
    • John Ericson's avatar
      Remove dead `ncgDebugIsOn` and `NCG_DEBUG` · d9e637df
      John Ericson authored
      Haven't been used since 16206a66.
    • Luke Lau's avatar
      Bump Hadrian's QuickCheck dependency · df6fbe03
      Luke Lau authored
    • Peter Trommler's avatar
      testsuite: check for RTS linker · 58569a5b
      Peter Trommler authored
      Fixes #16833
    • John Ericson's avatar
      Remove COMPILING_GHC · 7032a913
      John Ericson authored
      It is no longer used. I guess we are sharing fewer headers with the RTS
      than the comment claims. That's a relief!
    • Niklas Hambüchen's avatar
      linker: Move -optl flags to end of linker invocation. · 60c26403
      Niklas Hambüchen authored
      Until now, giving `-optl` linker flags to `ghc` on the command line placed
      them in the wrong place in the `ld` command line:
      They were given before all the Haskell libararies, when they should appear after.
      Most linkers like `ld.bfd` and `ld.gold`, but not the newer LLVM `lld`, work in
      a way where the order of `-l` flags given matters; earlier `-lmylib1` flags are
      supposed to create "holes" for linker symbols that are to be filled with later
      `lmylib2` flags that "fill the holes" for these symbols.
      As discovered in
      the `-optl` flags appeared before e.g. the
      flags that GHC added at the very end.
      Haskell libraries typically depend on C libraries, so `-lHS*` flags will create
      holes for the C libraries to fill in, but that only works when those libraries'
      `-l` flags are given **after** the `-lHS*` flags; until now they were given
      before, which was wrong.
      This meant that Cabal's `--ld-options` flag and `ld-options` `.cabal` file field
      were pretty ineffective, unless you used the `--ld-option=--start-group` hack as
      (https://github.com/haskell/cabal/pull/5451#issuecomment-406761676) that
      convinces the classical linkers to not be dependent on the order of linker flags
      This commit fixes the problem by simply flipping the order, putting `-optl`
      flags at the end, after Haskell libraries.
      The code change is effectively only `args1 ++ args` -> `args ++ args1`
      but the commit also renames the variables for improved clarity.
      Simple way to test it:
          ghc --make Main.hs -fforce-recomp -v -optl-s
      on a `Main.hs` like:
          import qualified Data.Set as Set
          main = print $ Set.fromList "hello"
  6. 09 Sep, 2019 6 commits
    • Sylvain Henry's avatar
      Module hierarchy: StgToCmm (#13009) · 447864a9
      Sylvain Henry authored
      Add StgToCmm module hierarchy. Platform modules that are used in several
      other places (NCG, LLVM codegen, Cmm transformations) are put into
    • Ryan Scott's avatar
      Replace queryCygwinTerminal with Win32's isMinTTYHandle · 270fbe85
      Ryan Scott authored
      `SysTools.Terminal.queryCygwinTerminal` now exists in the `Win32`
      library under the name `isMinTTYHandle` since `Win32-`.
      (GHC 8.4.4 ships with `Win32-`, so this is well within GHC's
      support window.) We can therefore get replace `queryCygwinTerminal`
      with `isMinTTYHandle` and delete quite a bit of code from
      `SysTools.Terminal` in the process.
      Along the way I needed to replace some uses of `#if defined x` with
      `#if defined(x)` to please the CI linters.
    • Daniel Gröber (dxld)'s avatar
      Update FastString docstrings · f5e2fde4
      Daniel Gröber (dxld) authored
      1) FastStrings are always UTF-8 encoded now.
      2) Clarify what is meant by "hashed"
      3) Add mention of lazy z-enc
    • Daniel Gröber (dxld)'s avatar
      Use lazyness for FastString's z-encoding memoization · 4cf91d1a
      Daniel Gröber (dxld) authored
      Having an IORef in FastString to memoize the z-encoded version is
      unecessary because there is this amazing thing Haskell can do natively,
      it's called "lazyness" :)
      We simply remove the UNPACK and strictness annotations from the constructor
      field corresponding to the z-encoding, making it lazy, and store the
      (pure) z-encoded string there.
      The only complication here is 'hasZEncoding' which allows cheking if a
      z-encoding was computed for a given string. Since this is only used for
      compiler performance statistics though it's not actually necessary to have
      the current per-string granularity.
      Instead I add a global IORef counter to the FastStringTable and use
      unsafePerformIO to increment the counter whenever a lazy z-encoding is
    • Moritz Kiefer's avatar
      Fix GHC version guard for Int32Rep/Word32Rep · d0b45ac6
      Moritz Kiefer authored
      Those constructors have been added after GHC 8.8. The version guards
      in `binary` are correct, see https://github.com/kolmodin/binary/pull/167/files.
    • Ömer Sinan Ağacan's avatar
      Add a new flag -dno-typeable-binds for debugging · 51379b89
      Ömer Sinan Ağacan authored
      See the user manual entry -- this helps when debugging as generated Core
      gets smaller without these bindings.
  7. 07 Sep, 2019 2 commits
    • Alp Mestanogullari's avatar
    • Ömer Sinan Ağacan's avatar
      Minor refactoring in deriveConstants · 821bece9
      Ömer Sinan Ağacan authored
      Mainly we now generate this
          data PlatformConstants = PlatformConstants {
                pc_CONTROL_GROUP_CONST_291 :: Int,
                pc_STD_HDR_SIZE :: Int,
                pc_PROF_HDR_SIZE :: Int,
                pc_BLOCK_SIZE :: Int,
      instead of
          data PlatformConstants = PlatformConstants {
              pc_platformConstants :: ()
              , pc_CONTROL_GROUP_CONST_291 :: Int
              , pc_STD_HDR_SIZE :: Int
              , pc_PROF_HDR_SIZE :: Int
              , pc_BLOCK_SIZE :: Int
      The first field has no use and according to (removed) comments it was to
      make code generator's work easier.. if anything this version is simpler
      because it has less repetition (the commas in strings are gone).
  8. 05 Sep, 2019 2 commits
  9. 02 Sep, 2019 2 commits