-
Notifications
You must be signed in to change notification settings - Fork 353
Add a static alias analysis #3336
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
Conversation
|
Previews, as seen when this build job started (bf5074d): |
|
One main stinker with this is that error's relating to pointer alias-ing can only be detected by "diving into" a function that takes pointer arguments; so if someone is using a shader library then an internal change to the library can make the users of that library have their code go from acceptable into unacceptable even though the interface did not change. Maybe to have something more simple and shallow as follows:
I think this prevents any possibility of aliasing and makes the error check simple and makes the function declarations king. |
This analysis already handles the your proposed check without needing the extra pointer types. The problem with your proposal is that it misses aliases with module-scope variables, which the reason you have to look into the functions. |
Can you provide an example? I don't see issue.... |
|
Look at |
jimblandy
left a comment
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.
Yes, this looks great. Just some requested clarifications and suggestions.
wgsl/index.bs
Outdated
| * Pointer parameters that are [=write access|written=]. | ||
| * Pointer parameters that are [=read access|read=]. |
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 should clarify that parameters may be passed along to functions called from this function, and that the callees' usage is included in this.
wgsl/index.bs
Outdated
| corresponding parameter is in the written parameter set. | ||
| * An argument of pointer type has a root identifier that is a global variable where: | ||
| * the corresponding parameter is in the set of written pointer parameters | ||
| and the modue-scope variable is in either the written or read set of |
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.
"module"
wgsl/index.bs
Outdated
|
|
||
| <div class='example wgsl' heading='Aliased memory views'> | ||
| A WGSL program [=shader-creation error|must not=] contain any potential aliases. | ||
| The program is analyzed from the leaves of the callgraph upwards (e.g. topological order). |
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.
editorial: Suggest "(that is, in topological order)". "e.g." is "for example".
wgsl/index.bs
Outdated
| module-scope variables for the called function, or | ||
| * the corresponding parameter is in the set of read pointer parameters and | ||
| the module-scope variable is in the written set of module-scope | ||
| variables for the called function. |
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.
Suggestion: I think this might be a bit easier to follow if it were split into three cases:
- parameter read, module-scope written
- parameter written, module-scope read
- both parameter and module-scope written
As it is now, the two cases are not quite symmetrical and it took me a few tries to see that they are correct as written.
Just a suggestion, if you think it's indeed clearer.
WGSL 2022-08-30 Minutes
|
Fixes gpuweb#1457 * Replace the aliasing section with a static analysis * topological ordering * disallows potential aliasing * same root identifier used as multiple pointer arguments * pointer parameter aliasing a global variable
* clarifications * updated example * fix typos
b9f1184 to
1cf9e61
Compare
|
Previews, as seen when this build job started (1cf9e61): |
dneto0
left a comment
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.
Thanks!
WGSL 2022-09-06 Minutes
|
|
Agreed to land this on 2022-09-20 |
WGSL 2022-09-20 Minutes
|
Fixes #1457