-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Inlining vs inout #471
Comments
Forcing inlining can easily cause bugs, because it bypasses all the verifications that inlining the function will behave correctly, that are described here: shader-minifier/src/inlining.fs Lines 172 to 197 in 3e25bdf
|
Ah, so perhaps this is user-error as I did not realize |
In a similar spirit to rule G requiring expression purity for |
Causing changes to already undefined behavior is acceptable. But it can introduce a bug in the case that the variable used as the
If safe: |
Yes, that's how I see it: detecting if it's safe or not to inline isn't easy, Improving the current rules is possible but it can be tricky to get the details right. They were chosen to balance multiple goals: preventing inlining from breaking the code, but still covering a lot of useful cases, but also not making the implementation too complex and the analysis too slow. |
Would it make sense to have a way to override inlining heuristic (inlining hint) that's separate from the existing "force inline" feature? |
When inlining a function, Minifier behaves as though all parameters are qualified
inout
.Contrived example reproducing the bug:
With the current single-expression-only inlining, this hasn't been an issue in practice. However it is likely to come up if allowing #470 .
The simplest fix is to enforce a rule:
Every parameter declaration of a function to be inlined must be either qualified
inout
or used immutably (no assignments).The text was updated successfully, but these errors were encountered: