Skip to content
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

add safety for noalias on a parameter #476

Open
andrewrk opened this issue Sep 14, 2017 · 2 comments
Open

add safety for noalias on a parameter #476

andrewrk opened this issue Sep 14, 2017 · 2 comments
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. research This proposal requires a considerable amount of investigation before it can be considered.
Projects
Milestone

Comments

@andrewrk
Copy link
Member

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.

@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Sep 14, 2017
@andrewrk andrewrk added this to the 0.2.0 milestone Sep 14, 2017
@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Oct 19, 2017
@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Feb 28, 2018
@BarabasGitHub
Copy link
Contributor

we should probably pass slices as 2 parameters, the pointer and the length. This way we can add parameter attributes to the pointer parameter.

Can't you do a noalias on a slice? Or are slices internally passed by reference currently?

@andrewrk andrewrk modified the milestones: 0.4.0, 0.5.0 Feb 15, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Sep 11, 2019
@andrewrk andrewrk added this to To do in Safety Oct 17, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Feb 10, 2020
@andrewrk andrewrk added proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. and removed enhancement Solving this issue will likely involve adding new logic or components to the codebase. labels Oct 9, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 9, 2020
@matu3ba
Copy link
Contributor

matu3ba commented Jan 26, 2021

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.

Fingers crossed that the LLVM IR does not break everything, once they enable noalias. This would also require implementing pointer provenance.

@andrewrk andrewrk added the research This proposal requires a considerable amount of investigation before it can be considered. label Apr 21, 2021
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Apr 21, 2021
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. research This proposal requires a considerable amount of investigation before it can be considered.
Projects
Safety
  
To do
Development

No branches or pull requests

3 participants