1. 01 Feb, 2023 4 commits
  2. 31 Jan, 2023 15 commits
    • Ben Gamari's avatar
      nativeGen/AArch64: Fix graph-colouring allocator · 7566fd9d
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Previously various `Instr` queries used by the graph-colouring allocator
      failed to handle a few pseudo-instructions. This manifested in compiler
      panicks while compiling `SHA`, which uses `-fregs-graph`.
      
      Fixes #22798.
      7566fd9d
    • Ben Gamari's avatar
      nativeGen: Teach graph-colouring allocator that x18 is unusable · 30989d13
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Previously trivColourable for AArch64 claimed that at 18 registers were
      trivially-colourable. This is incorrect as x18 is reserved by the platform on
      AArch64/Darwin.
      
      See #22798.
      30989d13
    • Ben Gamari's avatar
      nativeGen/AArch64: Fix debugging output · be417a47
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Previously various panics would rely on a half-written Show
      instance, leading to very unhelpful errors. Fix this.
      
      See #22798.
      be417a47
    • sheaf's avatar
      Revert "Cmm Lint: relax SIMD register assignment check" · 78b99430
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This reverts commit 3be48877, which weakened a Cmm Lint check involving
      SIMD vectors. Now that we keep track of the type a global register is
      used at, we can restore the original stronger check.
      78b99430
    • sheaf's avatar
      Cmm: track the type of global registers · 5618fc21
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This patch tracks the type of Cmm global registers. This is needed
      in order to lint uses of polymorphic registers, such as SIMD vector
      registers that can be used both for floating-point and integer values.
      
      This changes allows us to refactor VanillaReg to not store VGcPtr,
      as that information is instead stored in the type of the usage of the
      register.
      
      Fixes #22297
      5618fc21
    • Krzysztof Gogolewski's avatar
      Support "unusable UNPACK pragma" warning with -O0 · f83374f8
      Krzysztof Gogolewski authored and Marge Bot's avatar Marge Bot committed
      Fixes #11270
      f83374f8
    • Simon Peyton Jones's avatar
      Improve exprOkForSpeculation for classops · a83c810d
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch fixes #22745 and #15205, which are about GHC's
      failure to discard unnecessary superclass selections that
      yield coercions.  See
        GHC.Core.Utils Note [exprOkForSpeculation and type classes]
      
      The main changes are:
      
      * Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and
        refer to it
      
      * Define new function isTerminatingType, to identify those
        guaranteed-terminating dictionary types.
      
      * exprOkForSpeculation has a new (very simple) case for ClassOpId
      
      * ClassOpId has a new field that says if the return type is
        an unlifted type, or a terminating type.
      
      This was surprisingly tricky to get right.  In particular note
      that unlifted types are not terminating types; you can write an
      expression of unlifted type, that diverges.  Not so for dictionaries
      (or, more precisely, for the dictionaries that GHC constructs).
      
      Metric Decrease:
          LargeRecord
      a83c810d
    • doyougnu's avatar
      FastString: add fastStringToShorText · 765fab98
      doyougnu authored and Marge Bot's avatar Marge Bot committed
      765fab98
    • doyougnu's avatar
      InfoTableProv: ShortText --> ShortByteString · 19c1fbcd
      doyougnu authored and Marge Bot's avatar Marge Bot committed
      19c1fbcd
    • Joachim Breitner's avatar
      Update note at beginning of GHC.Builtin.NAmes · 085a6db6
      Joachim Breitner authored and Marge Bot's avatar Marge Bot committed
      some things have been renamed since it was written, it seems.
      085a6db6
    • Matthew Pickering's avatar
      Fixes for cabal-reinstall CI job · 7cbdaad0
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      * Allow filepath to be reinstalled
      * Bump some version bounds to allow newer versions of libraries
      * Rework testing logic to avoid "install --lib" and package env files
      
      Fixes #22344
      7cbdaad0
    • Simon Peyton Jones's avatar
      Take account of loop breakers in specLookupRule · d0f34f25
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      The key change is that in GHC.Core.Opt.Specialise.specLookupRule
      we were using realIdUnfolding, which ignores the loop-breaker
      flag.  When given a loop breaker, rule matching therefore
      looped infinitely -- #22802.
      
      In fixing this I refactored a bit.
      
      * Define GHC.Core.InScopeEnv as a data type, and use it.
        (Previously it was a pair: hard to grep for.)
      
      * Put several functions returning an IdUnfoldingFun into
        GHC.Types.Id, namely
           idUnfolding
           alwaysActiveUnfoldingFun,
           whenActiveUnfoldingFun,
           noUnfoldingFun
        and use them.  (The are all loop-breaker aware.)
      d0f34f25
    • Ryan Scott's avatar
      Fix two bugs in TypeData TH reification · 2f145052
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      This patch fixes two issues in the way that `type data` declarations were
      reified with Template Haskell:
      
      * `type data` data constructors are now properly reified using `DataConI`.
        This is accomplished with a special case in `reifyTyCon`. Fixes #22818.
      
      * `type data` type constructors are now reified in `reifyTyCon` using
        `TypeDataD` instead of `DataD`. Fixes #22819.
      2f145052
    • Ryan Scott's avatar
      Handle `type data` properly in tyThingParent_maybe · 20598ef6
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      Unlike most other data constructors, data constructors declared with `type data`
      are represented in `TyThing`s as `ATyCon` rather than `ADataCon`. The `ATyCon`
      case in `tyThingParent_maybe` previously did not consider the possibility of
      the underlying `TyCon` being a promoted data constructor, which led to the
      oddities observed in #22817. This patch adds a dedicated special case in
      `tyThingParent_maybe`'s `ATyCon` case for `type data` data constructors to fix
      these oddities.
      
      Fixes #22817.
      20598ef6
    • Andreas Klebinger's avatar
      ghc-the-library: Retain cafs in both static in dynamic builds. · 08ba8720
      Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
      We use keepCAFsForGHCi.c to force -fkeep-cafs behaviour by using a
      __attribute__((constructor)) function.
      
      This broke for static builds where the linker discarded the object file
      since it was not reverenced from any exported code. We fix this by
      asserting that the flag is enabled using a function in the same module
      as the constructor. Which causes the object file to be retained by the
      linker, which in turn causes the constructor the be run in static builds.
      
      This changes nothing for dynamic builds using the ghc library. But causes
      static to also retain CAFs (as we expect them to).
      
      Fixes #22417.
      
      -------------------------
      Metric Decrease:
          T21839r
      -------------------------
      08ba8720
  3. 30 Jan, 2023 2 commits
    • Cheng Shao's avatar
      compiler: fix data section alignment in the wasm NCG · da468391
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      Previously we tried to lower the alignment requirement as far as
      possible, based on the section kind inferred from the CLabel. For info
      tables, .p2align 1 was applied given the GC should only need the
      lowest bit to tag forwarding pointers. But this would lead to
      unaligned loads/stores, which has a performance penalty even if the
      wasm spec permits it. Furthermore, the test suite has shown memory
      corruption in a few cases when compacting gc is used.
      
      This patch takes a more conservative approach: all data sections
      except C strings align to word size.
      da468391
    • Ben Gamari's avatar
      nativeGen: Disable asm-shortcutting on Darwin · 8bed166b
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Asm-shortcutting may produce relative references to symbols defined in
      other compilation units. This is not something that MachO relocations
      support (see #21972). For this reason we disable the optimisation on
      Darwin. We do so without a warning since this flag is enabled by `-O2`.
      
      Another way to address this issue would be to rather implement a
      PLT-relocatable jump-table strategy. However, this would only benefit
      Darwin and does not seem worth the effort.
      
      Closes #21972.
      8bed166b
  4. 28 Jan, 2023 12 commits
    • Cheng Shao's avatar
      compiler: properly handle ForeignHints in the wasm NCG · 78c07219
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      Properly handle ForeignHints of ccall arguments/return value, insert
      sign extends and truncations when handling signed subwords. Fixes #22852.
      78c07219
    • Bodigrim's avatar
      Assorted changes to avoid Data.List.{head,tail} · 2b62739d
      Bodigrim authored and Marge Bot's avatar Marge Bot committed
      2b62739d
    • Cheng Shao's avatar
      compiler: fix lowering of CmmBlock in the wasm NCG · 6ea2aa02
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      The CmmBlock datacon was not handled in lower_CmmLit, since I thought
      it would have been eliminated after proc-point splitting. Turns out it
      still occurs in very rare occasions, and this patch is needed to fix
      T9329 for wasm.
      6ea2aa02
    • Cheng Shao's avatar
      compiler: fix subword literal narrowing logic in the wasm NCG · 7e11c6dc
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch fixes the W8/W16 literal narrowing logic in the wasm NCG,
      which used to lower it to something like i32.const -1, without
      properly zeroing-out the unused higher bits. Fixes #22608.
      7e11c6dc
    • Andrei Borzenkov's avatar
      Convert diagnostics in GHC.Rename.Bind to proper TcRnMessage (#20115) · 50b1e2e8
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      I removed all occurrences of TcRnUnknownMessage in GHC.Rename.Bind
      module. Instead, these TcRnMessage messages were introduced:
        TcRnMultipleFixityDecls
        TcRnIllegalPatternSynonymDecl
        TcRnIllegalClassBiding
        TcRnOrphanCompletePragma
        TcRnEmptyCase
        TcRnNonStdGuards
        TcRnDuplicateSigDecl
        TcRnMisplacedSigDecl
        TcRnUnexpectedDefaultSig
        TcRnBindInBootFile
        TcRnDuplicateMinimalSig
      50b1e2e8
    • Alex D's avatar
      CApiFFI: add ConstPtr for encoding const-qualified pointer return types · b3a3534b
      Alex D authored and Marge Bot's avatar Marge Bot committed
      Previously, when using `capi` calling convention in foreign declarations,
      code generator failed to handle const-cualified pointer return types.
      This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers`
      warning.
      
      `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases -
      special treatment was put in place to generate appropritetly qualified C
      wrapper that no longer triggers the above mentioned warning.
      
      Fixes #22043.
      b3a3534b
    • Ben Gamari's avatar
      Revert "CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)" · 56c1bd98
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      This reverts commit 99aca26b.
      56c1bd98
    • Simon Peyton Jones's avatar
      Accept an orphan declaration (sadly) · 15750d33
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This accepts the orphan type family instance
      
        type instance DsForeignHook = ...
      
      in GHC.HsToCore.Types.
      
      See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks
      15750d33
    • Simon Peyton Jones's avatar
      Avoid orphans in the parser · 0f25a13b
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This moves Anno instances for PatBuilder from GHC.Parser.PostProcess
      to GHC.Parser.Types to avoid orphans.
      0f25a13b
    • Simon Peyton Jones's avatar
      Avoid orphans in STG · faa300fb
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch removes some orphan instances in the STG namespace
      by introducing the GHC.Stg.Lift.Types module, which allows various
      type family instances to be moved to GHC.Stg.Syntax, avoiding orphan
      instances.
      faa300fb
    • Simon Peyton Jones's avatar
      Report family instance orphans correctly · 46a53bb2
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This fixes the fact that we were not reporting orphan family instances
      at all. The fix here is easy, but touches a bit of code. I refactored
      the code to be much more similar to the way that class instances are done:
      
         - Add a fi_orphan field to FamInst, like the is_orphan field in ClsInst
         - Make newFamInst initialise this field, just like newClsInst
         - And make newFamInst report a warning for an orphan, just like newClsInst
         - I moved newFamInst from GHC.Tc.Instance.Family to GHC.Tc.Utils.Instantiate,
           just like newClsInst.
         - I added mkLocalFamInst to FamInstEnv, just like mkLocalClsInst in InstEnv
         - TcRnOrphanInstance and SuggestFixOrphanInstance are now parametrised
           over class instances vs type/data family instances.
      
      Fixes #19773
      46a53bb2
    • Simon Peyton Jones's avatar
      Detect family instance orphans correctly · 638277ba
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      We were treating a type-family instance as a non-orphan if there
      was a type constructor on its /right-hand side/ that was local. Boo!
      Utterly wrong. With this patch, we correctly check the /left-hand side/
      instead!
      
      Fixes #22717
      638277ba
  5. 27 Jan, 2023 2 commits
    • Andrei Borzenkov's avatar
      Replace errors from badOrigBinding with new one (#22839) · 2648c09c
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      Problem: in 02279a9c the type-level [] syntax was changed from a built-in name
      to an alias for the GHC.Types.List constructor. badOrigBinding assumes that if
      a name is not built-in then it must have come from TH quotation, but this is
      not necessarily the case with [].
      
      The outdated assumption in badOrigBinding leads to incorrect error messages.
      This code:
        data []
      Fails with "Cannot redefine a Name retrieved by a Template Haskell quote: []"
      
      Unfortunately, there is not enough information in RdrName to directly determine
      if the name was constructed via TH or by the parser, so this patch changes the
      error message instead.
      
      It unifies TcRnIllegalBindingOfBuiltIn and TcRnNameByTemplateHaskellQuote
      into a new error TcRnBindingOfExistingName and changes its wording to avoid
      guessing the origin of the name.
      2648c09c
    • Richard Eisenberg's avatar
      Do newtype unwrapping in the canonicaliser and rewriter · 3e827c3f
      Richard Eisenberg authored and Marge Bot's avatar Marge Bot committed
      See Note [Unwrap newtypes first], which has the details.
      
      Close #22519.
      3e827c3f
  6. 26 Jan, 2023 5 commits