Skip to content

Add codeview_annotation intrinsic - #160285

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
gurry:add-codeview-annotation-intrinsic
Oct 17, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
gurry:add-codeview-annotation-intrinsic

Conversation

@gurry

@gurry gurry commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

This PR adds:

  • A new intrinsic called codeview_annotation, which lowers to llvm.codeview.annotation and allows users to emit arbitrary S_ANNOTATION records into PDB files
  • A std lib API to call this intrinsic

For the underlying motivation and design details see:

Tracking issues:

Implementation details

  • Codgen happens only on LLVM backend and only if the target uses PDBs. It is a no-op in all other cases. A compile error will still be emitted in all cases (even on non-LLVM, non-PDB ones) if CodeViewAnnotationArgs::ARGS fails to const eval.
  • Had to change the feature gate on core::os module to a neutral core_os in order to add the new module core::os::windows. It was earlier gated on darwin_objc, which was not general enough.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 31, 2026
@gurry gurry changed the title Add codeview_annotation intrinsic Add codeview_annotation intrinsic Jul 31, 2026
@rust-bors

This comment has been minimized.

@gurry
gurry force-pushed the add-codeview-annotation-intrinsic branch from 734844e to 0740b67 Compare August 11, 2026 07:10
@rust-bors

This comment has been minimized.

@gurry
gurry force-pushed the add-codeview-annotation-intrinsic branch from 0740b67 to 7161ffd Compare August 19, 2026 07:04
@rust-bors

This comment has been minimized.

@rust-bors

This comment has been minimized.

@gurry
gurry force-pushed the add-codeview-annotation-intrinsic branch 2 times, most recently from d012be4 to 6d91060 Compare October 9, 2026 11:10
@rustbot rustbot added the O-windows Operating system: Windows label Oct 9, 2026
@rust-log-analyzer

This comment has been minimized.

@gurry
gurry force-pushed the add-codeview-annotation-intrinsic branch from 6d91060 to 07eceeb Compare October 9, 2026 13:12
@gurry
gurry marked this pull request as ready for review October 10, 2026 03:29
@rustbot

rustbot commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

⚠️ #[miri::intrinsic_fallback_is_spec] must only be used if the function actively checks for all UB cases,
and explores the possible non-determinism of the intrinsic.

cc @rust-lang/miri

Any special-casing of Miri in the standard library requires review.

cc @rust-lang/miri

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

rustc_codegen_cranelift is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_cranelift instead.

cc @bjorn3

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 10, 2026
@rustbot

rustbot commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 17 candidates

@gurry
gurry force-pushed the add-codeview-annotation-intrinsic branch from 07eceeb to e9d57be Compare October 10, 2026 05:11
@gurry

gurry commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author

⚠️ #[miri::intrinsic_fallback_is_spec] must only be used if the function actively checks for all UB cases, and explores the possible non-determinism of the intrinsic.

The function does not caues any UB or non-determinism (it returns () and has no run-time side effects) so the fallback should be fine.

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

...
rustc_codegen_cranelift is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_cranelift instead.

I have now removed the changes in rustc_codegen_gcc and rustc_codegen_cranelift. I had earlier added explicit no-op handling for the intrinic in these backends, but I think the fallback function is enough.

Comment thread library/core/src/os/mod.rs Resolved
@gurry
gurry force-pushed the add-codeview-annotation-intrinsic branch from e9d57be to 457ca69 Compare October 10, 2026 11:43
@rust-log-analyzer

This comment has been minimized.

@gurry
gurry force-pushed the add-codeview-annotation-intrinsic branch from 457ca69 to 9b1f38c Compare October 10, 2026 14:15
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@gurry
gurry force-pushed the add-codeview-annotation-intrinsic branch from 9b1f38c to a339f69 Compare October 11, 2026 08:26

@folkertdev folkertdev 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.

Some small things, @RalfJung does the const eval stuff look OK to you otherwise?

View changes since this review

@rust-bors

This comment has been minimized.

@RalfJung

Copy link
Copy Markdown
Member

On the const-eval / Miri side there's just the fallback body and that seems reasonable to me.

@gurry
gurry force-pushed the add-codeview-annotation-intrinsic branch from a339f69 to 9d8da0d Compare October 14, 2026 09:04
@rustbot

rustbot commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@folkertdev folkertdev 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.

Looks good, thanks!

@bors r+

View changes since this review

Comment thread library/core/src/os/windows.rs Resolved
@rust-bors

rust-bors Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9d8da0d has been approved by folkertdev

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Oct 16, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 17, 2026
@rust-bors

rust-bors Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: folkertdev
Duration: 2h 58m 8s
Pushing f4d7ecf to main...

@rust-bors
rust-bors Bot merged commit f4d7ecf into rust-lang:main Oct 17, 2026
15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 5d8fec0 (parent) -> f4d7ecf (this PR)

Test differences

Show 116 test diffs

Stage 1

  • [codegen] tests/codegen-llvm/intrinsics/codeview-annotation-non-pdb-targets.rs: [missing] -> pass (J2)
  • [codegen] tests/codegen-llvm/intrinsics/codeview-annotation.rs#OPT0: [missing] -> ignore (only executed when the target environment is msvc) (J2)
  • [codegen] tests/codegen-llvm/intrinsics/codeview-annotation.rs#OPT3: [missing] -> ignore (only executed when the target environment is msvc) (J2)
  • [ui] tests/ui/feature-gates/feature-gate-codeview_annotation.rs: [missing] -> ignore (only executed when the operating system is windows) (J4)
  • [ui] tests/ui/intrinsics/codeview-annotation-bad-args.rs: [missing] -> pass (J4)
  • [ui] tests/ui/intrinsics/codeview-annotation.rs: [missing] -> ignore (only executed when the operating system is windows) (J4)
  • [ui (polonius)] tests/ui/feature-gates/feature-gate-codeview_annotation.rs: [missing] -> ignore (only executed when the operating system is windows) (J7)
  • [ui (polonius)] tests/ui/intrinsics/codeview-annotation-bad-args.rs: [missing] -> pass (J7)
  • [ui (polonius)] tests/ui/intrinsics/codeview-annotation.rs: [missing] -> ignore (only executed when the operating system is windows) (J7)

Stage 2

  • [codegen] tests/codegen-llvm/intrinsics/codeview-annotation-non-pdb-targets.rs: [missing] -> pass (J0)
  • [codegen] tests/codegen-llvm/intrinsics/codeview-annotation.rs#OPT0: [missing] -> ignore (only executed when the target environment is msvc) (J0)
  • [codegen] tests/codegen-llvm/intrinsics/codeview-annotation.rs#OPT3: [missing] -> ignore (only executed when the target environment is msvc) (J0)
  • [ui] tests/ui/feature-gates/feature-gate-codeview_annotation.rs: [missing] -> ignore (only executed when the operating system is windows) (J1)
  • [ui] tests/ui/intrinsics/codeview-annotation.rs: [missing] -> ignore (only executed when the operating system is windows) (J1)
  • [ui] tests/ui/feature-gates/feature-gate-codeview_annotation.rs: [missing] -> pass (J3)
  • [ui] tests/ui/intrinsics/codeview-annotation.rs: [missing] -> pass (J3)
  • [codegen] tests/codegen-llvm/intrinsics/codeview-annotation-non-pdb-targets.rs: [missing] -> ignore (ignored when the target environment is msvc) (J5)
  • [codegen] tests/codegen-llvm/intrinsics/codeview-annotation.rs#OPT0: [missing] -> pass (J5)
  • [codegen] tests/codegen-llvm/intrinsics/codeview-annotation.rs#OPT3: [missing] -> pass (J5)
  • [ui] tests/ui/intrinsics/codeview-annotation-bad-args.rs: [missing] -> pass (J6)

Additionally, 96 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard f4d7ecfb0efc8330cef8f8020f192920d8721911 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-loongarch64-linux: 5h 44m -> 1h 19m (-77.0%)
  2. dist-loongarch64-musl: 5h 40m -> 1h 31m (-73.0%)
  3. test-i686-gnu-nopt-1: 1h 31m -> 2h 24m (+58.5%)
  4. test-x86_64-msvc-ext2: 1h 9m -> 1h 50m (+58.3%)
  5. dist-arm-linux-gnueabi: 1h 4m -> 1h 41m (+57.9%)
  6. test-x86_64-gnu: 1h 42m -> 2h 36m (+53.2%)
  7. dist-s390x-linux: 1h 3m -> 1h 33m (+47.8%)
  8. dist-x86_64-solaris: 1h 10m -> 1h 43m (+47.6%)
  9. dist-powerpc64le-linux-musl: 1h 8m -> 1h 38m (+44.5%)
  10. dist-i686-linux: 1h 20m -> 1h 53m (+42.2%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (f4d7ecf): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (secondary 4.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.2% [4.2%, 4.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary 2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 490.438s -> 497.38s (1.42%)
Artifact size: 406.97 MiB -> 407.06 MiB (0.02%)

@gurry
gurry deleted the add-codeview-annotation-intrinsic branch October 25, 2026 06:54
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. merged-by-bors This PR was explicitly merged by bors. O-windows Operating system: Windows T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants