-
Notifications
You must be signed in to change notification settings - Fork 254
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
analyze: memcpy/memset, void* rewrites, and other fixes for algo_md5 #1043
Conversation
… by inner adjustment
mutbl: hir::Mutability, | ||
) -> bool { | ||
let adjusts = self.typeck_results.expr_adjustments(ex); | ||
if adjusts.len() < 2 { |
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.
a comment for the magic numbers would be helpful
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.
Refactored slightly in 6eca040 to make it clear we're inspecting the last two elements of adjusts
.
ex.span, ref_expr.span, mutbl | ||
); | ||
// Check whether the `&x` / `&mut x` expr got the expected adjustments. | ||
if self.expr_has_address_of_adjustments(ref_expr, mutbl) { |
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.
this is the part that extracts &x
from the cast?
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.
Added a small comment in 6eca040
&x as *const T
that don't get lowered to an actual MIRRvalue::Cast
assignmentunlower_map
has no origin" errors in algo_md5dataflow
changes for memcpy/memset. Specifically, this detects whether the memcpy/memset is affecting exactly one item (byte count ==mem::size_of::<T>()
, whereT
is the pointee type) or possibly more than one item. Multi-item memcpy/memset requires the OFFSET permission on the input pointers. The check formem::size_of::<T>()
uses the newrecent_writes
analysis to find the instruction that was used to compute the byte length argument.rewrite::expr::convert
to fold certain rewrites together. Specifically, when applying a MIR rewrite and there is already a HIR rewrite on the current node, in some cases it will edit the current rewrite instead of wrapping it. For example,mir_op::RewriteKind::MutToImm
applied toRewrite::Ref(rw, Mutability::Mut)
(&mut _
) will produceRewrite::Ref(rw, Mutability::Not)
(&_
) rather thanRef(Deref(Ref(rw, Mut)), Not)
(&*(&mut _)
). This fixes an issue with the removal of array.as_mut_ptr()
calls in cases where we're rewriting the resulting pointer type to a non-mut slice.input: *mut c_void
toinput: &[u8]
in certain algo_md5 function signatures.CVoidCasts
machinery, which is now superseded by pointee analysis and cast removal.