Sylvain Henry pushed to branch wip/andreask/cfg-fix at Glasgow Haskell Compiler / GHC Commits: 6687da29 by Andreas Klebinger at 2026-11-03T15:46:32+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. * A store emits the code of its address before the code of its value, because the CFG records new blocks in generation order. Stores and atomic operations take their address from the new getNonClobberedAmode, so the value code cannot clobber it. * backendMaintainsCfg is now True for i386: it gets the CFG based layout, dead code elimination and the -dasm-lint check. Fixes #27694, #27915 Co-authored-by: Sylvain Henry <sylvain@haskus.fr> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> - - - - - 16 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/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/-/commit/6687da29673ca23f2ea0fab6e4393f00... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6687da29673ca23f2ea0fab6e4393f00... 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)
-
Sylvain Henry (@hsyl20)