Repository navigation
Fix #4008: Renumber metadata before printing final IR on LLVM 24 - #4009
Merged
Merged
Conversation
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
approved these changes
Nov 6, 2026
aneshlya
marked this pull request as ready for review
November 6, 2026 17:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-optdid not ask, somemory-access-materialize.llfailed: it got!filename !4 ...where the test expects!0.ispc --emit-llvm-texthad the same problem: on trunk, the first function's!dbgwas!73and!llvm.module.flagswas out of order.Changes, both guarded by
ISPC_LLVM_VERSION >= ISPC_LLVM_24_0:tools/ispc-opt.cpp: passShouldRenumberMetadata=truetoPrintModulePass, as upstreamoptdoes.src/module.cpp: callModule::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:check-all: 743 passed, 99 unsupported, 16 expectedly failed, 0 failed.memory-access-materialize.llpasses again.--emit-llvm-textoutput now matches anllvm-as | llvm-disround trip exactly, apart from the ModuleID line.No released LLVM supported by ISPC was available locally, so PR CI covers the
#elsebranches. Those branches are the original code, unchanged.🤖 Generated with Claude Code