[Git][ghc/ghc][wip/T27212] 7 commits: Consolidate all CPU feature handling
Simon Peyton Jones pushed to branch wip/T27212 at Glasgow Haskell Compiler / GHC Commits: 54cf3c1e by sheaf at 2026-11-03T07:00:23-05:00 Consolidate all CPU feature handling This commit introduces GHC.Platform.CpuFeatures which consolidates all of the logic for implications between CPU feature flags (mainly X86): - DynFlags now only records the set of -m<feature> flags that were passed, as an EnumSet CpuFeature. That keeps it a simple record of the flags the user passed, with no post-processing. - GHC.Platform.CpuFeatures.initCpuFeatures turns this set into a CpuFeatures value, applying all implications and the per-architecture baseline. This is the single home for all of the feature implication logic. Some datatypes were reworked to better reflect the implication structure in the types, e.g. SseAvxVersion has a strategically placed 'FMA' boolean. - The NCG, LLVM backend, StgToCmm, CPP defines and LLVM -mattr flags all consult CpuFeatures, via targetCpuFeatures. See Note [CPU features], which replaces Note [Implications between X86 CPU feature flags]. Behaviour changes: - x86 feature flags (-msse3, -mavx, -mavx512*, -mgfni, ...) passed when targeting a non-x86 architecture no longer cause x86 CPP macros (__SSE3__, __AVX512BW__, __GFNI__, ...) to be defined, nor x86 attributes to be passed to LLVM. - Error messages reported when required CPU features are not enabled now print out the minimal set of flags required (e.g. "-mavx512vl" rather than "-mavx512f -mavx512vl"). - - - - - 9af64305 by Luite Stegeman at 2026-11-03T07:01:23-05:00 rts: move stack check to the start of the stg_unpack_cstring thunks fixes a deadlock see #27272 - - - - - a2208b21 by Simon Jakobi at 2026-11-03T07:02:05-05:00 Cmm: exclude the entry block from common block elimination a1d8139054c had fixed #27722 only partially, because it didn't prevent elimination of the entry block in later rounds, where the entry block is no longer guaranteed to come first. To close this loophole, we exclude the entry block from the CBE merge logic. See Note [Retain entry block during common block elimination] for details. This also deletes a misleading comment regarding unreachable blocks: the control-flow optimiser doesn't actually guarantee that no unreachable blocks reach CBE. Fixes #27722. Assisted-by: Claude Fable 5.1 - - - - - 37ad4710 by Alan Zimmerman at 2026-11-03T07:02:46-05:00 EPA: Use AnnList for GADT declarations Continuing the process of using AnnList to capture parser layout - - - - - 3cf8c152 by Simon Peyton Jones at 2026-11-03T16:32:20+00:00 Use a different herald for -ddump-simpl-trace ... so that we can more easily skip the high-volume ones - - - - - c7130c25 by Simon Peyton Jones at 2026-11-03T16:32:40+00:00 Update eta-reduction documentation; ignore multiplicities Triggered by #27212, this patch does several related things: * Update documentation about eta expansion and reduction, especially * Make it clear in `findRhsArity` that we eta expand only to increase `exprArity`, not `manifestArity`. (The latter was a misconception of #27212.) * Relabel the criteria in Note [Eta reduction soundness] as (EtaA), (EtaS), (EtaR), (EtaE), (EtaT), (EtaJ), (EtaB), (EtaW), fix references to them (including stale references to a non-existent Note [Eta reduction makes sense]), and add historical notes (EtaMult) and (EtaBot). * Refactor GHC.Core.Opt.Arity.tryEtaReduce, which was hard to understand. New code is simpler and more efficient. * As part of this refactor I dropped the tricky checks on multiplicity, which sometimes disabled eta-reduction. Note [Linting linearity] in GHC.Core.Lint already said that we don't try to preserve linearity when doing eta-reduction, so the change here just executs that claim. - - - - - 6fed2d5a by Simon Peyton Jones at 2026-11-03T16:32:40+00:00 Update comments and user manual This commit addresses the comment-related suggestions in #27973 - - - - - 64 changed files: - changelog.d/T27722-cbe-entry-block.md - + changelog.d/caf-deadlock-27272 - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Config.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/TyCo/Make.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Driver/Config/CmmToAsm.hs - compiler/GHC/Driver/Config/CmmToLlvm.hs - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Platform.hs - + compiler/GHC/Platform/CpuFeatures.hs - compiler/GHC/StgToCmm/Config.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Cpp.hs - compiler/GHC/Utils/Logger.hs - compiler/Language/Haskell/Syntax/Binds/InlinePragma.hs - compiler/ghc.cabal.in - docs/users_guide/debug-info.rst - docs/users_guide/using-optimisation.rst - libraries/containers - rts/StgStdThunks.cmm - + testsuite/tests/cmm/should_run/T27722.hs - + testsuite/tests/cmm/should_run/T27722_cmm.cmm - testsuite/tests/cmm/should_run/all.T - testsuite/tests/count-deps/CountDepsParser.stdout - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T24221.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/parser/should_compile/T20452.stderr - testsuite/tests/printer/T18791.stderr - + testsuite/tests/rts/T27272.hs - + testsuite/tests/rts/T27272_gen.py - testsuite/tests/rts/all.T - testsuite/tests/simplCore/should_compile/T24726.stderr - utils/check-exact/ExactPrint.hs - utils/hsc2hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea6c76cd93eee088c50f5c9120383e9... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea6c76cd93eee088c50f5c9120383e9... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Simon Peyton Jones (@simonpj)