add llvm writable attribute conditionally#155207
add llvm writable attribute conditionally#155207quiode wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_hir/src/attrs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_attr_parsing |
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? @RalfJung |
|
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
This generally looks good, thanks! I just hope this larger ArgAttribute won't cause us problems. Cc @nikic for the LLVM parts, in case you want to take a 2nd look.
I am not sure if there's anything special to look out for in the new attribute infrastructure; @jdonszelmann would be great if you could take a brief look at that part.
@rustbot author
| // The subset of llvm::Attribute needed for arguments, packed into a bitfield. | ||
| #[derive(Clone, Copy, Default, Hash, PartialEq, Eq, HashStable_Generic)] | ||
| pub struct ArgAttribute(u8); | ||
| pub struct ArgAttribute(u16); |
There was a problem hiding this comment.
Ah, this is unfortunate. We should benchmark this to ensure the larger bitfield isn't a problem.
|
Reminder, once the PR becomes ready for a review, use |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
add llvm writable attribute conditionally
|
💔 Test for 37fa495 failed: CI. Failed job:
|
|
^ The PR needs to be rebased |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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. |
|
@rustbot ready |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
add llvm writable attribute conditionally
|
This looks great, thanks! Please squash the commits. Let's hope the larger ArgAttribute does not cause a perf issue -- I kicked of a benchmark run to check this. |
|
@bors squash msg="add llvm writable attribute conditionally" |
This comment has been minimized.
This comment has been minimized.
|
🔨 11 commits were squashed into da2bbfb. |
|
Nice, I've not seen this in action before. :) |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (84b05e7): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 3.1%, secondary 1.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.3%, secondary 1.4%)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.756s -> 493.416s (0.54%) |
|
That looks good! This is just a secondary benchmark that has been rather noisy recently already, nothing to worry about IMO. @bors r+ |
View all comments
This PR tries to address rust-lang/unsafe-code-guidelines#584 (comment). It is part of a bachelor thesis supervised by @JoJoDeveloping and @RalfJung, for more information, see: Project_Description.pdf.
If the new
-Zllvm-writableflag is set, the llvm writable attribute is inserted for all mutable borrows. This can be conditionally turned off on a per-function basis using the#[rustc_no_writable]attribute. The new Undefined Behaviour introduced by this can detected by Miri, which is implemented here: rust-lang/miri#4947.Two library functions already received the
#[rustc_no_writable]attribute, as they are known to cause problems under the Tree Borrows aliasing model with implicit writes enabled.