Skip to content
Snippets Groups Projects
  1. Oct 18, 2024
    • Cheng Shao's avatar
      compiler: fix -ddump-cmm-raw when compiling .cmm · 07bd4e6c
      Cheng Shao authored
      This patch fixes missing -ddump-cmm-raw output when compiling .cmm,
      which is useful for debugging cmm related codegen issues.
      
      (cherry picked from commit 6346c669)
      (cherry picked from commit e5a1dd43)
      07bd4e6c
    • Cheng Shao's avatar
      compiler: remove ArchWasm32 special case in cmmDoCmmSwitchPlans · 39bdb0e5
      Cheng Shao authored
      This patch removes special consideration for ArchWasm32 in
      cmmDoCmmSwitchPlans, which means the compiler will now disable
      cmmImplementSwitchPlans for wasm unreg backend, just like unreg
      backend of other targets. We enabled it in the past to workaround some
      compile-time panic in older versions of LLVM, but those panics are no
      longer present, hence no need to keep this workaround.
      
      (cherry picked from commit bf0737c0)
      (cherry picked from commit 8bd28cf2)
      39bdb0e5
    • Cheng Shao's avatar
      driver: build C/C++ with -ffunction-sections -fdata-sections when split sections is enabled · 0aee272d
      Cheng Shao authored
      When -fsplit-sections is passed to GHC, pass -ffunction-sections
      -fdata-sections to gcc/clang when building C/C++. Previously,
      -fsplit-sections was only respected by the NCG/LLVM backends, but not
      the unregisterised backend; the GHC driver did not pass
      -fdata-sections and -ffunction-sections to the C compiler, which
      resulted in excessive executable sizes.
      
      Fixes #23381.
      
      -------------------------
      Metric Decrease:
          size_hello_artifact
          size_hello_unicode
      -------------------------
      
      (cherry picked from commit 02b1f91e)
      (cherry picked from commit 74cdf564)
      0aee272d
    • Cheng Shao's avatar
      compiler: avoid saving foreign call target to local when there are no caller-save GlobalRegs · 602537bb
      Cheng Shao authored
      This patch makes the STG->Cmm backend avoid saving foreign call target
      to local when there are no caller-save GlobalRegs.
      
      Since 321941a8, when we lower a
      foreign call, we unconditionally save the foreign call target to a
      temporary local first, then rely on cmmSink to clean it up later,
      which only happens with -fcmm-sink (implied by -O) and not in
      unoptimized code.
      
      And this is troublesome for the wasm backend NCG, which needs to infer
      a foreign call target symbol's type signature from the Cmm call site.
      Previously, the NCG has been emitting incorrect type signatures for
      unoptimized code, which happens to work with `wasm-ld` most of the
      time, but this is never future-proof against upstream toolchain
      updates, and it causes horrible breakages when LTO objects are
      included in linker input. Hence this patch.
      
      (cherry picked from commit 8dd8a076)
      (cherry picked from commit 2b2a3db8)
      602537bb
    • Cheng Shao's avatar
      compiler: enable generic cmm optimizations in wasm backend NCG · 7d991f09
      Cheng Shao authored
      This commit enables the generic cmm optimizations in other NCGs to be
      run in the wasm backend as well, followed by a late cmm control-flow
      optimization pass. The added optimizations do catch some corner cases
      not handled by the pre-NCG cmm pipeline and are useful in generating
      smaller CFGs.
      
      (cherry picked from commit c6ce242e)
      7d991f09
    • Cheng Shao's avatar
      compiler: explicitly disable PIC in wasm32 NCG · 89bc7a6d
      Cheng Shao authored
      This commit explicitly disables the ncgPIC flag for the wasm32 target.
      The wasm backend doesn't support PIC for the time being.
      
      (cherry picked from commit 87e34888)
      89bc7a6d
    • Cheng Shao's avatar
      compiler: move generic cmm optimization logic in NCG to a standalone module · 1063c756
      Cheng Shao authored
      This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module,
      GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be
      run in the wasm backend NCG code, which is defined in other modules
      that's imported by GHC.CmmToAsm, causing a cyclic dependency issue.
      
      (cherry picked from commit 6534da24)
      1063c756
  2. Oct 15, 2024
  3. Oct 14, 2024
  4. Oct 11, 2024
    • Rodrigo Mesquita's avatar
      Use symbol cache in internal interpreter too · 54a48fa8
      Rodrigo Mesquita authored and Ben Gamari's avatar Ben Gamari committed
      This commit makes the symbol cache that was used by the external
      interpreter available for the internal interpreter too.
      
      This follows from the analysis in #23415 that suggests the internal
      interpreter could benefit from this cache too, and that there is no good
      reason not to have the cache for it too. It also makes it a bit more
      uniform to have the symbol cache range over both the internal and
      external interpreter.
      
      This commit also refactors the cache into a function which is used by
      both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the
      caching logic to `lookupSymbolInDLL` too.
      54a48fa8
    • Alexis King's avatar
      linker: Avoid linear search when looking up Haskell symbols via dlsym · fc1dcd02
      Alexis King authored and Ben Gamari's avatar Ben Gamari committed
      
      See the primary Note [Looking up symbols in the relevant objects] for a
      more in-depth explanation.
      
      When dynamically loading a Haskell symbol (typical when running a splice or
      GHCi expression), before this commit we would search for the symbol in
      all dynamic libraries that were loaded. However, this could be very
      inefficient when too many packages are loaded (which can happen if there are
      many package dependencies) because the time to lookup the would be
      linear in the number of packages loaded.
      
      This commit drastically improves symbol loading performance by
      introducing a mapping from units to the handles of corresponding loaded
      dlls. These handles are returned by dlopen when we load a dll, and can
      then be used to look up in a specific dynamic library.
      
      Looking up a given Name is now much more precise because we can get
      lookup its unit in the mapping and lookup the symbol solely in the
      handles of the dynamic libraries loaded for that unit.
      
      In one measurement, the wait time before the expression was executed
      went from +-38 seconds down to +-2s.
      
      This commit also includes Note [Symbols may not be found in pkgs_loaded],
      explaining the fallback to the old behaviour in case no dll can be found
      in the unit mapping for a given Name.
      
      Fixes #23415
      
      Co-authored-by: default avatarRodrigo Mesquita <(@alt-romes)>
      (cherry picked from commit e008a19a)
      fc1dcd02
  5. Oct 10, 2024
    • Andreas Klebinger's avatar
      NCG: Fix a bug in jump shortcutting. · 44e119c9
      Andreas Klebinger authored
      When checking if a jump has more than one destination account for the
      possibility of some jumps not being representable by a BlockId.
      
      We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing
      represents non-BlockId jump destinations.
      
      Fixes #24507
      
      (cherry picked from commit 5bd8ed53)
      44e119c9
  6. Oct 04, 2024
    • Hannes Siebenhandl's avatar
      Escape multiple arguments in the settings file · 7e5f2ac0
      Hannes Siebenhandl authored and Ben Gamari's avatar Ben Gamari committed
      Uses responseFile syntax.
      
      The issue arises when GHC is installed on windows into a location that
      has a space, for example the user name is 'Fake User'.
      The $topdir will also contain a space, consequentially.
      When we resolve the top dir in the string `-I$topdir/mingw/include`,
      then `words` will turn this single argument into `-I/C/Users/Fake` and
      `User/.../mingw/include` which trips up the flag argument parser of
      various tools such as gcc or clang.
      We avoid this by escaping the $topdir before replacing it in
      `initSettngs`.
      Additionally, we allow to escape spaces and quotation marks for
      arguments in `settings` file.
      
      Add regression test case to count the number of options after variable
      expansion and argument escaping took place.
      Additionally, we check that escaped spaces and double quotation marks are
      correctly parsed.
      
      (cherry picked from commit 31bf85ee)
      (cherry picked from commit d74ffbbb)
      7e5f2ac0
    • Simon Peyton Jones's avatar
      Update the unification count in wrapUnifierX · 3ff6bbbe
      Simon Peyton Jones authored and Ben Gamari's avatar Ben Gamari committed
      Omitting this caused type inference to fail in #24146.
      This was an accidental omision in my refactoring of the
      equality solver.
      3ff6bbbe
    • Andreas Klebinger's avatar
      Fix ffi callbacks with >6 args and non-64bit args. · 47182b77
      Andreas Klebinger authored
      Check for ptr/int arguments rather than 64-bit width arguments when counting
      integer register arguments.
      The old approach broke when we stopped using exclusively W64-sized types to represent
      sub-word sized integers.
      
      Fixes #24314
      
      (cherry picked from commit de589554)
      47182b77
  7. Sep 30, 2024
  8. Sep 29, 2024
Loading