Skip to content

Conversation

Zalathar
Copy link
Contributor

The metadata kind ID values declared in MetadataType are not part of the LLVM-C API, and are not machine-checked. If a value that we use ever goes out of sync with LLVM, the resulting bugs could be difficult to track down. And the existing values lack any clear indication of what LLVM declarations they correspond to.

On top of that, we currently have another way of expressing metadata kind IDs in the form of MetadataKindId, which creates confusing inconsistency in LLVM bindings.

This PR therefore consolidates all usage of “fixed” metadata kind IDs into one list of MetadataKindId constants, which is backed by static assertions in our C++ code that match them up with named anonymous-enum variants in llvm::LLVMContext.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 30, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 30, 2025

📌 Commit cc6329a has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 30, 2025
bors added a commit that referenced this pull request Sep 30, 2025
Rollup of 6 pull requests

Successful merges:

 - #142506 (Add `Path::has_trailing_sep` and related methods)
 - #146886 (Add repr(align(2)) to RcInner and ArcInner)
 - #147166 (several small `proc_macro` cleanups)
 - #147172 (bootstrap: build bootstrap docs with in-tree rustdoc)
 - #147181 (cg_llvm: Replace enum `MetadataType` with a list of `MetadataKindId` constants)
 - #147187 (remove unnecessary test directives)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6e577e1 into rust-lang:master Sep 30, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 30, 2025
rust-timer added a commit that referenced this pull request Sep 30, 2025
Rollup merge of #147181 - Zalathar:fixed-metadata, r=petrochenkov

cg_llvm: Replace enum `MetadataType` with a list of `MetadataKindId` constants

The metadata kind ID values declared in `MetadataType` are not part of the LLVM-C API, and are not machine-checked. If a value that we use ever goes out of sync with LLVM, the resulting bugs could be difficult to track down. And the existing values lack any clear indication of what LLVM declarations they correspond to.

On top of that, we currently have another way of expressing metadata kind IDs in the form of `MetadataKindId`, which creates confusing inconsistency in LLVM bindings.

This PR therefore consolidates all usage of “fixed” metadata kind IDs into one list of `MetadataKindId` constants, which is backed by static assertions in our C++ code that match them up with named anonymous-enum variants in `llvm::LLVMContext`.
@Zalathar Zalathar deleted the fixed-metadata branch September 30, 2025 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants