Sylvain Henry pushed to branch wip/andreask/cfg-fix at Glasgow Haskell Compiler / GHC Commits: 1540fd6b by Andreas Klebinger at 2026-11-17T12:15:21+01:00 x86 ncg: Track the current block in NatM to keep the CFG in sync The x86 NCG uses a CFG for code layout. When instruction selection makes new blocks (word2Float#, cmpxchg loops, 64-bit shifts on i386), it must add them to the CFG. Some sites did not. The CFG went out of sync, the layout was bad, and the register allocator panicked when it added fixup blocks (#27694, #27915). NatM now keeps the current block in its state. Combinators update the CFG and the current block together. See Note [Updating the CFG during CodeGen] in GHC.CmmToAsm.Monad. Other changes: * -dasm-lint checks that the jumps in the code and the edges in the CFG agree in both directions. This found a second desync: the CFG did not follow the jumps that allocMoreStack retargets. The new addPreentryBlock fixes it. * The code must be emitted in generation order, because the CFG records new blocks in that order. A store now generates the code of its value before the code of its address, in the order it emits them. Atomic operations take their address from the new getNonClobberedAmode, so the code of their other operands cannot clobber it. Fixes #27694, #27915 Co-authored-by: Sylvain Henry <sylvain@haskus.fr> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> - - - - - e07bdf0b by Sylvain Henry at 2026-11-17T12:15:21+01:00 x86 ncg: Maintain the CFG on i386 The i386 NCG now keeps its CFG in sync with the code (see the previous commit), so backendMaintainsCfg is now True for i386. i386 gets the CFG based code layout, dead code elimination and the -dasm-lint check, like x86-64. The compiler allocates more on i386: the CFG now goes through the register allocator, branch shortcutting and optimizeCFG, which i386 skipped before. x86-64 already does this work. Metric Increase: CoOpt_Read ManyAlternatives T10421 T12425 T12707 T13056 T13253 T13253-spj T13960 T15164 T15304 T15630 T15630a T15703 T16577 T17516 T17836 T18140 T18282 T18304 T18698a T18698b T18730 T18923 T19695 T20049 T21839c T24471 T26425 T26989 T5642 T6048 T783 T9233 T9630 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 17 changed files: - + changelog.d/27694 - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - + testsuite/tests/codeGen/should_compile/T27694.hs - + testsuite/tests/codeGen/should_compile/T27694d.hs - testsuite/tests/codeGen/should_compile/all.T - + testsuite/tests/codeGen/should_run/T27694b.hs - + testsuite/tests/codeGen/should_run/T27694b.stdout - + testsuite/tests/codeGen/should_run/T27915.hs - + testsuite/tests/codeGen/should_run/T27915.stdout-ws-32 - + testsuite/tests/codeGen/should_run/T27915.stdout-ws-64 - testsuite/tests/codeGen/should_run/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d72b2358d7022970ee1aceb9c85a02... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d72b2358d7022970ee1aceb9c85a02... 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