Skip to content

Remove dead switch-table disassembly code from the xarch emitter - #130797

Merged
tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-jit-dead-switch-table-disasm
Jul 15, 2026
Merged

tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-jit-dead-switch-table-disasm

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Removes dead switch-table disassembly code from the xarch emitter.

The INS_i_jmp block in emitter::emitDispAddrMode identified a jump-table data section by testing jdsc->dsSize & 1 (an odd-size marker), then printed a J_M%03u_DS%02u label and adjusted the displacement, and a trailing block dumped the table's BasicBlock* targets.

No data section ever has an odd dsSize today: emitDataGenBeg asserts (size % dataSection::MIN_DATA_ALIGN) == 0 and emitBBTableDataGenBeg stores even numEntries * elemSize. Jump-table sections are now discriminated by dsType (blockRelative32 / blockAbsoluteAddr), so the odd-size marker is a pre-dsType fossil — jdsc is always null and both display blocks are unreachable. Their sole producer, emitIns_IJ (the only function that emitted an address-mode INS_i_jmp with a jump-table idMemCookie), has no callers; modern switch codegen (genTableBasedSwitch) emits jmp reg. git log -S on both the marker and emitIns_IJ surfaces only the 2020 directory-move (#44973), so this has been dead for a long time.

This removes:

  • the jtno / jdsc locals, the INS_i_jmp label-finder loop + if (jdsc) printf, and the if (jdsc && !noDetail) table dump in emitDispAddrMode
  • the now-vestigial noDetail parameter (its only non-default caller passed isNew purely to gate the dead dump)
  • the dead emitIns_IJ

This is DEBUG-only display code with no behavior change on any live path -- the only reachable address-mode INS_i_jmp is genNonLocalJmp's jmp [mem], which never carried a jump-table cookie, so jdsc stayed null there and disp was never adjusted.

The disassembly is unaffected because the same information is already produced by the live paths:

  • the instruction that references the table (lea reg, [@RWD00] from genJumpTable via emitIns_R_C) is labeled by emitDispClsVar as @RWD%02u
  • the table entries are dumped by emitter::emitDispDataSec, called from emitOutputDataSec under opts.disAsm, keyed off dsType == blockRelative32 / blockAbsoluteAddr, as dd/dq <blockLabel> ; case <blockLabel>
  • genEmitJumpTable emits the verbose J_M%03u_DS%02u LABEL DWORD header + entries during codegen

Other architectures are unaffected: the odd-dsSize marker was xarch-only, arm already identifies the table correctly via dsType == blockAbsoluteAddr (reachable through its movw/movt), and arm64 / riscv64 / loongarch64 have no arch-specific jump-table display walk at all (they rely on the shared emitDispDataSec + @RWD labels).

Built clr.jit -c checked -a x64 (0 warnings / 0 errors) and ran jitformat.py (no changes).

Note

This PR description was drafted by GitHub Copilot on behalf of the author.

The INS_i_jmp label block in emitDispAddrMode keyed off an odd dsSize marker that no data section ever sets (all sizes are even and jump-table sections are now discriminated by dsType), so jdsc was always null and both display blocks were unreachable. Their sole producer, emitIns_IJ, had no callers, and the switch-table label/entries are already emitted by genEmitJumpTable. Remove the dead display code, the now-vestigial noDetail parameter, and emitIns_IJ.

Co-authored-by: Copilot App <[email protected]>
Copilot AI review requested due to automatic review settings July 15, 2026 16:26
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 15, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@tannergooding

Copy link
Copy Markdown
Member Author

CC. @dotnet/jit-contrib, @EgorBo

This is simply removal of long dead code from the xarch emitter.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes unreachable, legacy switch/jump-table disassembly logic from the xarch JIT emitter, simplifying debug output code paths without impacting codegen or runtime behavior.

Changes:

  • Removes the dead emitIns_IJ helper (no remaining references in the repo).
  • Simplifies emitter::emitDispAddrMode by deleting the unreachable jump-table label/dump logic and removing the now-vestigial noDetail parameter.
  • Updates xarch instruction display call sites to use the simplified emitDispAddrMode signature.
Show a summary per file
File Description
src/coreclr/jit/emitxarch.h Drops emitDispAddrMode’s noDetail parameter and removes the emitIns_IJ declaration.
src/coreclr/jit/emitxarch.cpp Removes the dead emitIns_IJ definition and deletes the unreachable jump-table disassembly blocks in emitDispAddrMode; updates all local callers accordingly.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@tannergooding
tannergooding enabled auto-merge (squash) July 15, 2026 18:12
@tannergooding
tannergooding merged commit 9dc7aee into dotnet:main Jul 15, 2026
142 checks passed
@tannergooding
tannergooding deleted the tannergooding-jit-dead-switch-table-disasm branch July 15, 2026 23:26
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 16, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants