-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
add safety for noalias on a parameter #476
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
Comments
Can't you do a noalias on a slice? Or are slices internally passed by reference currently? |
Fingers crossed that the LLVM IR does not break everything, once they enable noalias. This would also require implementing pointer provenance. |
Just comparing a function's arguments would be useful already, but complete safety coverage would require run-time tracking of pointer provenance, through e.g. fat pointers. This could subsume our use of the AddressSanitizer; as far as I recall, addrsan's shadow heap is significantly faster than pointer tagging, but there has been some recent research on this topic, which may at least offer lower memory overhead than addrsan as a tradeoff. A potentially a much larger downside is that no tagging approach (that I'm aware of) can preserve full compatibility with non-instrumented code. This is rather fundamental, as LLVM's semantics associate properties with the individual pointer values, not just the addresses they refer to, but I don't think it's completely unsolvable; maybe we can come up with a custom sanitizer of our own? |
When you call a function with pointer arguments marked as
noalias
, such as@memcpy
, it is undefined behavior for the pointer arguments to point to the same memory. We can insert a safety check for this. It should be pretty low cost.This should work for slices too, and it should ensure that the slices do not overlap. In order for the optimizer to potentially be able to use this information, we should probably pass slices as 2 parameters, the pointer and the length. This way we can add parameter attributes to the pointer parameter.
The text was updated successfully, but these errors were encountered: