Repository navigation
Add codeview_annotation intrinsic - #160285
Conversation
codeview_annotation intrinsic
This comment has been minimized.
This comment has been minimized.
734844e to
0740b67
Compare
This comment has been minimized.
This comment has been minimized.
0740b67 to
7161ffd
Compare
This comment has been minimized.
This comment has been minimized.
7161ffd to
37c9de9
Compare
37c9de9 to
8a0ad0d
Compare
This comment has been minimized.
This comment has been minimized.
d012be4 to
6d91060
Compare
This comment has been minimized.
This comment has been minimized.
6d91060 to
07eceeb
Compare
|
cc @rust-lang/miri Any special-casing of Miri in the standard library requires review. cc @rust-lang/miri
cc @rust-lang/miri
cc @bjorn3 Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter |
|
r? @folkertdev rustbot has assigned @folkertdev. Use Why was this reviewer chosen?The reviewer was selected based on:
|
07eceeb to
e9d57be
Compare
The function does not caues any UB or non-determinism (it returns
I have now removed the changes in |
There was a problem hiding this comment.
Please move this into the intrinsics folder.
| @@ -0,0 +1,17 @@ | |||
| // Verifies that `codeview_annotation` is a no-op under Miri | |||
| // and that Miri does not try to const eval `CodeViewAnnotationArgs::ARGS` | |||
There was a problem hiding this comment.
Why should Miri not const-eval the args? That seems strange.
There was a problem hiding this comment.
My thinking was that Miri should not do anything at all upon encountering this intrinsic including const evaluating the args. That's what I meant by "no-op under Miri" in the comment.
Now I realize that perhaps Miri should actively try to const eval and raise an error if ARGS fails to eval because that's exactly what we're doing for LLVM+PDB targets. So that this particular behaviour will be consistent in all cases.
What are your thoughts?
There was a problem hiding this comment.
So that this particular behaviour will be consistent in all cases.
Yeah that's what I thought -- and not just Miri but also other codegen backends.
I think you can just put a const { let _ignore = T::ARGS; } into the fallback body to achieve this.
There was a problem hiding this comment.
Fixed. Added const block in the fallback body to force const eval, added miri test for when const eval fails (src/tools/miri/tests/fail/intrinsics/codeview-annotation.rs) and removed //@ only-msvc from tests/ui/intrinsics/codeview-annotation-bad-args.rs which will now test const eval failure on all environments.
| @@ -1,12 +1,11 @@ | |||
| //! OS-specific functionality. | |||
|
|
|||
| #![unstable(feature = "darwin_objc", issue = "145496")] | |||
| #![stable(feature = "core_os", since = "CURRENT_RUSTC_VERSION")] | |||
There was a problem hiding this comment.
This PR should not stabilize anything. (It would have to go through the full team approval process otherwise as it would represent a permanent commitment we can never take back. And anyway a stabilization PR should never also add new features.) Why can't this be a new unstable feature instead?
There was a problem hiding this comment.
Got it.
If I change the feature gate on core::os to something like core_os, then anyone using items in, say, core::os::windows will require both the features codeview_annotation and core_os. That's acceptable, right?
There was a problem hiding this comment.
It's suboptimal but better than a drive-by stabilization.
e9d57be to
457ca69
Compare
This comment has been minimized.
This comment has been minimized.
457ca69 to
9b1f38c
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9b1f38c to
a339f69
Compare
There was a problem hiding this comment.
Some small things, @RalfJung does the const eval stuff look OK to you otherwise?
| .filter_map(|trait_clause| { | ||
| let trait_ref = trait_clause.skip_binder().trait_ref; | ||
| tcx.associated_items(trait_ref.def_id) | ||
| .in_definition_order() | ||
| .find(|item| { | ||
| item.tag() == ty::AssocTag::Const | ||
| && tcx.item_name(item.def_id).as_str() == "ARGS" | ||
| }) | ||
| .map(|item| (item.def_id, trait_ref.args)) | ||
| }) | ||
| .next() |
There was a problem hiding this comment.
this can be find_map I think?
| mir::ConstValue::Slice { alloc_id, meta } => Some((alloc_id, Size::ZERO, meta)), | ||
| mir::ConstValue::Indirect { alloc_id, offset } => read_slice_pointer(tcx, alloc_id, offset) |
There was a problem hiding this comment.
Why are both branches needed?
There was a problem hiding this comment.
Looks like we'll only ever get ConstValue::Indirect in this case so I removed ConstValue::Slice. Thanks.
This comment has been minimized.
This comment has been minimized.
|
On the const-eval / Miri side there's just the fallback body and that seems reasonable to me. |
a339f69 to
9d8da0d
Compare
|
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. |
| #[cfg_attr(windows, doc = "```")] | ||
| #[cfg_attr(not(windows), doc = "```ignore (needs windows)")] |
There was a problem hiding this comment.
hmm, we have
```ignore-windows
but sadly not currently
```only-windows
it would be nice if rustdoc could do that
This comment has been minimized.
This comment has been minimized.
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 differencesShow 116 test diffsStage 1
Stage 2
Additionally, 96 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard f4d7ecfb0efc8330cef8f8020f192920d8721911 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (f4d7ecf): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis 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.
CyclesResults (secondary 2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 490.438s -> 497.38s (1.42%) |
View all comments
This PR adds:
codeview_annotation, which lowers to llvm.codeview.annotation and allows users to emit arbitraryS_ANNOTATIONrecords into PDB filesFor the underlying motivation and design details see:
codeview_annotationintrinsic compiler-team#1026codeview_annotationintrinsic libs-team#868Tracking issues:
codeview_annotationintrinsic #162252codeview_annotationAPI #163964Implementation details
CodeViewAnnotationArgs::ARGSfails to const eval.core::osmodule to a neutralcore_osin order to add the new modulecore::os::windows. It was earlier gated ondarwin_objc, which was not general enough.