Skip to content

Fix #4008: Renumber metadata before printing final IR on LLVM 24 - #4009

Merged
aneshlya merged 1 commit into
mainfrom
claude/issue-4008-renumber-metadata
Nov 6, 2026
Merged

aneshlya merged 1 commit into
mainfrom
claude/issue-4008-renumber-metadata

Conversation

@claude

@claude claude Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #4008

LLVM trunk (24) now gives each metadata node a persistent print ID. Since that change, printed IR only gets the canonical !0, !1, ... numbering if the caller asks for it. ispc-opt did not ask, so memory-access-materialize.ll failed: it got !filename !4 ... where the test expects !0. ispc --emit-llvm-text had the same problem: on trunk, the first function's !dbg was !73 and !llvm.module.flags was out of order.

Changes, both guarded by ISPC_LLVM_VERSION >= ISPC_LLVM_24_0:

  • tools/ispc-opt.cpp: pass ShouldRenumberMetadata=true to PrintModulePass, as upstream opt does.
  • src/module.cpp: call Module::renumberMetadataForAssembly() before printing for --emit-llvm-text.

Intermediate debug dumps (--debug-phase, debug module prints) are left as they are, because LLVM documents renumbering as only for final output.

Testing on LLVM trunk 24.0.0git, configured with -DCMAKE_CXX_FLAGS=-Werror:

  • The build passes with no warnings.
  • check-all: 743 passed, 99 unsupported, 16 expectedly failed, 0 failed. memory-access-materialize.ll passes again.
  • --emit-llvm-text output now matches an llvm-as | llvm-dis round trip exactly, apart from the ModuleID line.

No released LLVM supported by ISPC was available locally, so PR CI covers the #else branches. Those branches are the original code, unchanged.

🤖 Generated with Claude Code

LLVM trunk now gives each metadata node a persistent print ID
("[IR] Use persistent metadata IDs for printing"), so printed IR only
gets the canonical !0, !1, ... numbering when the caller asks for it.
ispc-opt did not ask, which broke the keeps_metadata check in
memory-access-materialize.ll, and --emit-llvm-text output had the same
non-canonical numbering.

Ask ispc-opt's PrintModulePass to renumber, as upstream opt does, and
call Module::renumberMetadataForAssembly() before printing for
--emit-llvm-text. Both are guarded by ISPC_LLVM_24_0. Intermediate
debug dumps (--debug-phase, debug module prints) are not renumbered,
because LLVM says renumbering is only for final output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aneshlya
aneshlya marked this pull request as ready for review November 6, 2026 17:05
@aneshlya
aneshlya merged commit ae2ae73 into main Nov 6, 2026
167 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLVM trunk nightly build failure

1 participant