add llvm writable attribute conditionally#155207
add llvm writable attribute conditionally#155207quiode wants to merge 11 commits 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 |
|
|
||
| impl<S: Stage> NoArgsAttributeParser<S> for RustcNoWritableParser { | ||
| const PATH: &[Symbol] = &[sym::rustc_no_writable]; | ||
| const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn; |
There was a problem hiding this comment.
I think it's nicest for all new attributes to be Error on duplicate
I'll go make a PR to give this const a default value
|
@bors try @rust-timer queue |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
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.
Co-authored-by: Ralf Jung <post@ralfj.de>
Co-authored-by: Ralf Jung <post@ralfj.de>
Co-authored-by: Ralf Jung <post@ralfj.de>
|
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 |
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.