Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 15.5k
Emit nofree attribute#156281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Emit nofree attribute #156281
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -122,6 +122,11 @@ mod attr_impl { | ||
| const InReg = 1 << 6; | ||
| const NoUndef = 1 << 7; | ||
| const Writable = 1 << 8; | ||
| /// It is UB for this pointer or any pointer derived from it to be used for | ||
| /// deallocation (except for zero-sized deallocation) while the function is | ||
| /// executing. Only valid on arguments (including return values that are passed | ||
| /// indirectly as arguments). | ||
| const NoFree = 1 << 9; | ||
RalfJung marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| } | ||
| rustc_data_structures::external_bitflags_debug! { ArgAttribute } | ||
| @@ -143,9 +148,8 @@ pub enum ArgExtension { | ||
| pub struct ArgAttributes { | ||
| pub regular: ArgAttribute, | ||
| pub arg_ext: ArgExtension, | ||
| /// The minimum size of the pointee, guaranteed to be valid for the duration of the whole call | ||
| /// (corresponding to LLVM's dereferenceable_or_null attributes, i.e., it is okay for this to be | ||
| /// set on a null pointer, but all non-null pointers must be dereferenceable). | ||
| /// If the pointer is not null, the minimum dereferenceable size of the pointee, at the time of | ||
| /// function entry (for arguments) or function return (for return values). | ||
| pub pointee_size: Size, | ||
| /// The minimum alignment of the pointee, if any. | ||
| pub pointee_align: Option<Align>, | ||
| @@ -408,7 +412,8 @@ impl<'a, Ty> ArgAbi<'a, Ty> { | ||
| .set(ArgAttribute::NoAlias) | ||
| .set(ArgAttribute::CapturesAddress) | ||
| .set(ArgAttribute::NonNull) | ||
| .set(ArgAttribute::NoUndef); | ||
| .set(ArgAttribute::NoUndef) | ||
| .set(ArgAttribute::NoFree); | ||
| attrs.pointee_size = layout.size; | ||
| attrs.pointee_align = Some(layout.align.abi); | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also don't want LLVM
dereferenceableon return values (see the comment incompiler/rustc_ty_utils/src/abi.rsthat you removed). Where is that handled now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's handled here: https://github.com/rust-lang/rust/pull/156281/changes#diff-eb5b0fc5c9734679907fdb908c3a6b424ff723c4dceb364eef2588c996366708R404 That is, we never set NoFree on return values (and thus also not dereferenceable).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a subtle non-local invariant and you removed the comment that explains it. Please add that comment back.